@@ -54,20 +54,14 @@ namespace oneapi {
54
54
namespace experimental {
55
55
56
56
namespace detail {
57
- // Type-trait for checking if a type defines `operator->`.
58
- template <typename T, typename = void >
59
- struct HasParenthesisOperator : std::false_type {};
60
- template <typename T>
61
- struct HasParenthesisOperator <
62
- T, sycl::detail::void_t <decltype (std::declval<T>().operator ()())>>
63
- : std::true_type {};
64
57
58
+ // Type-trait for checking if a type defines `operator[]`.
65
59
template <typename T, typename = void >
66
60
struct HasSubscriptOperator : std::false_type {};
67
61
68
62
template <typename T>
69
63
struct HasSubscriptOperator <
70
- T, sycl::detail:: void_t <decltype (std::declval<T>().operator []()) >>
64
+ T, typename std:: enable_if_t <!std::is_void <decltype (std::declval<T>().operator [](0 ))>::value >>
71
65
: std::true_type {};
72
66
73
67
} // namespace detail
@@ -274,13 +268,21 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(annotated_arg) annotated_arg <T, detail::
274
268
return obj;
275
269
}
276
270
277
- // template<typename... Args>
278
- // template <class RelayT = T>
279
- // std::enable_if_t<detail::HasParenthesisOperator<RelayT>::value>
280
- // &operator()(Args... args) noexcept {
281
- // __SYCL_HOST_NOT_SUPPORTED("operator() on an annotated_arg")
282
- // return obj.operator(args);
283
- // }
271
+ template <class RelayT = T>
272
+ std::enable_if_t <
273
+ detail::HasSubscriptOperator<RelayT>::value,
274
+ const decltype (std::declval<RelayT>().operator [](0 ))>
275
+ &operator [](std::ptrdiff_t idx) const noexcept {
276
+ return obj.operator [](idx);
277
+ }
278
+
279
+ template <class RelayT = T>
280
+ std::enable_if_t <
281
+ detail::HasSubscriptOperator<RelayT>::value,
282
+ decltype (std::declval<RelayT>().operator [](0 ))>
283
+ &operator [](std::ptrdiff_t idx) noexcept {
284
+ return obj.operator [](idx);
285
+ }
284
286
285
287
template <typename PropertyT> static constexpr bool has_property () {
286
288
return property_list_t ::template has_property<PropertyT>();
0 commit comments