24 Ranges library [ranges]

24.5 Range utilities [range.utility]

24.5.3 Sub-ranges [range.subrange]

24.5.3.1 Constructors and conversions [range.subrange.ctor]

constexpr subrange(I i, S s) requires (!StoreSize);
Expects: [i, s) is a valid range.
Effects: Initializes begin_­ with i and end_­ with s.
constexpr subrange(I i, S s, iter_difference_t<I> n) requires (K == subrange_kind::sized);
Expects: [i, s) is a valid range, and n == ranges::distance(i, s).
Effects: Initializes begin_­ with i and end_­ with s.
If StoreSize is true, initializes size_­ with n.
[Note
:
Accepting the length of the range and storing it to later return from size() enables subrange to model SizedRange even when it stores an iterator and sentinel that do not model SizedSentinel.
end note
]
template<not-same-as<subrange> R> requires forwarding-range<R> && ConvertibleTo<iterator_t<R>, I> && ConvertibleTo<sentinel_t<R>, S> constexpr subrange(R&& r) requires (!StoreSize || SizedRange<R>);
Effects: Equivalent to:
  • If StoreSize is true, subrange{ranges::begin(r), ranges::end(r), ranges::size(r)}.
  • Otherwise, subrange{ranges::begin(r), ranges::end(r)}.
template<not-same-as<subrange> PairLike> requires pair-like-convertible-from<PairLike, const I&, const S&> constexpr operator PairLike() const;
Effects: Equivalent to: return PairLike(begin_­, end_­);