operator- (std::counted_iterator<I>, std::default_sentinel_t)
From cppreference.net
<
cpp
|
iterator
|
counted iterator
C++
Iterator library
| Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::counted_iterator
| Member functions | ||||
| Non-member functions | ||||
|
(C++20)
(C++20)
|
||||
|
(C++20)
|
||||
|
(C++20)
|
||||
|
(C++20)
|
||||
|
operator-
(default_sentinel_t)
(C++20)
|
||||
|
(C++20)
|
||||
|
(C++20)
|
||||
| Helper classes | ||||
|
friend
constexpr
std::
iter_difference_t
<
I
>
operator
-
(
const counted_iterator & x, std:: default_sentinel_t ) ; |
(1) | (C++20以降) |
|
friend
constexpr
std::
iter_difference_t
<
I
>
operator
-
(
std:: default_sentinel_t , const counted_iterator & y ) ; |
(2) | (C++20以降) |
1)
終端までの負の距離を返します。
2)
終端までの正の距離を返します。
この関数テンプレートは通常の unqualified lookup または qualified lookup では可視化されず、引数に関連付けられたクラスとしてstd::counted_iterator<I>が存在する場合にのみ argument-dependent lookup によって発見されます。
目次 |
パラメータ
| x, y | - | 差を計算するイテレータアダプタ |
戻り値
1)
-
x.
count
(
)
2)
y.
count
(
)
例
このコードを実行
#include <initializer_list> #include <iterator> int main() { constexpr static auto v = {1, 2, 3, 4}; constexpr std::counted_iterator<std::initializer_list<int>::iterator> it{v.begin(), 3}; constexpr auto d1 = it - std::default_sentinel; static_assert(d1 == -3); // (1) constexpr auto d2 = std::default_sentinel - it; static_assert(d2 == +3); // (2) }
関連項目
counted_iterator
を進めるまたは戻す
(公開メンバ関数) |
|
|
(C++20)
|
イテレータを進める
(関数テンプレート) |
|
(C++20)
|
2つのイテレータアダプタ間の距離を計算する
(関数テンプレート) |
|
(C++20)
|
範囲の境界を知っているイテレータで使用するデフォルトセンチネル
(クラス) |