Horizon
Loading...
Searching...
No Matches
empty.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
14#ifndef RANGES_V3_VIEW_EMPTY_HPP
15#define RANGES_V3_VIEW_EMPTY_HPP
16
18
20
21#include <range/v3/detail/prologue.hpp>
22
23namespace ranges
24{
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
79} // namespace ranges
80
81#include <range/v3/detail/epilogue.hpp>
82#include <range/v3/detail/satisfy_boost_range.hpp>
83RANGES_SATISFY_BOOST_RANGE(::ranges::empty_view)
84
85#endif
Definition empty.hpp:29
Definition interface.hpp:129