std::next
提供: cppreference.com
|
|
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
| ヘッダ <iterator> で定義
|
||
| template< class ForwardIt > ForwardIt next( ForwardIt it, |
(C++11およびそれ以降) | |
イテレータnのitth後継者を返す.
Original:
Return the nth successor of iterator it.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目次 |
[編集] パラメータ
| it | - | iterater '
Original: an iterater' The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| n | - | 前進する要素の数
Original: number of elements to advance The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| 型の要件 | ||
-ForwardIt は ForwardIterator の要件を満たさなければなりません。
| ||
[編集] 値を返します
イテレータnのitth後継.
Original:
The nth successor of iterator it.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 可能な実装
template<class ForwardIt> ForwardIt next(ForwardIt it, typename std::iterator_traits<ForwardIt>::difference_type n = 1) { std::advance(it, n); return it; } |
[編集] 例
Run this code
#include <iostream> #include <iterator> #include <vector> int main() { std::vector<int> v{ 3, 1, 4 }; auto it = v.begin(); auto nx = std::next(it, 2); std::cout << *it << ' ' << *nx << '\n'; }
出力:
3 4
[編集] 参照
| (C++11) |
イテレータをデクリメントします (関数) |
| イテレータを指定された距離だけ前進させます (関数) |