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

#include <iostream>
#include <mutex>

using namespace std;

class CallOnceSingleton11
{
private:
    static CallOnceSingleton11* instance;
    int SomeState;
    CallOnceSingleton11() { SomeState = 123; }
    static once_flag flag;
    static void Init();
public:
    CallOnceSingleton11(const CallOnceSingleton11& original) = delete;
    CallOnceSingleton11& operator=(const CallOnceSingleton11& original) = delete;
    static CallOnceSingleton11& Instance();
    void SomeMethod() { cout << SomeState << endl; }
};

#endif
