Horizon
Loading...
Searching...
No Matches
all.hpp
Go to the documentation of this file.
1
2// Range v3 library
3//
4// Copyright Eric Niebler 2014-present
5//
6// Use, modification and distribution is subject to the
7// Boost Software License, Version 1.0. (See accompanying
8// file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt)
10//
11// Project home: https://github.com/ericniebler/range-v3
12//
13#ifndef RANGES_V3_VIEW_ALL_HPP
14#define RANGES_V3_VIEW_ALL_HPP
15
16#include <type_traits>
17
18#include <meta/meta.hpp>
19
21
25#include <range/v3/utility/static_const.hpp>
26#include <range/v3/view/ref.hpp>
29
30#include <range/v3/detail/prologue.hpp>
31
32namespace ranges
33{
36 namespace views
37 {
38 struct all_fn
39 {
40 private:
42 template<typename T>
43 static constexpr auto from_range_(T && t, std::true_type, detail::ignore_t,
44 detail::ignore_t)
45 {
46 return static_cast<T &&>(t);
47 }
48
51 template<typename T>
52 static constexpr auto from_range_(T && t, std::false_type, std::true_type,
53 detail::ignore_t)
54 {
55 return ranges::views::ref(t);
56 }
57
60 template<typename T>
61 static constexpr auto from_range_(T && t, std::false_type, std::false_type,
62 std::true_type)
63 {
64 return make_subrange(static_cast<T &&>(t));
65 }
66
67 public:
68 template(typename T)(
69 requires range<T &> AND viewable_range<T>)
70 constexpr auto operator()(T && t) const
71 {
72 return all_fn::from_range_(static_cast<T &&>(t),
73 meta::bool_<view_<uncvref_t<T>>>{},
74 std::is_lvalue_reference<T>{},
76 }
77
78 template<typename T>
79 RANGES_DEPRECATED("Passing a reference_wrapper to views::all is deprecated.")
80 constexpr ref_view<T> operator()(std::reference_wrapper<T> r) const
81 {
82 return ranges::views::ref(r.get());
83 }
84 };
85
88 RANGES_INLINE_VARIABLE(view_closure<all_fn>, all)
89
90 template<typename Rng>
91 using all_t = decltype(all(std::declval<Rng>()));
92 } // namespace views
93
94 template<typename Rng>
95 struct identity_adaptor : Rng
96 {
97 CPP_assert(view_<Rng>);
98
99 identity_adaptor() = default;
100 constexpr explicit identity_adaptor(Rng const & rng)
101 : Rng(rng)
102 {}
103 constexpr explicit identity_adaptor(Rng && rng)
104 : Rng(detail::move(rng))
105 {}
106 };
107
108 namespace cpp20
109 {
110 namespace views
111 {
112 using ranges::views::all;
113 using ranges::views::all_t;
114 }
115 template(typename Rng)(
116 requires viewable_range<Rng>)
117 using all_view RANGES_DEPRECATED(
118 "Please use ranges::cpp20::views::all_t instead.") =
119 ranges::views::all_t<Rng>;
120 } // namespace cpp20
122} // namespace ranges
123
124#include <range/v3/detail/epilogue.hpp>
125
126#endif
The range concept.
The view_ concept.
The viewable_range concept.
std::integral_constant< bool, B > bool_
An integral constant wrapper for bool.
Definition meta.hpp:168
Tiny meta-programming library.
Definition all.hpp:96
Definition ref.hpp:41
Definition all.hpp:39
Definition view.hpp:178