1313#define XSIMD_BATCH_CONSTANT_HPP
1414
1515#include < cstddef>
16+ #include < functional>
1617#include < utility>
1718
1819#include " ./xsimd_batch.hpp"
@@ -289,42 +290,12 @@ namespace xsimd
289290 return values[i];
290291 }
291292
292- struct arithmetic_add
293- {
294- constexpr T operator ()(T x, T y) const { return x + y; }
295- };
296- struct arithmetic_sub
297- {
298- constexpr T operator ()(T x, T y) const { return x - y; }
299- };
300- struct arithmetic_mul
301- {
302- constexpr T operator ()(T x, T y) const { return x * y; }
303- };
304- struct arithmetic_div
305- {
306- constexpr T operator ()(T x, T y) const { return x / y; }
307- };
308- struct arithmetic_mod
309- {
310- constexpr T operator ()(T x, T y) const { return x % y; }
311- };
312- struct binary_and
313- {
314- constexpr T operator ()(T x, T y) const { return x & y; }
315- };
316- struct binary_or
317- {
318- constexpr T operator ()(T x, T y) const { return x | y; }
319- };
320- struct binary_xor
321- {
322- constexpr T operator ()(T x, T y) const { return x ^ y; }
323- };
293+ template <typename = void >
324294 struct binary_rshift
325295 {
326296 constexpr T operator ()(T x, T y) const { return x >> y; }
327297 };
298+ template <typename = void >
328299 struct binary_lshift
329300 {
330301 constexpr T operator ()(T x, T y) const { return x << y; }
@@ -349,47 +320,22 @@ namespace xsimd
349320 template <T... OtherValues> \
350321 constexpr auto operator OP (batch_constant<T, A, OtherValues...> other) const \
351322 { \
352- return apply<NAME> (*this , other); \
323+ return apply<NAME< void >> (*this , other); \
353324 }
354325
355- MAKE_BINARY_OP (+, arithmetic_add )
356- MAKE_BINARY_OP (-, arithmetic_sub )
357- MAKE_BINARY_OP (*, arithmetic_mul )
358- MAKE_BINARY_OP (/, arithmetic_div )
359- MAKE_BINARY_OP (%, arithmetic_mod )
360- MAKE_BINARY_OP (&, binary_and )
361- MAKE_BINARY_OP (|, binary_or )
362- MAKE_BINARY_OP (^, binary_xor )
326+ MAKE_BINARY_OP (+, std::plus )
327+ MAKE_BINARY_OP (-, std::minus )
328+ MAKE_BINARY_OP (*, std::multiplies )
329+ MAKE_BINARY_OP (/, std::divides )
330+ MAKE_BINARY_OP (%, std::modulus )
331+ MAKE_BINARY_OP (&, std::bit_and )
332+ MAKE_BINARY_OP (|, std::bit_or )
333+ MAKE_BINARY_OP (^, std::bit_xor )
363334 MAKE_BINARY_OP (<<, binary_lshift)
364335 MAKE_BINARY_OP (>>, binary_rshift)
365336
366337#undef MAKE_BINARY_OP
367338
368- struct boolean_eq
369- {
370- constexpr bool operator ()(T x, T y) const { return x == y; }
371- };
372- struct boolean_ne
373- {
374- constexpr bool operator ()(T x, T y) const { return x != y; }
375- };
376- struct boolean_gt
377- {
378- constexpr bool operator ()(T x, T y) const { return x > y; }
379- };
380- struct boolean_ge
381- {
382- constexpr bool operator ()(T x, T y) const { return x >= y; }
383- };
384- struct boolean_lt
385- {
386- constexpr bool operator ()(T x, T y) const { return x < y; }
387- };
388- struct boolean_le
389- {
390- constexpr bool operator ()(T x, T y) const { return x <= y; }
391- };
392-
393339 template <class F , class SelfPack , class OtherPack , std::size_t ... Indices>
394340 static constexpr batch_bool_constant<T, A, F()(std::tuple_element<Indices, SelfPack>::type::value, std::tuple_element<Indices, OtherPack>::type::value)...>
395341 apply_bool (std::index_sequence<Indices...>)
@@ -408,15 +354,15 @@ namespace xsimd
408354 template <T... OtherValues> \
409355 constexpr auto operator OP (batch_constant<T, A, OtherValues...> other) const \
410356 { \
411- return apply_bool<NAME> (*this , other); \
357+ return apply_bool<NAME< void >> (*this , other); \
412358 }
413359
414- MAKE_BINARY_BOOL_OP (==, boolean_eq )
415- MAKE_BINARY_BOOL_OP (!=, boolean_ne )
416- MAKE_BINARY_BOOL_OP (<, boolean_lt )
417- MAKE_BINARY_BOOL_OP (<=, boolean_le )
418- MAKE_BINARY_BOOL_OP (>, boolean_gt )
419- MAKE_BINARY_BOOL_OP (>=, boolean_ge )
360+ MAKE_BINARY_BOOL_OP (==, std::equal_to )
361+ MAKE_BINARY_BOOL_OP (!=, std::not_equal_to )
362+ MAKE_BINARY_BOOL_OP (<, std::less )
363+ MAKE_BINARY_BOOL_OP (<=, std::less_equal )
364+ MAKE_BINARY_BOOL_OP (>, std::greater )
365+ MAKE_BINARY_BOOL_OP (>=, std::greater_equal )
420366
421367#undef MAKE_BINARY_BOOL_OP
422368
0 commit comments