// http://www.modernescpp.com/index.php/thread-safe-initialization-of-a-singleton
// fast and thread safe
class MySingleton{
public:
static MySingleton& getInstance(){
static MySingleton instance;
return instance;
}
private:
MySingleton()= default;
~MySingleton()= default;
MySingleton(const MySingleton&)= delete;
MySingleton& operator=(const MySingleton&)= delete;
};
Created
May 25, 2018 08:30
-
-
Save ttchengcheng/34ba8636638dd9bea9405b16d91a10a9 to your computer and use it in GitHub Desktop.
Some C++ patterns
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment