标签:boost noncopyable
C++ 编写一个不可复制的类
flyfish
Effective C++:条款06
若不想使用编译器自动生成的函数,就该明确拒绝 .
Explicitly disallow the use of complier-generated functions you do not want.
老式C++的写法
class noncopyable { protected: noncopyable() {} ~noncopyable() {} private: noncopyable( const noncopyable& ); noncopyable& operator=( const noncopyable& ); };
class noncopyable { protected: constexpr noncopyable() = default; ~noncopyable() = default; noncopyable( const noncopyable& ) = delete; noncopyable& operator=( const noncopyable& ) = delete; };
namespace boost { namespace noncopyable_ { class noncopyable { }; } typedef noncopyable_::noncopyable noncopyable; }
标签:boost noncopyable
原文地址:http://blog.csdn.net/flyfish1986/article/details/43305363