diff --git a/include/xsimd/types/xsimd_batch.hpp b/include/xsimd/types/xsimd_batch.hpp index 015e036ca..e5210ca37 100644 --- a/include/xsimd/types/xsimd_batch.hpp +++ b/include/xsimd/types/xsimd_batch.hpp @@ -228,6 +228,7 @@ struct batch, A> { using real_batch = batch; using arch_type = A; static constexpr std::size_t size = real_batch::size; + using batch_bool_type = batch_bool; batch() = default; batch(value_type const& val) : m_real(val.real()), m_imag(val.imag()) {} diff --git a/include/xsimd/types/xsimd_register.hpp b/include/xsimd/types/xsimd_register.hpp index d28ccefc4..3aadc9a9c 100644 --- a/include/xsimd/types/xsimd_register.hpp +++ b/include/xsimd/types/xsimd_register.hpp @@ -1,6 +1,7 @@ #ifndef XSIMD_REGISTER_HPP #define XSIMD_REGISTER_HPP +#include #include namespace xsimd diff --git a/include/xsimd/types/xsimd_traits.hpp b/include/xsimd/types/xsimd_traits.hpp index 50f965dc9..a6d4bba1b 100644 --- a/include/xsimd/types/xsimd_traits.hpp +++ b/include/xsimd/types/xsimd_traits.hpp @@ -159,6 +159,20 @@ namespace xsimd : std::enable_if::value, batch, A>> { }; + +#if XSIMD_ENABLE_XTL_COMPLEX + template + struct simd_return_type_impl, T2, A> + : std::enable_if::value, batch, A>> + { + }; + + template + struct simd_return_type_impl, xtl::xcomplex, A> + : std::enable_if::value, batch, A>> + { + }; +#endif } template diff --git a/test/test_batch_complex.cpp b/test/test_batch_complex.cpp index 83f401b6b..a9d13d929 100644 --- a/test/test_batch_complex.cpp +++ b/test/test_batch_complex.cpp @@ -21,7 +21,7 @@ class batch_complex_test : public testing::Test { protected: - using batch_type = B; + using batch_type = xsimd::simd_type; using arch_type = typename B::arch_type; using real_batch_type = typename B::real_batch; using value_type = typename B::value_type; diff --git a/test/test_traits.cpp b/test/test_traits.cpp index ea31bff04..6b61ab7aa 100644 --- a/test/test_traits.cpp +++ b/test/test_traits.cpp @@ -47,7 +47,7 @@ class traits_test : public testing::Test using rtype1 = xsimd::simd_return_type; constexpr bool res1 = std::is_same>::value; EXPECT_TRUE(res1); - + using rtype2 = xsimd::simd_return_type; constexpr bool res2 = std::is_same>::value; EXPECT_TRUE(res2); @@ -71,3 +71,65 @@ TYPED_TEST(traits_test, simd_return_type) this->test_simd_return_type(); } +template +class complex_traits_test : public testing::Test +{ +protected: + + using batch_type = B; + using value_type = typename B::value_type; + + void test_simd_traits() + { + using traits_type = xsimd::simd_traits; + EXPECT_EQ(traits_type::size, batch_type::size); + constexpr bool same_type = std::is_same::value; + EXPECT_TRUE(same_type); + using batch_bool_type = xsimd::batch_bool; + constexpr bool same_bool_type = std::is_same::value; + EXPECT_TRUE(same_bool_type); + + using vector_traits_type = xsimd::simd_traits>; + EXPECT_EQ(vector_traits_type::size, 1); + constexpr bool vec_same_type = std::is_same>::value; + EXPECT_TRUE(vec_same_type); + } + + void test_revert_simd_traits() + { + using traits_type = xsimd::revert_simd_traits; + EXPECT_EQ(traits_type::size, batch_type::size); + constexpr bool same_type = std::is_same::value; + EXPECT_TRUE(same_type); + } + + void test_simd_return_type() + { + using rtype1 = xsimd::simd_return_type; + constexpr bool res1 = std::is_same>>::value; + EXPECT_TRUE(res1); + + using rtype2 = xsimd::simd_return_type; + constexpr bool res2 = std::is_same>::value; + EXPECT_TRUE(res2); + } +}; + +TYPED_TEST_SUITE(complex_traits_test, batch_complex_types, simd_test_names); + +TYPED_TEST(complex_traits_test, simd_traits) +{ + this->test_simd_traits(); +} + +TYPED_TEST(complex_traits_test, revert_simd_traits) +{ + this->test_revert_simd_traits(); +} + +TYPED_TEST(complex_traits_test, simd_return_type) +{ + this->test_simd_return_type(); +} + +