OpenKalman
sized.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) 2024-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 
16 #ifndef OPENKALMAN_COLLECTIONS_SIZED_HPP
17 #define OPENKALMAN_COLLECTIONS_SIZED_HPP
18 
19 #include <type_traits>
20 #ifdef __cpp_lib_ranges
21 #include <ranges>
22 #else
24 #endif
25 
27 {
31 #ifdef __cpp_lib_ranges
32  template<typename T>
33  concept sized = std::ranges::sized_range<T> or requires { std::tuple_size<std::decay_t<T>>::value; };
34 #else
35  namespace detail_sized
36  {
37  template<typename T, typename = void>
38  struct has_tuple_size : std::false_type {};
39 
40  template<typename T>
41  struct has_tuple_size<T, std::void_t<decltype(std::tuple_size<std::decay_t<T>>::value)>> : std::true_type {};
42 
43  using namespace std;
44 
45  template<typename T>
46  constexpr bool sized = ranges::sized_range<remove_cvref_t<T>> or has_tuple_size<T>::value;
47  }
48 
49 
50  using detail_sized::sized;
51 #endif
52 
53 } // OpenKalman::collections
54 
55 #endif //OPENKALMAN_COLLECTIONS_SIZED_HPP
Namespace for collections.
Definition: collections.hpp:27
Definition: tuple_reverse.hpp:103
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
Definitions implementing features of the c++ ranges library for compatibility.