C++从迭代器中获取整数形式的索引值
C++ get Index value in integer from iterator
我正在尝试从迭代器中获取索引值。但我一直得到错误"Indirection需要指针操作数('long'无效)"知道吗?我需要得到索引。在下面的示例中,它应该输出2。
template<typename T>
void practice(T begin, T end) {
T it = begin;
it++;
it++;
auto index = it - begin;
cout << *index;
cout << index;
无需*
取消引用。
相关文章:
- 如何在for循环中包含两个索引值的测试条件
- *无符号字符中的索引值
- 将最小值整数转换为无符号长整型
- 返回向量的单个索引值
- 如何在对向量排序后更改索引值?c++
- 为什么C++数组索引值是有符号的,而不是围绕size_t类型构建的(或者我错了)
- 如何计算 3d 数组中的索引值在内存中的位置?如何计算字符**中的索引值在内存中的位置?
- 如何在C++中为数组分配不同的索引值
- C++枚举索引值
- 查找索引值在char表中
- 根据索引值提取特定字节
- 尝试输出所有索引值(如果找到)
- 有没有办法创建一个花哨的迭代器和相应的新数组,以便检查每个索引的索引值的条件?
- 为什么在将单词从文本文件C++到行进行多重映射时获得额外的索引值
- C++使用 min_element 或 max_element 时检索向量中的索引值
- 为什么从右值整数向量的元素中推导 decltype(auto) 的类型是 int&?
- 如何使用二进制索引树来计算小于索引值的元素数量
- 存储数组索引值C++
- 在 for 循环中使用 int 以外的数据类型作为索引值C++
- C++从迭代器中获取整数形式的索引值