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// SPDX-FileCopyrightText: Copyright (C) 2023 Tobias Hienzsch
3
4#ifndef TETL_LINALG_CONJUGATED_SCALAR_HPP
5#define TETL_LINALG_CONJUGATED_SCALAR_HPP
6
7#include <etl/_concepts/same_as.hpp>
8#include <etl/_linalg/concepts.hpp>
9#include <etl/_linalg/proxy_reference.hpp>
10#include <etl/_type_traits/declval.hpp>
11
12namespace etl::linalg::detail {
13
14template <typename ReferenceValue>
15concept conjugatable = requires {
16 { conj_if_needed(declval<ReferenceValue>()) } -> same_as<ReferenceValue>;
17};
18
19template <typename Reference, conjugatable ReferenceValue>
20struct conjugated_scalar : proxy_reference<Reference, ReferenceValue, conjugated_scalar<Reference, ReferenceValue>> {
21 using value_type = decltype(conj_if_needed(ReferenceValue(declval<Reference>())));
22
23 constexpr explicit conjugated_scalar(Reference reference)
24 : base_type(reference)
25 {
26 }
27
28 [[nodiscard]] static constexpr auto to_value(Reference reference)
29 {
30 return conj_if_needed(ReferenceValue(reference));
31 }
32
33private:
34 using my_type = conjugated_scalar<Reference, ReferenceValue>;
35 using base_type = proxy_reference<Reference, ReferenceValue, my_type>;
36};
37
38} // namespace etl::linalg::detail
39
40#endif // TETL_LINALG_CONJUGATED_SCALAR_HPP
Definition accessor_conjugate.hpp:13
Definition adjacent_find.hpp:9