OpenKalman
all.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 
17 #ifndef OPENKALMAN_COLLECTIONS_VIEWS_ALL_HPP
18 #define OPENKALMAN_COLLECTIONS_VIEWS_ALL_HPP
19 
20 #include "basics/basics.hpp"
22 #include "from_tuple_like.hpp"
23 #include "from_range.hpp"
25 
27 {
28  namespace detail
29  {
31  {
32 #ifdef __cpp_concepts
33  template<viewable_collection R>
34  constexpr collection_view auto
35 #else
36  template<typename R, std::enable_if_t<viewable_collection<R>, int> = 0>
37  constexpr auto
38 #endif
39  operator() (R&& r) const
40  {
41  if constexpr (collection_view<R> and (collections::tuple_like<R> or
42  (uniformly_gettable<R> and not values::fixed_value_compares_with<size_of<R>, stdex::dynamic_extent, &stdex::is_neq>)))
43  {
44  return std::forward<R>(r);
45  }
46  else if constexpr (stdex::ranges::random_access_range<R> and stdex::ranges::viewable_range<R>)
47  {
48  return from_range {std::forward<R>(r)};
49  }
50  else //if constexpr (viewable_tuple_like<R>)
51  {
52  return from_tuple_like {std::forward<R>(r)};
53  }
54  }
55  };
56  }
57 
58 
70  inline constexpr detail::all_closure all;
71 
72 
77 #ifdef __cpp_concepts
78  template<viewable_collection R>
79 #else
80  template<typename R, std::enable_if_t<viewable_collection<R>, int> = 0>
81 #endif
82  using all_t = decltype(all(std::declval<R>()));
83 
84 }
85 
86 
87 #endif
Definition for collections::tuple_like.
A collection_view created from a std::ranges::random_access_range that is a std::ranges::viewable_ran...
Definition: from_range.hpp:122
The size of a sized object (including a collection).
Definition: size_of.hpp:33
A collection_view created from a viewable_tuple_like object.
Definition: from_tuple_like.hpp:74
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
Definition for collections::from_range.
constexpr bool collection_view
A view to a collection which is also a std::ranges:view.
Definition: collection_view.hpp:31
Namespace for generalized views.
Definition: collections.hpp:33
Definition: range_adaptor_closure.hpp:34
constexpr bool fixed_value_compares_with
T has a fixed value that compares with N in a particular way based on parameter comp.
Definition: fixed_value_compares_with.hpp:74
Definition for collections::viewable_collection.
decltype(all(std::declval< R >())) all_t
Calculates the suitable collection_view type of a viewable_collection type.
Definition: all.hpp:82
Basic definitions for OpenKalman as a whole.
Definition for collections::from_tuple_like.