/* Collection of code snippets by Arne Vajhøj */
/* (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) */
#ifndef VOLATILE_SINGLETON_11_H
#define VOLATILE_SINGLETON_11_H

#include <iostream>

using namespace std;

// **** double lock with volatile singleton pattern is not thread safe - never use it ****
class VolatileSingleton11
{
private:
    static volatile VolatileSingleton11* volatile instance;
    int SomeState;
    VolatileSingleton11() { SomeState = 123; }
public:
    VolatileSingleton11(const VolatileSingleton11& original) = delete;
    VolatileSingleton11& operator=(const VolatileSingleton11& original) = delete;
    static volatile VolatileSingleton11& Instance();
    void SomeMethod() { cout << SomeState << endl; }
};

#endif
