OpenKalman
tuple_like.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) 2021-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_TUPLE_LIKE_HPP
17 #define OPENKALMAN_COLLECTIONS_TUPLE_LIKE_HPP
18 
19 #include <tuple>
21 #include "uniformly_gettable.hpp"
22 
24 {
25 #if not defined(__cpp_concepts) or __cpp_generic_lambdas < 201707L
26  namespace detail
27  {
28  template<typename T, typename = void>
29  struct is_tuple_like : std::false_type {};
30 
31  template<typename T>
32  struct is_tuple_like<T, std::void_t<decltype(std::tuple_size<T>::value)>> : std::true_type {};
33 
34  } // namespace detail
35 #endif
36 
37 
43  template<typename T>
44 #if defined(__cpp_concepts) and __cpp_generic_lambdas >= 201707L
45  concept tuple_like = uniformly_gettable<T> and requires
46  {
47  typename std::tuple_size<std::decay_t<T>>;
48  std::tuple_size<std::decay_t<T>>::value;
49  };
50 #else
51  constexpr bool tuple_like = uniformly_gettable<T> and detail::is_tuple_like<std::decay_t<T>>::value;
52 #endif
53 
54 
55 } // namespace OpenKalman::collections
56 
57 #endif //OPENKALMAN_COLLECTIONS_TUPLE_LIKE_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 relating to the availability of c++ language features.
Definition for collections::uniformly_gettable.
constexpr bool tuple_like
T is a non-empty tuple, pair, array, or other type that acts like a tuple.
Definition: tuple_like.hpp:51