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 #ifndef __cpp_lib_ranges
21 
22 #include "view-concepts.hpp"
23 #include "view_interface.hpp"
24 
25 namespace OpenKalman::ranges
26 {
31  template<typename T>
32  struct empty_view : ranges::view_interface<empty_view<T>>
33  {
34  static constexpr T* begin() noexcept { return nullptr; }
35 
36  static constexpr T* end() noexcept { return nullptr; }
37 
38  static constexpr T* data() noexcept { return nullptr; }
39 
40  static constexpr std::size_t size() noexcept { return 0; }
41 
42  static constexpr bool empty() noexcept { return true; }
43  };
44 
45 
46  template<typename T>
47  constexpr bool enable_borrowed_range<OpenKalman::ranges::empty_view<T>> = true;
48 
49 }
50 
51 
53 {
57  template<class T>
58  constexpr empty_view<T> empty{};
59 
60 }
61 
62 
63 #endif
64 
65 #endif //OPENKALMAN_COMPATIBILITY_VIEWS_EMPTY_HPP
Definition: view_interface.hpp:32
Definition: range-access.hpp:25
Definition: all.hpp:35
Equivalent to std::ranges::single_view.
Definition: empty.hpp:32