17 #ifndef OPENKALMAN_ADAPTERBASE_HPP 18 #define OPENKALMAN_ADAPTERBASE_HPP 20 #include "linear-algebra/traits/internal/library_base.hpp" 33 template<
typename Derived, indexible Nested, indexible LibraryObject = Nested> requires
34 (not std::is_rvalue_reference_v<Nested>)
36 template<
typename Derived,
typename Nested,
typename LibraryObject = Nested>
41 #ifndef __cpp_concepts 42 static_assert(indexible<Nested>);
43 static_assert(indexible<LibraryObject>);
44 static_assert(not std::is_rvalue_reference_v<Nested>);
58 template<
typename Arg> requires
59 (not std::is_base_of_v<Derived, std::decay_t<Arg>>) and
60 std::constructible_from<Nested, Arg&&>
62 template<
typename Arg, std::enable_if_t<
63 (not std::is_base_of_v<Derived, std::decay_t<Arg>>) and
64 stdex::constructible_from<Nested, Arg&&>,
int> = 0>
73 #ifdef __cpp_explicit_this_parameter 74 template<
typename Self>
75 constexpr decltype(
auto)
nested_object(
this Self&&
self) {
return std::forward<Self>(
self).nested_; }
83 constexpr Nested&&
nested_object() && {
return std::move(*this).nested_; }
86 constexpr
const Nested&&
nested_object() const && {
return std::move(*this).nested_; }
93 #ifdef __cpp_explicit_this_parameter 94 template<
typename Self,
typename...I> requires
95 requires(Self&& s, I&&...i) {
access(std::forward<Self>(s), std::forward<I>(i)...); }
97 operator[](this Self&& self, I&&...i)
99 return access(std::forward<Self>(
self), std::forward<I>(i)...);
102 template<
typename...I, std::enable_if_t<
103 values::value<decltype(access(std::declval<Derived&>(), std::declval<I>()...))>,
int> = 0>
106 return access(static_cast<Derived&>(*
this), std::forward<I>(i)...);
110 template<
typename...I, std::enable_if_t<
111 values::value<decltype(access(std::declval<const Derived&>(), std::declval<I>()...))>,
int> = 0>
114 return access(static_cast<const Derived&>(*
this), std::forward<I>(i)...);
118 template<
typename...I, std::enable_if_t<
119 values::value<decltype(access(std::declval<Derived&&>(), std::declval<I>()...))>,
int> = 0>
122 return access(static_cast<Derived&&>(*
this), std::forward<I>(i)...);
126 template<
typename...I, std::enable_if_t<
127 values::value<decltype(access(std::declval<const Derived&&>(), std::declval<I>()...))>,
int> = 0>
130 return access(static_cast<const Derived&&>(*
this), std::forward<I>(i)...);
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45
Definition: AdapterBase.hpp:38
decltype(auto) constexpr access(Arg &&arg, const Indices &indices)
Access a component of an indexible object at a given set of indices.
Definition: access.hpp:74
decltype(auto) constexpr operator[](I &&...i) &
Access a component using a collection or pack of indices.
Definition: AdapterBase.hpp:104
Definition for access function.
constexpr AdapterBase()=default
Default constructor.
constexpr Nested & nested_object() &
Get the nested object.
Definition: AdapterBase.hpp:77
constexpr const Nested && nested_object() const &&
Definition: AdapterBase.hpp:86
decltype(auto) constexpr operator[](I &&...i) &&
Definition: AdapterBase.hpp:120
constexpr AdapterBase(Arg &&arg)
Construct from the nested type.
Definition: AdapterBase.hpp:67
constexpr Nested && nested_object() &&
Definition: AdapterBase.hpp:83
decltype(auto) constexpr operator[](I &&...i) const &&
Definition: AdapterBase.hpp:128
Definition: basics.hpp:48
constexpr const Nested & nested_object() const &
Definition: AdapterBase.hpp:80
decltype(auto) constexpr operator[](I &&...i) const &
Definition: AdapterBase.hpp:112