Skip to content

Commit

Permalink
Forward declare and specialize trait in one place
Browse files Browse the repository at this point in the history
Signed-off-by: Larsen, Steffen <[email protected]>
  • Loading branch information
steffenlarsen committed Oct 30, 2024
1 parent a531a18 commit c66d01d
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions sycl/include/sycl/ext/oneapi/device_global/device_global.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ namespace sycl {
inline namespace _V1 {
namespace ext::oneapi::experimental {

template <typename T, typename PropertyListT> class device_global;

namespace detail {
// Type-trait for checking if a type defines `operator->`.
template <typename T, typename = void>
Expand All @@ -49,10 +51,19 @@ struct HasArrowOperator<T,
std::void_t<decltype(std::declval<T>().operator->())>>
: std::true_type {};

template <typename T, typename PropertyListT, typename>
class device_global_base;

// Checks that T is a reference to either device_global or
// device_global_base. This is used by the variadic ctor to allow copy ctors to
// take preference.
template <typename T> struct IsDeviceGlobalOrBaseRef : std::false_type {};
template <typename T, typename PropertyListT>
struct IsDeviceGlobalOrBaseRef<device_global_base<T, PropertyListT, void> &>
: std::true_type {};
template <typename T, typename PropertyListT>
struct IsDeviceGlobalOrBaseRef<device_global<T, PropertyListT> &>
: std::true_type {};

// Base class for device_global.
template <typename T, typename PropertyListT, typename = void>
Expand Down Expand Up @@ -179,10 +190,6 @@ class device_global_base<
}
};

template <typename T, typename PropertyListT>
struct IsDeviceGlobalOrBaseRef<const device_global_base<T, PropertyListT> &>
: std::true_type {};

} // namespace detail

template <typename T, typename PropertyListT = empty_properties_t>
Expand Down Expand Up @@ -305,12 +312,6 @@ class
}
};

namespace detail {
template <typename T, typename PropertyListT>
struct IsDeviceGlobalOrBaseRef<device_global<T, PropertyListT> &>
: std::true_type {};
} // namespace detail

} // namespace ext::oneapi::experimental
} // namespace _V1
} // namespace sycl
Expand Down

0 comments on commit c66d01d

Please sign in to comment.