OpenKalman
empty.hpp
Go to the documentation of this file.
1 /* This file is part of OpenKalman, a header-only C++ library for
2  * Kalman filters and other recursive filters.
3  *
4  * Copyright (c) 2025 Christopher Lee Ogden <ogden@gatech.edu>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
9  */
10 
17 #ifndef OPENKALMAN_COMPATIBILITY_VIEWS_EMPTY_HPP
18 #define OPENKALMAN_COMPATIBILITY_VIEWS_EMPTY_HPP
19 
20 #include "view-concepts.hpp"
21 #include "view_interface.hpp"
22 
24 {
25 #ifdef __cpp_lib_ranges
26  using std::ranges::empty_view;
27  namespace views
28  {
29  using std::ranges::views::empty;
30  }
31 #else
32 
36  template<typename T>
37  struct empty_view : stdex::ranges::view_interface<empty_view<T>>
38  {
39  static constexpr T* begin() noexcept { return nullptr; }
40 
41  static constexpr T* end() noexcept { return nullptr; }
42 
43  static constexpr T* data() noexcept { return nullptr; }
44 
45  static constexpr std::size_t size() noexcept { return 0; }
46 
47  static constexpr bool empty() noexcept { return true; }
48  };
49 
50 
51  template<typename T>
52  constexpr bool enable_borrowed_range<empty_view<T>> = true;
53 
54 
55  namespace views
56  {
60  template<class T>
61  constexpr empty_view<T> empty{};
62  }
63 
64 #endif
65 }
66 
67 #endif
Definition: view_interface.hpp:32
Equivalent to std::ranges::empty_view.
Definition: empty.hpp:37
Definition: common.hpp:200
constexpr bool size
T is either an index representing a size, or unbounded_size_t, which indicates that the size is unbou...
Definition: size.hpp:65