一种禁用拷贝函数基类和单例基类写法
#pragma once
namespace detail {
class DisallowCopy {
public:
DisallowCopy() = default;
~DisallowCopy() = default;
private:
DisallowCopy(const DisallowCopy&) = delete;
DisallowCopy(DisallowCopy&&) = delete;
void operator = (const DisallowCopy&) = delete;
void operator = (DisallowCopy&&) = delete;
};
template <class T>
class SimpleSingleton {
friend T;
public:
static T& Instance() {
static T inst;
return inst;
}
private:
SimpleSingleton() = default;
};
}