C++ - 迭代器向量未编译的迭代器
C++ - iterator for a vector of iterators not compiling
我有一个模板化类P,它有一个const_iterator,我正在尝试制作所述迭代器的向量并遍历该向量:
std::vector<typename P<A, B>::const_iterator>::const_iterator it;
问题是当我尝试编译时,我得到
error: expected ‘;’ before ‘it’
关于为什么会发生这种情况的任何想法?
在std::vector<>
之前还需要一个typename
,因为P<A, B>
中至少有一个模板参数是依赖类型:
typename std::vector<typename P<A, B>::const_iterator>::const_iterator it;
const_iterator
的两种用法都依赖于模板参数;所以两者都需要typename
。
typename std::vector<typename P<A, B>::const_iterator>::const_iterator it;
^^^^^^^^ ^^^^^^^^
相关文章:
- 编译时二叉搜索树错误的反向迭代器表示"no matching function call for operator=()"
- 编译错误 std::vector<std::shared_ptr<T>>迭代器和擦除方法
- 如果我在下面的代码中使用 list 而不是 vector,为什么在我尝试在迭代器之间执行减法的行中编译失败?
- C++向量迭代器nth_element编译错误
- 为什么 std::variant 使用开始和结束迭代器进行编译?
- 在将迭代器与C 中的null进行比较时,编译误差
- 编译错误与迭代器取消引用的 decltype
- 使用set<set>迭代器的编译错误<int>
- 通过迭代器调用功能无法在派生对象上编译
- C :多态容器 /迭代器与编译时间概念 /特征
- 迭代器使用的编译时验证
- 从函数返回 ::迭代器不会编译
- 二叉树编译错误的迭代器
- C++:使用clang编译以迭代器为值的映射时出现巨大错误
- C++ - 未编译的对象向量的迭代器
- 编译错误 ::向量 ::迭代器
- 链表迭代器模板中的编译错误
- 取消引用字符串迭代器无法编译
- Clang 3.0 C++ std::map<>::迭代器编译错误
- 使用映射迭代器编译错误