From 3a5bfe445cecd561af606c76f7fde4c561772d4a Mon Sep 17 00:00:00 2001 From: Nils Wentzell Date: Fri, 1 Nov 2024 17:21:56 -0400 Subject: [PATCH] Minor code simplifications in c++/nda/mapped_functions.hpp --- c++/nda/mapped_functions.hpp | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/c++/nda/mapped_functions.hpp b/c++/nda/mapped_functions.hpp index 4661b46d..459cfa42 100644 --- a/c++/nda/mapped_functions.hpp +++ b/c++/nda/mapped_functions.hpp @@ -28,7 +28,6 @@ #include #include -#include #include namespace nda { @@ -41,26 +40,12 @@ namespace nda { namespace detail { // Get the real part of a scalar. - template - auto real(T t) - requires(nda::is_scalar_v) - { - if constexpr (is_complex_v) { - return std::real(t); + template + auto real(S x) { + if constexpr (is_complex_v) { + return std::real(x); } else { - return t; - } - } - - // Get the complex conjugate of a scalar. - template - auto conj(T t) - requires(nda::is_scalar_v) - { - if constexpr (is_complex_v) { - return std::conj(t); - } else { - return t; + return x; } } @@ -75,7 +60,14 @@ namespace nda { // Functor for nda::detail::conj. struct conj_f { - auto operator()(auto const &x) const { return conj(x); }; + template + auto operator()(S x) const { + if constexpr (is_complex_v) { + return std::conj(x); + } else { + return x; + } + } }; } // namespace detail