@@ -43,12 +43,21 @@ namespace xt
4343 } \
4444 }
4545
46+ #define DEFINE_COMPLEX_OVERLOAD (OP ) \
47+ template <class T1 , class T2 , XTL_REQUIRES(xtl::negation<std::is_same<T1, T2>>)> \
48+ constexpr auto operator OP (const std::complex <T1>& arg1, const std::complex <T2>& arg2) \
49+ { \
50+ using result_type = typename xtl::promote_type_t <std::complex <T1>, std::complex <T2>>; \
51+ return (result_type (arg1) OP result_type (arg2)); \
52+ }
53+
4654#define BINARY_OPERATOR_FUNCTOR (NAME, OP ) \
4755 struct NAME \
4856 { \
4957 template <class T1 , class T2 > \
5058 constexpr auto operator ()(T1&& arg1, T2&& arg2) const \
5159 { \
60+ using xt::detail::operator OP; \
5261 return (std::forward<T1>(arg1) OP std::forward<T2>(arg2)); \
5362 } \
5463 template <class B > \
@@ -60,6 +69,24 @@ namespace xt
6069
6170 namespace detail
6271 {
72+ DEFINE_COMPLEX_OVERLOAD (+);
73+ DEFINE_COMPLEX_OVERLOAD (-);
74+ DEFINE_COMPLEX_OVERLOAD (*);
75+ DEFINE_COMPLEX_OVERLOAD (/);
76+ DEFINE_COMPLEX_OVERLOAD (%);
77+ DEFINE_COMPLEX_OVERLOAD (||);
78+ DEFINE_COMPLEX_OVERLOAD (&&);
79+ DEFINE_COMPLEX_OVERLOAD (|);
80+ DEFINE_COMPLEX_OVERLOAD (&);
81+ DEFINE_COMPLEX_OVERLOAD (^);
82+ DEFINE_COMPLEX_OVERLOAD (<<);
83+ DEFINE_COMPLEX_OVERLOAD (>>);
84+ DEFINE_COMPLEX_OVERLOAD (<);
85+ DEFINE_COMPLEX_OVERLOAD (<=);
86+ DEFINE_COMPLEX_OVERLOAD (>);
87+ DEFINE_COMPLEX_OVERLOAD (>=);
88+ DEFINE_COMPLEX_OVERLOAD (==);
89+ DEFINE_COMPLEX_OVERLOAD (!=);
6390
6491 UNARY_OPERATOR_FUNCTOR (identity, +);
6592 UNARY_OPERATOR_FUNCTOR (negate, -);
0 commit comments