24 Ranges library [ranges]

24.5 Range utilities [range.utility]

24.5.3 Sub-ranges [range.subrange]

24.5.3.2 Accessors [range.subrange.access]

constexpr I begin() const;
Effects: Equivalent to: return begin_­;
constexpr S end() const;
Effects: Equivalent to: return end_­;
constexpr bool empty() const;
Effects: Equivalent to: return begin_­ == end_­;
constexpr make-unsigned-like-t(iter_difference_t<I>) size() const requires (K == subrange_kind::sized);
Effects:
  • If StoreSize is true, equivalent to: return size_­;
  • Otherwise, equivalent to: return make-unsigned-like-t(end_­ - begin_­);
[[nodiscard]] constexpr subrange next(iter_difference_t<I> n = 1) const;
Effects: Equivalent to:
auto tmp = *this;
tmp.advance(n);
return tmp;
Note
:
If I does not model forward_­iterator, next can invalidate *this.
— end note
 ]
[[nodiscard]] constexpr subrange prev(iter_difference_t<I> n = 1) const requires bidirectional_iterator<I>;
Effects: Equivalent to:
auto tmp = *this;
tmp.advance(-n);
return tmp;
constexpr subrange& advance(iter_difference_t<I> n);
Effects: Equivalent to:
  • If StoreSize is true,
    auto d = n - ranges::advance(begin_, n, end_);
    if (d >= 0)
      size_ -= make-unsigned-like(d);
    else
      size_ += make-unsigned-like(-d);
    return *this;
    
  • Otherwise,
    ranges::advance(begin_, n, end_);
    return *this;
    
template<size_t N, class I, class S, subrange_kind K> requires (N < 2) constexpr auto get(const subrange<I, S, K>& r);
Effects: Equivalent to:
if constexpr (N == 0)
  return r.begin();
else
  return r.end();