Namespaces
Variants

iota_view에 대한 연역 가이드std::ranges::iota_view

From ko.cppreference.net
 
 
Ranges 라이브러리
범위 어댑터
 
 
헤더 <ranges>
template< class W, class Bound >
    requires (!/*is-integer-like*/<W> ||
              !/*is-integer-like*/<Bound> ||
              /*is-signed-integer-like*/<W> == /*is-signed-integer-like*/<Bound>)
iota_view( W, Bound ) -> iota_view<W, Bound>;
에 정의됨 (C++20부터)

이 연역 가이드는 iota_view이 초깃값과 경계값으로부터 연역될 수 있도록 제공됩니다.

/*is-integer-like*/ 및 /*is-signed-integer-like*/의 정의는 is-integer-like 을 참조하십시오.

이 가이드는 views::iota(0, v.size())과 같이 부호 불일치로 인한 버그를 방지합니다. 여기서 0는 부호 있는 정수이고 v.size()는 부호 없는 정수입니다.

예제

#include <cassert>
#include <ranges>
int main()
{
    auto io = std::ranges::iota_view(1L, 7L); // W와 Bound를 "long"으로 추론
    assert(io.front() == 1L and io.back() == 6L);
}