tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
conjugated_scalar.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_LINALG_CONJUGATED_SCALAR_HPP
4#define TETL_LINALG_CONJUGATED_SCALAR_HPP
5
10
11namespace etl::linalg::detail {
12
13template <typename ReferenceValue>
14concept conjugatable = requires {
15 { conj_if_needed(declval<ReferenceValue>()) } -> same_as<ReferenceValue>;
16};
17
18template <typename Reference, conjugatable ReferenceValue>
19struct conjugated_scalar : proxy_reference<Reference, ReferenceValue, conjugated_scalar<Reference, ReferenceValue>> {
20 using value_type = decltype(conj_if_needed(ReferenceValue(declval<Reference>())));
21
22 constexpr explicit conjugated_scalar(Reference reference)
23 : base_type(reference)
24 {
25 }
26
27 [[nodiscard]] static constexpr auto to_value(Reference reference)
28 {
29 return conj_if_needed(ReferenceValue(reference));
30 }
31
32private:
33 using my_type = conjugated_scalar<Reference, ReferenceValue>;
34 using base_type = proxy_reference<Reference, ReferenceValue, my_type>;
35};
36
37} // namespace etl::linalg::detail
38
39#endif // TETL_LINALG_CONJUGATED_SCALAR_HPP
auto declval() noexcept -> add_rvalue_reference_t< T >