#include <list>
template <typename ContainerType, typename ElementType>
class MyClass
{
public:
ElementType mSingleElement;
ContainerType<ElementType> mContainerOfElements;
};
int main(int argc, char* argv[])
{
MyClass<std::list, int> myClass;
return 0;
}
In particular, it complains about the line:
ContainerType<ElementType> mContainerOfElements;
With the error message:
error C3203: 'list' : unspecialized class template can't be used as a template argument for template parameter 'ContainerType', expected a real type[/quote]
I can get around this by writing it as follows:
#include <list>
template <typename ContainerType, typename ElementType>
class MyClass
{
public:
ElementType mSingleElement;
ContainerType mContainerOfElements;
};
int main(int argc, char* argv[])
{
MyClass<std::list<int>, int> myClass;
return 0;
}
This works, but it feels ugly to me that I have to specify 'int' twice in the following line:
MyClass<std::list<int>, int> myClass;
Is there are better way to write this?