OpenKalman
most_fixed_pattern.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) 2022-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_MOST_FIXED_PATTERN_HPP
18 #define OPENKALMAN_MOST_FIXED_PATTERN_HPP
19 
22 
24 {
25  namespace detail
26  {
28  {
29  template<typename D, typename...Ds>
30  constexpr decltype(auto)
31  impl(D&& d, Ds&&...ds)
32  {
33  if constexpr (sizeof...(Ds) == 0) return std::forward<D>(d);
34  else if constexpr (fixed_pattern<D>) return std::forward<D>(d);
35  else return impl(std::forward<Ds>(ds)...);
36  }
37 
38  public:
39 
40  template<typename D, typename...Ds>
41  constexpr decltype(auto)
42  operator()(D&& d, Ds&&...ds)
43  {
44  static_assert((... and compares_with<D, Ds, &stdex::is_eq, applicability::permitted>),
45  "In most_fixed_pattern, elements of pattern_collection argument are not compatible");
46  return impl(std::forward<D>(d), std::forward<Ds>(ds)...);
47  }
48  };
49  }
50 
51 
56 #ifdef __cpp_concepts
57  template<pattern_collection P> requires values::fixed_value_compares_with<collections::size_of<P>, 0, &std::is_gt>
58  constexpr pattern decltype(auto)
59 #else
60  template<typename P, std::enable_if_t<values::fixed_value_compares_with<collections::size_of<P>, 0, &stdex::is_gt>, int> = 0>
61  constexpr decltype(auto)
62 #endif
64  {
65  return collections::apply(detail::MostFixedPattern{}, std::forward<P>(p));
66  }
67 
68 
69 }
70 
71 #endif
Definition: get_descriptor_dimension.hpp:25
Definition for compares_with.
constexpr bool pattern
An object describing the set of coordinates associated with a tensor index.
Definition: pattern.hpp:31
decltype(auto) constexpr apply(F &&f, T &&t)
A generalization of std::apply.
Definition: apply.hpp:49
Inclusion file for collections.
decltype(auto) constexpr most_fixed_pattern(P &&p)
Given a fixed-size /ref coordinates::pattern_collection, return the first component, if any, that is a fixed_pattern.
Definition: most_fixed_pattern.hpp:63