operator- (ranges::zip_view:: sentinel )
|
||||||||||||||||||||||
| Range primitives | |||||||
|
|||||||
| Range concepts | |||||||||||||||||||
|
|||||||||||||||||||
| Range factories | |||||||||
|
|||||||||
| Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||
| Helper items | |||||||||||||||||
|
|
||||||||||||||||
| Member functions | ||||
| Deduction guides | ||||
| Iterator | ||||
| Member functions | ||||
| Non-member functions | ||||
| Sentinel | ||||
| Member functions | ||||
| Non-member functions | ||||
|
operator-
(zip_view::
iterator
,zip_view::
sentinel
)
|
|
template
<
bool
OtherConst
>
requires
(
std::
sized_sentinel_for
<
|
(1) | (C++23以降) |
|
template
<
bool
OtherConst
>
requires
(
std::
sized_sentinel_for
<
|
(2) | (C++23以降) |
x の基となるイテレータタプルと y の基となるセンチネルタプル間の最小距離を計算します。
これらの関数は通常の
unqualified lookup
または
qualified lookup
では可視化されず、
argument-dependent lookup
によってのみ発見され、その場合も
zip_view::
sentinel
<Const>
が引数の関連クラスである場合に限られます。
パラメータ
| x | - | iterator |
| y | - | sentinel |
戻り値
current_
を
x
の基盤となるイテレータのタプルとし、
end_
を
y
の基盤となるセンチネルのタプルとする。
DIST
(x, y, i)
を、ある整数
i
に対して
std
::
get
<
i
>
(
x.
current_
)
-
std
::
get
<
i
>
(
y.
end_
)
と同等の式で計算される距離とする。
0 ≤ i < sizeof...(Views)
内の全ての
i
における
DIST
(x, y, i)
の中で絶対値が最小の値
例
#include <cassert> #include <deque> #include <list> #include <ranges> #include <vector> int main() { auto x = std::vector{1, 2, 3, 4}; auto y = std::deque{'a', 'b', 'c'}; auto z = {1.1, 2.2}; auto w = std::list{1, 2, 3}; auto p = std::views::zip(x, y, z); assert(p.begin() - p.end() == +2); assert(p.end() - p.begin() == -2); [[maybe_unused]] auto q = std::views::zip(x, y, w); // 以下のコードはコンパイル時エラーを発生させます。std::list::iteratorは // 距離を計算するために必要なoperator-をサポートしていないためです: // auto e = q.begin() - q.end(); }