Namespaces
Variants

operator- (ranges::zip_view:: sentinel )

From cppreference.net
Ranges library
Range adaptors
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 의 기반 센티넬 튜플 사이의 최소 거리를 계산합니다.

이 함수들은 일반적인 unqualified lookup 또는 qualified lookup 으로는 보이지 않으며, 인수들의 연관 클래스로 zip_view:: sentinel <Const> 가 있을 때에만 argument-dependent lookup 을 통해서만 찾을 수 있습니다.

매개변수

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 는 정수입니다.

1) 범위 0 ≤ i < sizeof...(Views) 내 모든 i 에 대한 DIST (x, y, i) 중 절댓값이 가장 작은 값
2) - ( x - y ) .

예제

#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();
}