I know that a Scott Meyers Singleton is thread-safe for C++11 and above. Is the following code also thread-safe (for C++11 and above)?
class T
{
static T* obj;
public:
T& GetInstance()
{
if (!obj)
{
obj = new T();
}
return *obj;
}
};
T* T::obj=nullptr;