OpenKalman
get.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 
16 #ifndef OPENKALMAN_COLLECTIONS_GET_HPP
17 #define OPENKALMAN_COLLECTIONS_GET_HPP
18 
20 
22 {
23  namespace detail_get
24  {
25  template<std::size_t i>
26  struct get_impl
27  {
28 #ifdef __cpp_concepts
29  template<typename Arg> requires
30  requires { get_element(std::declval<Arg>(), std::integral_constant<std::size_t, i>{}); }
31 #else
32  template<typename Arg, typename = std::void_t<decltype(get_element(std::declval<Arg>(), std::integral_constant<std::size_t, i>{}))>>
33 #endif
34  constexpr decltype(auto)
35  operator() [[nodiscard]] (Arg&& arg) const
36  {
37  return get_element(std::forward<Arg>(arg), std::integral_constant<std::size_t, i>{});
38  }
39  };
40 
41  }
42 
43 
48  template<std::size_t i>
49  inline constexpr detail_get::get_impl<i>
50  get;
51 
52 
53 }
54 
55 #endif
Namespace for collections.
Definition: collections.hpp:27
Definition for collections::get_element.
decltype(auto) constexpr get_element(Arg &&arg, I i)
A generalization of std::get and the range subscript operator.
Definition: get_element.hpp:122