@@ -31,6 +31,7 @@ namespace xsimd
3131 using batch_type = batch_bool<T, A>;
3232 static constexpr std::size_t size = sizeof ...(Values);
3333 using value_type = bool ;
34+ using operand_type = T;
3435 static_assert (sizeof ...(Values) == batch_type::size, " consistent batch size" );
3536
3637 public:
@@ -227,6 +228,63 @@ namespace xsimd
227228
228229#undef MAKE_BINARY_OP
229230
231+ struct boolean_eq
232+ {
233+ constexpr bool operator ()(T x, T y) const { return x == y; }
234+ };
235+ struct boolean_ne
236+ {
237+ constexpr bool operator ()(T x, T y) const { return x != y; }
238+ };
239+ struct boolean_gt
240+ {
241+ constexpr bool operator ()(T x, T y) const { return x > y; }
242+ };
243+ struct boolean_ge
244+ {
245+ constexpr bool operator ()(T x, T y) const { return x >= y; }
246+ };
247+ struct boolean_lt
248+ {
249+ constexpr bool operator ()(T x, T y) const { return x < y; }
250+ };
251+ struct boolean_le
252+ {
253+ constexpr bool operator ()(T x, T y) const { return x <= y; }
254+ };
255+
256+ template <class F , class SelfPack , class OtherPack , size_t ... Indices>
257+ static constexpr batch_bool_constant<T, A, F()(std::tuple_element<Indices, SelfPack>::type::value, std::tuple_element<Indices, OtherPack>::type::value)...>
258+ apply_bool (detail::index_sequence<Indices...>)
259+ {
260+ return {};
261+ }
262+
263+ template <class F , T... OtherValues>
264+ static constexpr auto apply_bool (batch_constant<T, A, Values...>, batch_constant<T, A, OtherValues...>)
265+ -> decltype(apply_bool<F, std::tuple<std::integral_constant<T, Values>...>, std::tuple<std::integral_constant<T, OtherValues>...>>(detail::make_index_sequence<sizeof ...(Values)>()))
266+ {
267+ static_assert (sizeof ...(Values) == sizeof ...(OtherValues), " compatible constant batches" );
268+ return {};
269+ }
270+
271+ #define MAKE_BINARY_BOOL_OP (OP, NAME ) \
272+ template <T... OtherValues> \
273+ constexpr auto operator OP (batch_constant<T, A, OtherValues...> other) const \
274+ -> decltype(apply_bool<NAME>(*this , other)) \
275+ { \
276+ return {}; \
277+ }
278+
279+ MAKE_BINARY_BOOL_OP (==, boolean_eq)
280+ MAKE_BINARY_BOOL_OP (!=, boolean_ne)
281+ MAKE_BINARY_BOOL_OP (<, boolean_lt)
282+ MAKE_BINARY_BOOL_OP (<=, boolean_le)
283+ MAKE_BINARY_BOOL_OP (>, boolean_gt)
284+ MAKE_BINARY_BOOL_OP (>=, boolean_ge)
285+
286+ #undef MAKE_BINARY_BOOL_OP
287+
230288 constexpr batch_constant<T, A, (T)-Values...> operator -() const
231289 {
232290 return {};
0 commit comments