ranges_common_view

ranges_common_view (공통 뷰)

std::ranges::common_view은 반복자와 센티널이 같은 타입인 뷰로 공통 범위(common_range)로 만드는 뷰 어댑터예요. C++20부터 사용할 수 있어요.

출처: cppreference

본문

<ranges> 헤더에 정의되어 있고, 시그니처는 다음과 같아요.

template< ranges::view V >
    requires (not ranges::common_range<V> and
              std::copyable<ranges::iterator_t<V>>)
class common_view
    : public ranges::view_interface<common_view<V>>

(1) (since C++20)

namespace views {
    inline constexpr /* unspecified */ common = /* unspecified */;
}

(2) (since C++20)

호출 시그니처:

template< ranges::viewable_range R >
    requires /* see below */
constexpr /* see below */ common( R&& r );
    1. 기본 뷰 V의 모든 요소를 볼 수 있는 뷰로, 반복자와 센티널이 같은 타입이도록 만들어요 (common_range).
    1. common 뷰를 생성하는 뷰 어댑터 객체.

멤버 함수 (Member functions)

  • (constructor) — common 뷰 생성
  • base — 기본 뷰에 대한 참조 반환
  • begin — 반복자 반환
  • end — 같은 타입의 반복자/센티널 반환
  • size — 크기 반환 (sized일 때)

참고 (Notes)

반복자/센티널 타입이 다른 범위(예: 일부 뷰)를 전통적인 [first, last) 패턴을 요구하는 알고리즘이나 API에 넘기기 위해 common_range로 만들어 줘요. views::common으로 생성해요.

더 알아보기 (Learn more)

cppreference