简体   繁体   中英

C++ - iterator for a vector of iterators not compiling

I have a templated class P that has a const_iterator and i'm trying to make a vector of said iterators and iterate through that vector:

std::vector<typename P<A, B>::const_iterator>::const_iterator it;

problem is when i try to compile i get

error: expected ‘;’ before ‘it’

any ideas as to why this is happening?

你需要一个typename之前std::vector<>以及因为在模板参数中的至少一个P<A, B>是一个依赖型:

typename std::vector<typename P<A, B>::const_iterator>::const_iterator it;

Both uses of const_iterator depend on template parameters; so both need typename .

typename std::vector<typename P<A, B>::const_iterator>::const_iterator it;
^^^^^^^^             ^^^^^^^^

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM