Features --
- Share the same singleton instance in dynamical library and executable.
- Multithread safe
- Lazy construction
- Lock-free with double checked mutex on initialization.
- define a class or struct, for example
class MyObject {
public:
int a;
int b;
};
- use the singleton instance
#include "singleton-cpp/singleton.h"
MyObject &obj = singleton<MyObject>();