[range.all]

# 25 Ranges library [[ranges]](./#ranges)

## 25.7 Range adaptors [[range.adaptors]](range.adaptors#range.all)

### 25.7.6 All view [range.all]

#### [25.7.6.1](#general) General [[range.all.general]](range.all.general)

[1](#general-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L4494)

views​::​all returns a view that includes all elements of
its range argument[.](#general-1.sentence-1)

[2](#general-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L4499)

The name views​::​all denotes a
range adaptor object ([[range.adaptor.object]](range.adaptor.object "25.7.2 Range adaptor objects"))[.](#general-2.sentence-1)

Given a subexpression E, the expressionviews​::​all(E) is expression-equivalent to:

- [(2.1)](#general-2.1)

  *decay-copy*(E) if the decayed type of E models [view](range.view#concept:view "25.4.5 Views [range.view]")[.](#general-2.1.sentence-1)

- [(2.2)](#general-2.2)

  Otherwise, ref_view{E} if that expression is well-formed[.](#general-2.2.sentence-1)

- [(2.3)](#general-2.3)

  Otherwise, owning_view{E}[.](#general-2.3.sentence-1)

#### [25.7.6.2](#range.ref.view) Class template ref_view [[range.ref.view]](range.ref.view)

[1](#range.ref.view-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L4515)

ref_view is a view of the elements of some other range[.](#range.ref.view-1.sentence-1)

[ð](#lib:ref_view)

namespace std::ranges {template<[range](range.range#concept:range "25.4.2 Ranges [range.range]") R>requires is_object_v<R>class ref_view : public view_interface<ref_view<R>> {private: R* *r_*; // *exposition only*public:template<[*different-from*](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]")<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() constrequires requires { ranges::empty(**r_*); }{ return ranges::empty(**r_*); }constexpr auto size() const requires [sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")<R>{ return ranges::size(**r_*); }constexpr auto reserve_hint() const requires [approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3 Approximately sized ranges [range.approximately.sized]")<R>{ return ranges::reserve_hint(**r_*); }constexpr auto data() const requires [contiguous_range](range.refinements#concept:contiguous_range "25.4.6 Other range refinements [range.refinements]")<R>{ return ranges::data(**r_*); }}; template<class R> ref_view(R&) -> ref_view<R>;}

[ð](#lib:ref_view,constructor)

`template<[different-from](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]")<ref_view> T>
  requires see below
constexpr ref_view(T&& t);
`

[2](#range.ref.view-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L4563)

*Effects*: Initializes *r_* withaddressof(static_cast<R&>(std​::​forward<T>(t)))[.](#range.ref.view-2.sentence-1)

[3](#range.ref.view-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L4568)

*Remarks*: Let *FUN* denote the exposition-only functionsvoid *FUN*(R&);void *FUN*(R&&) = delete;

The expression in the [*requires-clause*](temp.pre#nt:requires-clause "13.1 Preamble [temp.pre]") is equivalent to:[convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")<T, R&> && requires { *FUN*(declval<T>()); }

#### [25.7.6.3](#range.owning.view) Class template owning_view [[range.owning.view]](range.owning.view)

[1](#range.owning.view-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L4583)

owning_view is a move-only view
of the elements of some other range[.](#range.owning.view-1.sentence-1)

[ð](#lib:owning_view)

namespace std::ranges {template<[range](range.range#concept:range "25.4.2 Ranges [range.range]") R>requires [movable](concepts.object#concept:movable "18.6 Object concepts [concepts.object]")<R> && (!*is-initializer-list*<R>) // see [[range.refinements]](range.refinements "25.4.6 Other range refinements")class owning_view : public view_interface<owning_view<R>> {private: R *r_* = R(); // *exposition only*public: owning_view() requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12 Concept default_­initializable [concept.default.init]")<R> = default; constexpr owning_view(R&& t);

 owning_view(owning_view&&) = default;
 owning_view& operator=(owning_view&&) = default; constexpr R& base() & noexcept { return *r_*; }constexpr const R& base() const & noexcept { return *r_*; }constexpr R&& base() && noexcept { return std::move(*r_*); }constexpr const R&& base() const && noexcept { return std::move(*r_*); }constexpr iterator_t<R> begin() { return ranges::begin(*r_*); }constexpr sentinel_t<R> end() { return ranges::end(*r_*); }constexpr auto begin() const requires [range](range.range#concept:range "25.4.2 Ranges [range.range]")<const R>{ return ranges::begin(*r_*); }constexpr auto end() const requires [range](range.range#concept:range "25.4.2 Ranges [range.range]")<const R>{ return ranges::end(*r_*); }constexpr bool empty() requires requires { ranges::empty(*r_*); }{ return ranges::empty(*r_*); }constexpr bool empty() const requires requires { ranges::empty(*r_*); }{ return ranges::empty(*r_*); }constexpr auto size() requires [sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")<R>{ return ranges::size(*r_*); }constexpr auto size() const requires [sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]")<const R>{ return ranges::size(*r_*); }constexpr auto reserve_hint() requires [approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3 Approximately sized ranges [range.approximately.sized]")<R>{ return ranges::reserve_hint(*r_*); }constexpr auto reserve_hint() const requires [approximately_sized_range](range.approximately.sized#concept:approximately_sized_range "25.4.3 Approximately sized ranges [range.approximately.sized]")<const R>{ return ranges::reserve_hint(*r_*); }constexpr auto data() requires [contiguous_range](range.refinements#concept:contiguous_range "25.4.6 Other range refinements [range.refinements]")<R>{ return ranges::data(*r_*); }constexpr auto data() const requires [contiguous_range](range.refinements#concept:contiguous_range "25.4.6 Other range refinements [range.refinements]")<const R>{ return ranges::data(*r_*); }};}

[ð](#lib:owning_view,constructor)

`constexpr owning_view(R&& t);
`

[2](#range.owning.view-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L4645)

*Effects*: Initializes *r_* with std​::​move(t)[.](#range.owning.view-2.sentence-1)
