Debian Codegraph @

3rd_party/range-v3/range/v3/view/empty.hpp

raw
1 /// \file
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
14 #ifndef RANGES_V3_VIEW_EMPTY_HPP
15 #define RANGES_V3_VIEW_EMPTY_HPP
16
17 #include <range/v3/range_fwd.hpp>
18
19 #include <range/v3/view/interface.hpp>
20
21 #include <range/v3/detail/prologue.hpp>
22
23 namespace ranges
24 {
25 /// \addtogroup group-views
26 /// @{
27 template<typename T>
28 struct empty_view : view_interface<empty_view<T>, (cardinality)0>
29 {
30 static_assert(std::is_object<T>::value,
31 "The template parameter to empty_view must be an object type.");
32 empty_view() = default;
33 static constexpr T * begin() noexcept
34 {
35 return nullptr;
36 }
37 static constexpr T * end() noexcept
38 {
39 return nullptr;
40 }
41 static constexpr std::size_t size() noexcept
42 {
43 return 0u;
44 }
45 static constexpr T * data() noexcept
46 {
47 return nullptr;
48 }
49 RANGES_DEPRECATED(
50 "Replace views::empty<T>() with views::empty<T>. "
51 "It is now a variable template.")
52 empty_view operator()() const
53 {
54 return *this;
55 }
56 };
57
58 template<typename T>
59 RANGES_INLINE_VAR constexpr bool enable_borrowed_range<empty_view<T>> = true;
60
61 namespace views
62 {
63 template<typename T>
64 RANGES_INLINE_VAR constexpr empty_view<T> empty{};
65 }
66
67 namespace cpp20
68 {
69 namespace views
70 {
71 using ranges::views::empty;
72 }
73 template(typename T)(
74 requires std::is_object<T>::value) //
75 using empty_view = ranges::empty_view<T>;
76 } // namespace cpp20
77
78 /// @}
79 } // namespace ranges
80
81 #include <range/v3/detail/epilogue.hpp>
82 #include <range/v3/detail/satisfy_boost_range.hpp>
83 RANGES_SATISFY_BOOST_RANGE(::ranges::empty_view)
84
85 #endif