开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜