OpenKalman
concat.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-2026 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_PATTERNS_VIEWS_CONCAT_HPP
17 #define OPENKALMAN_PATTERNS_VIEWS_CONCAT_HPP
18 
23 
25 {
26  namespace detail
27  {
29  {
30  private:
31 
32  struct Op
33  {
34  template<typename...Xs>
35  constexpr auto operator()(Xs...xs) const { return (0 + ... + xs); }
36  };
37 
38  public:
39 
40  #ifdef __cpp_concepts
41  template<pattern...P>
42  #else
43  template<typename...P, std::enable_if_t<(... and pattern<P>), int> = 0>
44  #endif
45  constexpr auto
46  operator() (P&&...p) const
47  {
48  if constexpr ((... and euclidean_pattern<P>))
49  return Dimensions {values::operation(Op{}, get_dimension(p)...)};
50  else if constexpr ((... and descriptor<P>))
51  return std::make_tuple(std::forward<P>(p)...) | collections::views::all;
52  else
53  return collections::views::concat([](P&& p) {
54  if constexpr (descriptor<P>) return std::array {std::forward<P>(p)};
55  else return std::forward<P>(p);
56  }(std::forward<P>(p))...);
57  }
58  };
59 
60  }
61 
62 
66  inline constexpr detail::concat_adaptor concat;
67 
68 }
69 
70 
71 #endif
Definition for patterns::euclidean_pattern.
constexpr detail::concat_adaptor concat
a std::ranges::range_adaptor_closure for a set of concatenated collection objects.
Definition: concat.hpp:209
constexpr bool pattern
An object describing the characteristics (e.g., dimensions, wrapping structure) of an index...
Definition: pattern.hpp:31
The namespace for views for patterns::pattern object.
Definition: patterns.hpp:51
A structure representing the dimensions associated with of a particular index.
Definition: Dimensions.hpp:42
Definition for patterns::pattern.
constexpr detail::all_closure all
a std::ranges::range_adaptor_closure which returns a view to all members of its collection argument...
Definition: all.hpp:70
Inclusion file for collections.
constexpr detail::concat_adaptor concat
a std::ranges::range_adaptor_closure for a set of concatenated pattern objects.
Definition: concat.hpp:66
Definition for patterns::get_dimension.
constexpr auto get_dimension(const Arg &arg)
Get the vector dimension of patterns::pattern Arg.
Definition: get_dimension.hpp:53
constexpr auto operation(Operation &&op, Args &&...args)
A potentially constant-evaluated operation involving some number of values.
Definition: operation.hpp:98