mardi 5 juillet 2016

Initialize static std::map with unique_ptr as value

How can one initialize static map, where value is std::unique_ptr?

static void f()
{
    static std::map<int, std::unique_ptr<MyClass>> = {
        { 0, std::make_unique<MyClass>() }
    };
}

Of course this does not work (copy-ctor of std::unique_ptr is deleted).

Is it possible?

Aucun commentaire:

Enregistrer un commentaire