vendredi 6 mars 2020

C++ Meyer's Singleton with arguments

Is it possible to define a Meyer's singleton (like this one) with arguments?

I know it is possible with the GOF style singleton (like here),

but I can't seem to make it work with Meyer's singletons:

// ...
public:

    static S& getInstance()
    {
        static S instance; // no way to pass arguments here ...
        return instance;
    }

Aucun commentaire:

Enregistrer un commentaire