16 #ifndef OPENKALMAN_NUMBER_TRAITS_HPP 17 #define OPENKALMAN_NUMBER_TRAITS_HPP 21 #include "../../basics/compatibility/language-features.hpp" 34 template<
typename T,
typename =
void>
54 static constexpr
auto real = [](T) {
throw std::logic_error(
"Interface not implemented"); };
60 static constexpr
auto imag = [](T) {
throw std::logic_error(
"Interface not implemented"); };
68 static constexpr
auto make_complex = [](T re, T im) {
throw std::logic_error(
"Interface not implemented"); };
90 template<
typename T> requires std::is_arithmetic_v<T>
99 static constexpr
auto real = [](T t) noexcept {
return std::real(std::move(t)); };
100 static constexpr
auto imag = [](T t) noexcept {
return std::imag(std::move(t)); };
101 static constexpr
auto make_complex = [](T re, T im) noexcept {
return std::complex<T> {std::move(re), std::move(im)}; };
113 static constexpr
auto real = [](std::complex<T> t) noexcept {
return std::real(std::move(t)); };
114 static constexpr
auto imag = [](std::complex<T> t) noexcept {
return std::imag(std::move(t)); };
115 static constexpr
auto make_complex = [](T re, T im) noexcept {
return std::complex<T> {std::move(re), std::move(im)}; };
121 #endif //OPENKALMAN_NUMBER_TRAITS_HPP static constexpr auto imag
A callable object that returns the real part of the argument of type T.
Definition: number_traits.hpp:60
Definition: basics.hpp:41
constexpr auto imag(Arg arg)
A constexpr function to obtain the imaginary part of a (complex) number.
Definition: imag.hpp:40
constexpr bool complex
T is a values::value that reduces to std::complex or a custom complex type.
Definition: complex.hpp:46
static constexpr bool is_specialized
This value is true for all T for which there exists a specialization of numeric_traits.
Definition: number_traits.hpp:42
Definition: tuple_reverse.hpp:103
static constexpr auto real
A callable object that returns the real part of the argument of type T.
Definition: number_traits.hpp:54
constexpr auto real(Arg arg)
A constexpr function to obtain the real part of a (complex) number.
Definition: real.hpp:40
static constexpr auto make_complex
A callable object that makes a complex number consistent with T from two real arguments.
Definition: number_traits.hpp:68
static constexpr bool is_complex
Whether T is a complex number.
Definition: number_traits.hpp:48
Definition: number_traits.hpp:36