How to use an stl container's size_type type when using templates?
I'm trying to use the size_typ开发者_C百科e from std::list and I have the following list:
std::list<T*> mylist;
template <class T>
T* at(std::list<T*>::size_type pos);
But this doesn't work as I get a bunch of syntax errors.
template <class T> T*
at(typename std::list<T*>::size_type pos);
// ^^^^^^^^
See also this question.
Add typename
ala:
template <class T>
T* at(typename std::list<T*>::size_type pos);
Otherwise, the compiler doesn't know what size_type could be.
精彩评论