开发者

How to use an stl container's size_type type when using templates?

开发者 https://www.devze.com 2023-02-14 00:53 出处:网络
I\'m trying to use the size_typ开发者_C百科e from std::list and I have the following list: std::list<T*> mylist;

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

精彩评论

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