Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Template Class Compile Issue with Typedef Variables

Martin__Jonathan
Beginner
507 Views

I'm having an issue compiling a template class using a newer C++ compiler (going from Visual C++ 6.0 to Visual C++ 2015). All of the errors center around a handful of typedefs within the class. Here is a snippet of the header file:

template< class Type> class Vector
{
public:

    typedef Type* iterator;
    typedef const Type* const_iterator;
    typedef Type& reference;
    typedef const Type& const_reference;
    typedef size_t size_type;

    Vector();
    Vector( size_type Size, const_reference Object = Type() );
...
private:
    VectorImpl<Type>* m_pImpl;
};

template <typename Type> Vector<Type>::Vector()
{
    m_pImpl = new VectorImpl<Type>();
};

template <typename Type> Vector<Type>::Vector(Vector<Type>::size_type Size, Vector<Type>::const_reference Object)
{
    m_pImpl = new VectorImpl<Type>(Size, Object);
};

When the compiler attempts to build the template method implementation it throws an error when encountering the typedef parameter (i.e. 'Vector<Type>::size_type Size') I get an 'C2988 unrecognizable template declaration/definition' error. In other instances I get an 'C2061 syntax error: identifier 'size_type'' error.

Is there a formatting issue or could there be a compatibility issue with using typedefs in a template class?

0 Kudos
1 Reply
Viet_H_Intel
Moderator
507 Views

Hi Jonathan,

What is the version of Intel compiler? Did the source code compile with MS compiler?

Thanks,

Viet  

 

 

0 Kudos
Reply