diff --git a/sycl/include/sycl/functional.hpp b/sycl/include/sycl/functional.hpp index 4dae45d392b66..e0201e0a64a40 100644 --- a/sycl/include/sycl/functional.hpp +++ b/sycl/include/sycl/functional.hpp @@ -23,6 +23,11 @@ template using bit_xor = std::bit_xor; // std:logical_and/std::logical_or with a non-void type returns bool, // sycl requires returning T. +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES +template struct logical_and : std::logical_and {}; +template struct logical_or : std::logical_or {}; + +#else template struct logical_and { T operator()(const T &lhs, const T &rhs) const { return lhs && rhs; } }; @@ -35,6 +40,8 @@ template struct logical_or { template <> struct logical_or : std::logical_or {}; +#endif + // sycl::minimum definition should be consistent with std::min template struct minimum { T operator()(const T &lhs, const T &rhs) const { diff --git a/sycl/test/basic_tests/logical_operations.cpp b/sycl/test/basic_tests/logical_operations.cpp new file mode 100644 index 0000000000000..e040470cecd04 --- /dev/null +++ b/sycl/test/basic_tests/logical_operations.cpp @@ -0,0 +1,25 @@ +// RUN: %clang -fpreview-breaking-changes -fsycl -fsyntax-only %s +// RUN: %clang -fsycl -fsyntax-only %s + +#include +#include +#include + +int main() { + const auto logicalAnd = sycl::logical_and(); + const auto logicalOr = sycl::logical_or(); + const auto logicalAndVoid = sycl::logical_and(); + const auto logicalOrVoid = sycl::logical_or(); +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); +#else + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + static_assert(std::is_same_v); +#endif + return 0; +}