23 Ranges library [ranges]

23.7 Range adaptors [range.adaptors]

23.7.3 All view [range.all]

view::all returns a View that includes all elements of its Range argument.
The name view::all denotes a range adaptor object.
For some subexpression E, the expression view::all(E) is expression-equivalent to:
  • DECAY_­COPY(E) if the decayed type of E models View.
  • Otherwise, ref-view{E} if that expression is well-formed, where ref-view is the exposition-only View specified below.
  • Otherwise, subrange{E}. ref-view [range.view.ref]

namespace std::ranges {
  template<Range R>
    requires is_object_v<R>
  class ref-view : public view_interface<ref-view<R>> {
    R* r_ = nullptr;            // exposition only
    constexpr ref-view() noexcept = default;

    template<not-same-as<ref-view> T>
      requires see below
    constexpr ref-view(T&& t);

    constexpr R& base() const { return *r_; }

    constexpr iterator_t<R> begin() const { return ranges::begin(*r_); }
    constexpr sentinel_t<R> end() const { return ranges::end(*r_); }

    constexpr bool empty() const
      requires requires { ranges::empty(*r_); }
    { return ranges::empty(*r_); }

    constexpr auto size() const requires SizedRange<R>
    { return ranges::size(*r_); }

    constexpr auto data() const requires ContiguousRange<R>
    { return ranges::data(*r_); }

    friend constexpr iterator_t<R> begin(ref-view r)
    { return r.begin(); }

    friend constexpr sentinel_t<R> end(ref-view r)
    { return r.end(); }
template<not-same-as<ref-view> T> requires see below constexpr ref-view(T&& t);
Remarks: Let FUN denote the exposition-only functions
void FUN(R&);
void FUN(R&&) = delete;
The expression in the requires-clause is equivalent to
ConvertibleTo<T, R&> && requires { FUN(declval<T>()); }
Effects: Initializes r_­ with addressof(static_­cast<R&>(std::forward<T>(t))).