Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions include/simsycl/detail/coordinate.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ class coordinate {
for(int d = 0; d < Dimensions; ++d) { result[d] = lhs.m_values[d] op rhs.m_values[d]; } \
return result; \
} \
friend constexpr Interface operator op(const Interface &lhs, const size_t &rhs) { \
template <typename Integral> \
requires(std::integral<Integral>) \
friend constexpr Interface operator op(const Interface &lhs, const Integral &rhs) { \
Interface result = make_interface_type(); \
for(int d = 0; d < Dimensions; ++d) { result[d] = lhs.m_values[d] op rhs; } \
return result; \
Expand Down Expand Up @@ -78,7 +80,9 @@ class coordinate {
for(int d = 0; d < Dimensions; ++d) { lhs.m_values[d] op rhs.m_values[d]; } \
return lhs; \
} \
friend constexpr Interface &operator op(Interface & lhs, const size_t & rhs) { \
template <typename Integral> \
requires(std::integral<Integral>) \
friend constexpr Interface &operator op(Interface & lhs, const Integral & rhs) { \
for(int d = 0; d < Dimensions; ++d) { lhs.m_values[d] op rhs; } \
return lhs; \
}
Expand All @@ -97,7 +101,9 @@ class coordinate {
#undef SIMSYCL_DETAIL_DEFINE_COORDINATE_BINARY_INPLACE_LHS_OPERATOR

#define SIMSYCL_DETAIL_DEFINE_COORDINATE_BINARY_COPY_RHS_OPERATOR(op) \
friend constexpr Interface operator op(const size_t &lhs, const Interface &rhs) { \
template <typename Integral> \
requires(std::integral<Integral>) \
friend constexpr Interface operator op(const Integral &lhs, const Interface &rhs) { \
Interface result = make_interface_type(); \
for(int d = 0; d < Dimensions; ++d) { result[d] = lhs op rhs.m_values[d]; } \
return result; \
Expand Down
15 changes: 15 additions & 0 deletions test/ambiguity_tests.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <catch2/catch_test_macros.hpp>

#include <cstddef>

#include <sycl/sycl.hpp>

using namespace sycl;
Expand Down Expand Up @@ -27,3 +29,16 @@ TEST_CASE("Calls to the deprecated parallel_for signature are not ambiguous", "[
}

SIMSYCL_STOP_IGNORING_DEPRECATIONS

TEST_CASE("Calls of operator op with integral type are not abiguous", "[ambiguity]") {
SECTION("size_t") {
[[maybe_unused]] auto multiply = [](id<1> i, size_t j) {
return i * j;
};
}
SECTION("int") {
[[maybe_unused]] auto multiply = [](id<1> i, int j) {
return i * j;
};
}
}