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 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 decltype(auto)
38 #endif
39  operator() (R&& r) const
40  {
41  if constexpr (
42  collection_view<R> and
43  (not values::fixed_value_compares_with<size_of<R>, stdex::dynamic_extent, &stdex::is_neq> or
44  collections::tuple_like<R>))
45  {
46  return std::forward<R>(r);
47  }
48  else if constexpr (stdex::ranges::random_access_range<R> and stdex::ranges::viewable_range<R>)
49  {
50  return from_range {std::forward<R>(r)};
51  }
52  else //if constexpr (viewable_tuple_like<R>)
53  {
54  return from_tuple_like {std::forward<R>(r)};
55  }
56  }
57  };
58  }
59 
60 
72  inline constexpr detail::all_closure all;
73 
74 
79 #ifdef __cpp_concepts
80  template<viewable_collection R>
81 #else
82  template<typename R, std::enable_if_t<viewable_collection<R>, int> = 0>
83 #endif
84  using all_t = decltype(all(std::declval<R>()));
85 
86 }
87 
88 
89 #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:72
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:84
Basic definitions for OpenKalman as a whole.
Definition for collections::from_tuple_like.