VCCC  2024.05
VisualCamp Common C++ library
empty_view.hpp
Go to the documentation of this file.
1 //
2 // Created by yonggyulee on 2024/01/02.
3 //
4 
5 #ifndef VCCC_RANGES_VIEWS_EMPTY_VIEW_HPP
6 #define VCCC_RANGES_VIEWS_EMPTY_VIEW_HPP
7 
8 #include <cstddef>
9 #include <type_traits>
10 
14 
15 namespace vccc {
16 namespace ranges {
17 
30 
31 template<typename T>
32 class empty_view : public ranges::view_interface<empty_view<T>> {
33  public:
34  static_assert(std::is_object<T>::value, "Constraints not satisfied");
35 
36  static constexpr T* begin() noexcept { return nullptr; }
37 
38  static constexpr T* end() noexcept { return nullptr; }
39 
40  static constexpr T* data() noexcept { return nullptr; }
41 
42  static constexpr std::size_t size() noexcept { return 0; }
43 
44  static constexpr bool empty() noexcept { return true; }
45 };
46 
47 template<typename T>
48 struct enable_borrowed_range<empty_view<T>> : std::true_type {};
49 
50 namespace views {
51 
52 template<typename T>
54 
55 } // namespace views
56 
58 
59 } // namespace ranges
60 } // namespace vccc
61 
62 #endif // VCCC_RANGES_VIEWS_EMPTY_VIEW_HPP
Definition: empty_view.hpp:32
static constexpr T * begin() noexcept
Definition: empty_view.hpp:36
static constexpr std::size_t size() noexcept
Definition: empty_view.hpp:42
static constexpr T * data() noexcept
Definition: empty_view.hpp:40
static constexpr T * end() noexcept
Definition: empty_view.hpp:38
static constexpr bool empty() noexcept
Definition: empty_view.hpp:44
helper class template for defining a view, using the curiously recurring template pattern
Definition: view_interface.hpp:78
#define VCCC_INLINE_OR_STATIC
Definition: inline_or_static.hpp:9
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > value
Definition: key_value.hpp:35
Definition: empty.hpp:10
Definition: enable_borrowed_range.hpp:17