mardi 29 décembre 2015

How do I call make_shared or make_unique with a templated Constructor

How can I call make_shared or make_unique on a class that has a templated constructor? Here's an example:

class A
{
    template <class T> A() { ... }
};

make_shared<A<T>>() doesn't make sense (nor does it compile), since that would rather be for a templated class, not a templated constructor.

Neither make_shared<A><T>() nor make_shared<A>(<T>()) compile---nor look like they should. Ditto on make_shared<A, T>()

Is there any way to specify the template for the constructor call in the call to make_shared? I assume the answer would apply for make_unique; if it doesn't, please indicate that. Thanks!

Aucun commentaire:

Enregistrer un commentaire