Consider the following snippet from an imaginary implementation of a shared_ptr
class:
template <class T>
{
template<class U>
shared_ptr(const shared_ptr<U>& other)
{
//do something
}
//to suppress the compiler from generating a copy-constructor, as the above template doesn't count
shared_ptr(const shared_ptr<T>& other)
{
//do the same thing as above
}
};
Would it be possible to delegate the call of non-template shared_ptr
to the template version with U=T
? I tried the following syntax but it didn't work
shared_ptr(const shared_ptr<T>& other)
:shared_ptr<T>(other)
{
}
Is there a syntax for delegating to a specific instantiation of a template constructor?
Aucun commentaire:
Enregistrer un commentaire