23 Ranges library [ranges]

23.6 Range utilities [range.utility]

23.6.3 Sub-ranges [range.subrange] Constructors and conversions [range.subrange.ctor]

constexpr subrange(I i, S s) requires (!StoreSize);
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: n == ranges::distance(i, s).
Effects: Initializes begin_­ with i and end_­ with s.
If StoreSize is true, initializes size_­ with n.
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_­);