Reputation: 185
Let's say I have some classes using templates like the following in some file(s) :
// PointerTemplates.hpp
template <class T>
class Smart_Ptr_A
{
// [...]
};
template <class T>
class Smart_Ptr_B
{
// [...]
};
I would like to create another templated class that can use any of the previous classes.
Something like :
// ClassFoo.hpp
class ClassBar;
template<class PtrType>
class ClassFoo
{
// [...]
PtrType<ClassBar> m_pBar;
};
How could I do that ?
Upvotes: 0
Views: 703
Reputation: 206727
You will need to use a template template
parameter.
template <template<class> class PtrType>
class ClassFoo
{
// [...]
PtrType<ClassBar> m_pBar;
};
Upvotes: 3