I'm converting a Visual Studio 6 project to Visual Studio 2010. The project uses STL heavily. After converting, the compiler gives an error. The code and error are as follows.
#include <list>
namespace mySpace
{
template <class T>
class MyList : public std::list<T>
{
public:
typedef std::list<T>::allocator_type AllocatorType;
}
Error: Error 2 error C2146: syntax error : missing ';' before identifier 'AllocatorType' c:\myProject\mylist.h 39 1
I can click on the 'allocator_type' text and hit F12 and the IDE takes me to the 'allocator_type' definition in list.
If I remove '::allocator_type' the error goes away.
Any ideas what would cause this?
It should be
You have to tell the compiler allocator_type is actually a type.
By the way, inheriting from STL containers isn't a great practice as they don't have virtual destructors.
Modify the typedef line as:
to state that
std::list<T>::allocator
is a type.