Skip to content

Commit 34e8cf4

Browse files
committed
bug fix
1 parent 86aeb05 commit 34e8cf4

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

sycl/include/sycl/ext/oneapi/experimental/annotated_arg/annotated_arg.hpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ struct is_ann_arg_impl<const annotated_arg<T, P>> : std::true_type {};
4848
template <class T>
4949
constexpr bool is_ann_arg_v =
5050
is_ann_arg_impl<std::remove_reference_t<T>>::value;
51+
52+
template <class T> struct GetUnderlyingTImpl;
53+
template <class T, class P> struct GetUnderlyingTImpl<annotated_arg<T, P>> {
54+
using type = T;
55+
};
56+
template <class T>
57+
using GetUnderlyingT = typename GetUnderlyingTImpl<
58+
std::remove_cv_t<std::remove_reference_t<T>>>::type;
59+
5160
} // namespace detail
5261

5362
// Deduction guide
@@ -220,6 +229,7 @@ template <typename T, typename... Props>
220229
class __SYCL_SPECIAL_CLASS
221230
__SYCL_TYPE(annotated_arg) annotated_arg<T, detail::properties_t<Props...>> {
222231
using property_list_t = detail::properties_t<Props...>;
232+
using UnderlyingT = T;
223233

224234
template <typename T2, typename PropertyListT> friend class annotated_arg;
225235

@@ -326,10 +336,11 @@ __SYCL_TYPE(annotated_arg) annotated_arg<T, detail::properties_t<Props...>> {
326336

327337
// propagate binary operators
328338
#define PROPAGATE_OP(op) \
329-
template <class O> \
330-
friend auto operator op(O &&a, const annotated_arg &b) \
331-
->decltype(std::forward<O>(a) op std::declval<T>()) { \
332-
return std::forward<O>(a) op b.operator T(); \
339+
template <class O> friend auto operator op(O &&a, const annotated_arg &b) { \
340+
if constexpr (!detail::is_ann_arg_v<O>) \
341+
return std::forward<O>(a) op b.operator T(); \
342+
else \
343+
return a.operator detail::GetUnderlyingT<O>() op b.operator T(); \
333344
} \
334345
template <class O, typename = std::enable_if_t<!detail::is_ann_arg_v<O>>> \
335346
friend auto operator op(const annotated_arg &a, O &&b) \

0 commit comments

Comments
 (0)