Abr*_*ile 2 c++ memory-alignment memcpy shared-ptr
我想通过使用单个调用来复制类CB中CA类的所有成员以memcpy获得性能原因.
在基本形式中,我认为它是可能的,因为它们都是CPtr只包含指针的类的成员 .
如果不是指针我使用类似boost::shared_ptr或std::shared_ptr?
这个想法是否有意义,我是否可以获得&a_和&c_的地址,计算偏移量并对memcpy&f_ 做?
class CBase {
virtual ~CBase(){}
};
class CPtr : public CBase{
int* p_; // what If I have shared_ptr<int> p_; ?
};
class CA {
public:
CPtr a_;
CPtr b_;
CPtr c_;
};
class CB {
public:
CPtr e_;
CPtr f_;
CPtr g_;
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
102 次 |
| 最近记录: |