Last active
November 11, 2017 22:06
-
-
Save garrettsickles/8e79bfa912f9de4f2e79770119ef0842 to your computer and use it in GitHub Desktop.
singleton_c++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Singleton { | |
public: | |
// Singleton Pattern | |
// Instance() returns a single static instance of the Singleton class. | |
// This singleton is shared between a single compilation unit. | |
static Singleton& Instance() { | |
static Singleton singleton; | |
return singleton; | |
} | |
// Constructor/Destructor | |
Singleton() {}; | |
~Singleton() {}; | |
// Delete Copy and Move constructors and assign operators | |
Singleton(Singleton const&) = delete; // Copy constructor | |
Singleton(Singleton&&) = delete; // Move constructor | |
Singleton& operator=(Singleton const&) = delete; // Copy assignment | |
Singleton& operator=(Singleton &&) = delete; // Move assignment | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment