#pragma oncetemplate<typename T>
class Singleton
{
public:
static std::shared_ptr<T> Instance()
{
if (_instance == nullptr)
{
_instance = std::make_shared<T>();
}
return _instance;
}
static void SetInstance(std::shared_ptr<T> instance)
{
_instance = instance;
}
private:
static std::shared_ptr<T> _instance;
};
template<typename T>
std::shared_ptr<T> Singleton<T>::_instance = nullptr;
#include "Singleton.h"
struct MyClass { ... };
extern template class Singleton<MyClass>;
#include "Singleton.h"
#include "MyClass.h"
template class Singleton<MyClass>;
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/ac428c5e-b062-4503-b994-ea4451c32251%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.