From 101c534dff395c8fa403fff01043e6ca17768d4b Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Sun, 12 Oct 2025 11:20:17 +0200 Subject: [PATCH 1/2] Make xsimd_scalar.hpp independent from xsimd::batch This paves the way for cleaner error when trying to instantiate an xsimd::batch when to architecture is available. Related to #1143 --- include/xsimd/arch/xsimd_scalar.hpp | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/include/xsimd/arch/xsimd_scalar.hpp b/include/xsimd/arch/xsimd_scalar.hpp index 2452d9e9c..1e309f149 100644 --- a/include/xsimd/arch/xsimd_scalar.hpp +++ b/include/xsimd/arch/xsimd_scalar.hpp @@ -32,11 +32,6 @@ namespace xsimd { - template - class batch; - template - class batch_bool; - using std::abs; using std::acos; @@ -779,20 +774,6 @@ namespace xsimd namespace detail { - template - struct value_type_or_type_helper - { - using type = T; - }; - template - struct value_type_or_type_helper> - { - using type = T; - }; - - template - using value_type_or_type = typename value_type_or_type_helper::type; - template XSIMD_INLINE typename std::enable_if::value, T0>::type ipow(const T0& x, const T1& n) noexcept @@ -801,7 +782,7 @@ namespace xsimd T0 a = x; T1 b = n; bool const recip = b < 0; - T0 r(static_cast>(1)); + T0 r(static_cast(1)); while (1) { if (b & 1) From 74d315eef7d72ba78a3b567baba1a2d601f97262 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Sun, 12 Oct 2025 22:36:28 +0200 Subject: [PATCH 2/2] Proper static_assert when trying to instantiate a batch while no arch is supported Fix #1143 --- include/xsimd/xsimd.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/xsimd/xsimd.hpp b/include/xsimd/xsimd.hpp index 1ae9f5867..e50dc3bd1 100644 --- a/include/xsimd/xsimd.hpp +++ b/include/xsimd/xsimd.hpp @@ -63,7 +63,16 @@ #include "memory/xsimd_aligned_allocator.hpp" #if defined(XSIMD_NO_SUPPORTED_ARCHITECTURE) -// to type definition or anything appart from scalar definition and aligned allocator +// no type definition or anything apart from scalar definition and aligned allocator +namespace xsimd +{ + template + class batch + { + static constexpr bool supported_architecture = sizeof(A*) == 0; // type-dependant but always false + static_assert(supported_architecture, "No SIMD architecture detected, cannot instantiate a batch"); + }; +} #else #include "types/xsimd_batch.hpp" #include "types/xsimd_batch_constant.hpp"