Hello Folks:
I don't use templates very often.
I'm doing something stupid.
Visual Studio doesn't like my list's const_iterator type declaration.
The following code causes Visual Studio to generate these warnings and errors:
circular_buffer.h(14,1): warning C4346: 'const_iterator': dependent name is not a type
circular_buffer.h(14,1): message : prefix with 'typename' to indicate a type
circular_buffer.h(16): message : see reference to class template instantiation 'CIRCULAR_BUFFER<T>' being compiled
circular_buffer.h(14,1): error C2061: syntax error: identifier 'const_iterator'
circular_buffer.h(14,1): error C2238: unexpected token(s) preceding ';'
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#ifndef CIRCULAR_BUFFER_H
#define CIRCULAR_BUFFER_H
#include <iostream>
#include <list>
template <class T>
class CIRCULAR_BUFFER
{
typedef std::list <T*> CIRCULAR_BUFFER_LIST;
private:
CIRCULAR_BUFFER_LIST::const_iterator test_iterator;
CIRCULAR_BUFFER_LIST buffer;
};
#endif
|
The code compiles if I comment the template stuff out and make the list a list of type int.
The compilation fails even if I never actually declare a variable of type CIRCULAR_BUFFER.
What am I doing wrong?
Thanks
Larry