struct NoNewable
{
void *operator new(std::size_t) = delete; //禁止通过new操作符创建对象
};
struct NonCopyable
{
NonCopyable & operator=(const NonCopyable&) = delete; //禁止赋值
NonCopyable(const NonCopyable&) = delete; //禁止拷贝构造
NonCopyable() = default;
};
struct NonStack
{
private:
NonStack() = default; //禁止在栈上创建对象
public:
static NonStack* Create(){
return new NonStack;
}
};
struct OnlyInt{void f(int i);template<class T> void f(T) = delete; //禁止用非int类型参数调用f};