24 Ranges library [ranges]

24.7 Range adaptors [range.adaptors]

24.7.14 Reverse view [range.reverse]

24.7.14.2 Class template reverse_­view [range.reverse.view]

namespace std::ranges {
  template<view V>
    requires bidirectional_range<V>
  class reverse_view : public view_interface<reverse_view<V>> {
  private:
    V base_ = V();  // exposition only
  public:
    reverse_view() = default;

    constexpr explicit reverse_view(V r);

    template<viewable_range R>
      requires bidirectional_range<R> && constructible_from<V, all_view<R>>
    constexpr explicit reverse_view(R&& r);

    constexpr V base() const;

    constexpr reverse_iterator<iterator_t<V>> begin();
    constexpr reverse_iterator<iterator_t<V>> begin() requires common_range<V>;
    constexpr reverse_iterator<iterator_t<const V>> begin() const
      requires common_range<const V>;

    constexpr reverse_iterator<iterator_t<V>> end();
    constexpr reverse_iterator<iterator_t<const V>> end() const
      requires common_range<const V>;

    constexpr auto size() requires sized_range<V> {
      return ranges::size(base_);
    }
    constexpr auto size() const requires sized_range<const V> {
      return ranges::size(base_);
    }
  };

  template<class R>
    reverse_view(R&&) -> reverse_view<all_view<R>>;
}
constexpr explicit reverse_view(V base);
Effects: Initializes base_­ with std​::​move(base).
template<viewable_range R> requires bidirectional_range<R> && constructible_from<V, all_view<R>> constexpr explicit reverse_view(R&& r);
Effects: Initializes base_­ with views​::​all(std​::​forward<R>(r)).
constexpr V base() const;
Effects: Equivalent to: return base_­;
constexpr reverse_iterator<iterator_t<V>> begin();
Returns:
make_reverse_iterator(ranges::next(ranges::begin(base_), ranges::end(base_)))
Remarks: In order to provide the amortized constant time complexity required by the range concept, this function caches the result within the reverse_­view for use on subsequent calls.
constexpr reverse_iterator<iterator_t<V>> begin() requires common_range<V>; constexpr reverse_iterator<iterator_t<const V>> begin() const requires common_range<const V>;
Effects: Equivalent to: return make_­reverse_­iterator(ranges​::​end(base_­));
constexpr reverse_iterator<iterator_t<V>> end(); constexpr reverse_iterator<iterator_t<const V>> end() const requires common_range<const V>;
Effects: Equivalent to: return make_­reverse_­iterator(ranges​::​begin(base_­));