ngl_server 1.0
基于 Actor 模型的 C++ 服务器框架
ngl::tools::impl< T > Class Template Reference

Pimpl辅助包装类。 More...

#include <tools_impl.h>

Public Member Functions

 impl ()
 默认构造函数(延迟初始化)
 ~impl ()
 析构函数
template<typename ... ARG>
void make_unique (const ARG &... args)
 延迟构造实现对象。
std::unique_ptr< T > & operator() ()
 获取实现对象的引用。

Detailed Description

template<typename T>
class ngl::tools::impl< T >

Pimpl辅助包装类。

封装std::unique_ptr<T>,提供延迟构造和访问接口。 适用于需要隐藏实现细节、减少编译依赖的场景。

Template Parameters
T实现类型
Note
禁止拷贝,支持移动语义。
class MyClass {
impl<MyImpl> m_pimpl;
public:
void init() { m_pimpl.make_unique(arg1, arg2); }
void doWork() { m_pimpl()->work(); }
};

Member Function Documentation

◆ make_unique()

template<typename T>
template<typename ... ARG>
void ngl::tools::impl< T >::make_unique ( const ARG &... args)
inline

延迟构造实现对象。

Template Parameters
ARG构造参数类型
Parameters
args传递给T构造函数的参数

◆ operator()()

template<typename T>
std::unique_ptr< T > & ngl::tools::impl< T >::operator() ( )
inline

获取实现对象的引用。

Returns
std::unique_ptr<T>& unique_ptr引用

The documentation for this class was generated from the following file: