19 namespace ext::oneapi {
23 static_assert(Dims >= 0 && Dims < 4,
"Invalid dimensionality in range.");
24 if constexpr (Dims == 0)
26 if constexpr (Dims == 1)
28 else if constexpr (Dims == 2)
40 template <
typename SYCLObjT>
41 class weak_object :
public detail::weak_object_base<SYCLObjT> {
47 : detail::weak_object_base<SYCLObjT>(SYCLObj) {}
59 std::optional<SYCLObjT>
try_lock() const noexcept {
60 auto MObjImplPtr = this->MObjWeakPtr.lock();
63 return sycl::detail::createSyclObjFromImpl<SYCLObjT>(MObjImplPtr);
66 std::optional<SYCLObjT> OptionalObj = try_lock();
69 "Referenced object has expired.");
76 template <
typename T,
int Dimensions,
typename AllocatorT>
88 MRange{detail::createDummyRange<Dimensions>()}, MOffsetInBytes{0},
89 MIsSubBuffer{
false} {}
92 MOffsetInBytes{SYCLObj.OffsetInBytes},
93 MIsSubBuffer{SYCLObj.IsSubBuffer} {}
94 weak_object(
const weak_object &Other) noexcept =
default;
95 weak_object(weak_object &&Other) noexcept =
default;
100 this->MRange = SYCLObj.Range;
101 this->MOffsetInBytes = SYCLObj.OffsetInBytes;
102 this->MIsSubBuffer = SYCLObj.IsSubBuffer;
108 std::optional<buffer_type>
try_lock() const noexcept {
109 auto MObjImplPtr = this->MObjWeakPtr.lock();
113 return buffer_type{MObjImplPtr, MRange, MOffsetInBytes, MIsSubBuffer};
116 std::optional<buffer_type> OptionalObj = try_lock();
119 "Referenced object has expired.");
126 size_t MOffsetInBytes;