C++ 中为了避免被不正确引用,经常会有不允许 copy 的对象,下面是 FNoncopyable 的 Class 模板
/**
* utility template for a class that should not be copyable.
* Derive from this class to make your class non-copyable
*/
class FNoncopyable
{
protected:
// ensure the class cannot be constructed directly
FNoncopyable() {}
// the class should not be used polymorphically
~FNoncopyable() {}
private:
FNoncopyable(const FNoncopyable&);
FNoncopyable& operator=(const FNoncopyable&);
};
网友评论