谁能告诉我如何将迭代器增加 2?
Can anybody tell me how to increment the iterator by 2?
iter++ 可用 - 我必须做 iter+2 吗?我怎样才能做到这一点?
iter++ is available - do I have to do iter+2? How can I achieve this?
std::advance( iter, 2 );
此方法适用于不是随机访问迭代器的迭代器,但在与随机访问迭代器一起使用时,它仍然可以通过实现进行专门化,使其效率不低于 iter += 2.
This method will work for iterators that are not random-access iterators but it can still be specialized by the implementation to be no less efficient than iter += 2 when used with random-access iterators.
这篇关于如何将迭代器增加 2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
读取输入文件,最快的方法?read input files, fastest way possible?(读取输入文件,最快的方法?)
在 C++ 中读取格式化输入的最简单方法?The easiest way to read formatted input in C++?(在 C++ 中读取格式化输入的最简单方法?)
从 .txt 文件读取到 C++ 中的二维数组Reading from .txt file into two dimensional array in c++(从 .txt 文件读取到 C++ 中的二维数组)
如何在 C++ 中模拟按键按下How to simulate a key press in C++(如何在 C++ 中模拟按键按下)
为什么在 cin.ignore() 之后没有 getline(cin, var) 读取Why doesn#39;t getline(cin, var) after cin.ignore() read the first character of the string?(为什么在 cin.ignore() 之后没有 getline(cin, var) 读取
scanf 格式输入的 cin 类比是什么?What is the cin analougus of scanf formatted input?(scanf 格式输入的 cin 类比是什么?)