operator-(ranges::zip_view::sentinel)
template< bool OtherConst >
requires (std::sized_sentinel_for<
ranges::sentinel_t</*maybe-const*/<Const, Views>>,
ranges::iterator_t</*maybe-const*/<OtherConst, Views>>> && ...)
friend constexpr
std::common_type_t<ranges::range_difference_t</*maybe-const*/<OtherConst, Views>>...>
operator-( const iterator<OtherConst>& x, const sentinel& y );
|
(1) | (C++23부터) |
template< bool OtherConst >
requires (std::sized_sentinel_for<
ranges::sentinel_t</*maybe-const*/<Const, Views>>,
ranges::iterator_t</*maybe-const*/<OtherConst, Views>>> && ...)
friend constexpr
std::common_type_t<ranges::range_difference_t</*maybe-const*/<OtherConst, Views>>...>
operator-( const sentinel& y, const iterator<OtherConst>& x );
|
(2) | (C++23부터) |
x의 기본 반복자 튜플과 y의 기본 센티널 튜플 사이의 최소 거리를 계산합니다.
이 함수들은 일반적인 비한정 또는 한정 조회로는 볼 수 없으며, 인자 종속 조회를 통해서만 찾을 수 있습니다. 여기서 zip_view::sentinel<Const>은 인자의 연관 클래스입니다.
매개변수
| x | - | an iterator |
| y | - | a sentinel |
반환값
current_
를
x
의 기반 반복자 튜플로 표기하고,
end_
를
y
의 기반 센티넬 튜플로 표기한다.
DIST
(x, y, i)
를
std
::
get
<
i
>
(
x.
current_
)
-
std
::
get
<
i
>
(
y.
end_
)
와
동등한 표현식으로 계산된 거리라고 정의합니다.
여기서
i
는 정수입니다.
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(); }