OpenKalman
apply.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_APPLY_HPP
17 #define OPENKALMAN_COLLECTIONS_APPLY_HPP
18 
19 #include "values/values.hpp"
23 
25 {
26  namespace detail
27  {
28  template<typename F, typename T, std::size_t...i>
29  constexpr decltype(auto)
30  apply_impl(F&& f, T&& t, std::index_sequence<i...>)
31  {
32  return stdex::invoke(std::forward<F>(f), get<i>(std::forward<T>(t))...);
33  }
34  }
35 
36 
41 #ifdef __cpp_concepts
42  template<typename F, collection T>
43  requires values::fixed_value_compares_with<size_of<T>, stdex::dynamic_extent, &std::is_neq>
44 #else
45  template<typename F, typename T, std::enable_if_t<
46  collection<T> and values::fixed_value_compares_with<size_of<T>, stdex::dynamic_extent, &stdex::is_neq>, int> = 0>
47 #endif
48  constexpr decltype(auto)
49  apply(F&& f, T&& t)
50  {
51  return detail::apply_impl(std::forward<F>(f), std::forward<T>(t), std::make_index_sequence<size_of_v<T>>{});
52  }
53 
54 
55 }
56 
57 #endif
Namespace for collections.
Definition: collections.hpp:27
Definition for collections::get.
Definition for collections::collection.
Header file for code relating to values (e.g., scalars and indices)
Definition for collections::size_of.
decltype(auto) constexpr apply(F &&f, T &&t)
A generalization of std::apply.
Definition: apply.hpp:49