How to use stty type of stl container when using templates?

I am trying to use size_type 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 does not work as I get a bunch of syntax errors.

+3
source share
2 answers
template <class T> T*
at(typename std::list<T*>::size_type pos);
// ^^^^^^^^

See also this question .

+3
source

Add typenameala:

template <class T>
T* at(typename std::list<T*>::size_type pos); 

Otherwise, the compiler does not know what size_type is.

+1
source

Source: https://habr.com/ru/post/1795161/


All Articles