OpenKalman
view-concepts.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_COMPATIBILITY_VIEWS_VIEW_CONCEPTS_HPP
18 #define OPENKALMAN_COMPATIBILITY_VIEWS_VIEW_CONCEPTS_HPP
19 
23 #include "view_interface.hpp"
24 
25 
27 {
28 #ifdef __cpp_lib_ranges
29  using std::ranges::view_base;
30  using std::ranges::enable_view;
31  using std::ranges::view;
32  using std::ranges::viewable_range;
33 #else
34  // ---
35  // view, enable_view, view_base
36  // ---
37 
38  struct view_base {};
39 
40  namespace detail
41  {
42  template<typename T, typename U, std::enable_if_t<not std::is_same_v<T, view_interface<U>>, int> = 0>
43  void is_derived_from_view_interface_test(const T&, const view_interface<U>&); // no need to define
44 
45 
46  template<typename T, typename = void>
47  struct is_derived_from_view_interface : std::false_type {};
48 
49  template<typename T>
51  std::void_t<decltype(is_derived_from_view_interface_test(std::declval<T>(), std::declval<T>()))>> : std::true_type {};
52  }
53 
54 
55  template<class T>
56  inline constexpr bool
57  enable_view =
58  (std::is_base_of_v<view_base, T> and stdex::convertible_to<const volatile T&, const volatile view_base&>) or
60 
61 
62  template<typename T>
63  inline constexpr bool
64  view = range<T> and stdex::movable<T> and enable_view<T>;
65 
66 
67  // ---
68  // viewable_range
69  // ---
70 
71  template<typename T>
72  constexpr bool
73  viewable_range = stdex::ranges::range<T> and
74  ((view<stdex::remove_cvref_t<T>> and stdex::constructible_from<stdex::remove_cvref_t<T>, T>) or
75  (not view<remove_cvref_t<T>> and
76  (std::is_lvalue_reference_v<T> or
77  (stdex::movable<std::remove_reference_t<T>> and not OpenKalman::internal::is_initializer_list<stdex::remove_cvref_t<T>>::value))));
78 
79 #endif
80 }
81 
82 #endif
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45
Definition: view_interface.hpp:32
Exposition-only definitions from teh c++ language standard.
Definitions relating to the availability of c++ language features.
Definition: view-concepts.hpp:38
Definition: common.hpp:200
Whether the argument is a specialization of std::initializer_list.
Definition: exposition.hpp:76
Global definitions for OpenKalman.