Horizon
dangling.hpp
Go to the documentation of this file.
1 // Range v3 library
3 //
4 // Copyright Eric Niebler 2013-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 
14 #ifndef RANGES_V3_RANGE_DANGLING_HPP
15 #define RANGES_V3_RANGE_DANGLING_HPP
16 
17 #include <utility>
18 
19 #include <concepts/concepts.hpp>
20 
21 #include <range/v3/range_fwd.hpp>
22 
25 #include <range/v3/utility/static_const.hpp>
26 
27 #include <range/v3/detail/prologue.hpp>
28 
29 namespace ranges
30 {
34  struct dangling
35  {
36  dangling() = default;
38  template(typename T)(
39  requires not_same_as_<T, dangling>)
40  constexpr dangling(T &&)
41  {}
42  };
43 
45  namespace detail
46  {
47  template(class R, class U)(
48  requires range<R>)
49  using maybe_dangling_ = //
51  }
53 
54  template<typename Rng>
55  using borrowed_iterator_t = detail::maybe_dangling_<Rng, iterator_t<Rng>>;
56 
57  template<typename Rng>
58  using safe_iterator_t RANGES_DEPRECATED(
59  "Please use ranges::borrowed_iterator_t instead.") = borrowed_iterator_t<Rng>;
60 
62  struct _sanitize_fn
63  {
64  template<typename T>
65  constexpr T && operator()(T && t) const noexcept
66  {
67  return static_cast<T &&>(t);
68  }
69  };
70 
71  using sanitize_fn RANGES_DEPRECATED(
72  "The sanitize function is unneeded and deprecated.") = _sanitize_fn;
73 
74  namespace
75  {
76  RANGES_DEPRECATED("The sanitize function is unneeded and deprecated.")
77  constexpr auto & sanitize = static_const<_sanitize_fn>::value;
78  } // namespace
80 
81  namespace cpp20
82  {
83  using ranges::dangling;
84  using ranges::borrowed_iterator_t;
85 
86  template<typename Rng>
87  using safe_iterator_t RANGES_DEPRECATED(
88  "Please use ranges::borrowed_iterator_t instead.") = borrowed_iterator_t<Rng>;
89  } // namespace cpp20
90 } // namespace ranges
91 
92 #include <range/v3/detail/epilogue.hpp>
93 
94 #endif
typename detail::_cond< If >::template invoke< Then, Else > conditional_t
Select one type or another depending on a compile-time Boolean.
Definition: meta.hpp:1148
A placeholder for an iterator or a sentinel into a range that may no longer be valid.
Definition: dangling.hpp:35