OpenKalman
copyable_from.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_COPYABLE_FROM_HPP
18 #define OPENKALMAN_COPYABLE_FROM_HPP
19 
20 #include "basics/basics.hpp"
24 
25 namespace OpenKalman
26 {
27 #ifndef __cpp_concepts
28  namespace detail
29  {
30  template<typename To, typename From, typename = void>
31  struct is_element_copyable : std::false_type {};
32 
33  template<typename To, typename From>
34  struct is_element_copyable<To, From, std::enable_if_t<
35  stdex::assignable_from<typename std::decay_t<decltype(get_mdspan(std::declval<To>()))>::reference, typename element_type_of<From>::type>>>
36  : std::true_type {};
37  }
38 #endif
39 
40 
46  template<typename Dest, typename Source>
47 #ifdef __cpp_lib_concepts
48  concept copyable_from =
49  patterns_may_match_with<Dest, Source> and
50  std::assignable_from<typename std::decay_t<decltype(get_mdspan(std::declval<Dest>()))>::reference, element_type_of_t<Source>>;
51 #else
52  constexpr bool copyable_from =
53  patterns_may_match_with<Dest, Source> and
55 #endif
56 
57 
58 }
59 
60 #endif
Definition for patterns_may_match_with.
Definition for element_type_of.
The root namespace for OpenKalman.
Definition: basics.hpp:34
Definition of get_mdspan function.
Basic definitions for OpenKalman as a whole.
constexpr bool copyable_from
Specifies that an indexible object is copyable from another indexible object.
Definition: copyable_from.hpp:52
typename element_type_of< T >::type element_type_of_t
helper template for element_type_of.
Definition: element_type_of.hpp:54
Definition: copyable_from.hpp:31