cuda::experimental::basic_resource_ref#
-
template<_ResourceKind _Kind, class ..._Properties>
class basic_resource_ref# Type erased wrapper around a reference to an object that satisfies the
resourceconcept and that provides the requested_Properties.basic_resource_refmodels thecuda::std::copyableandcuda::std::equality_comparableconcepts.- Template Parameters:
_Properties – The properties that any resource wrapped within the
basic_resource_refneeds to provide.
Public Functions
-
basic_resource_ref(const basic_resource_ref &__other)#
Copy constructs a
basic_resource_ref.- Post:
*thisand__otherboth refer to the same resource object.
-
template<class _Resource>
basic_resource_ref(_Resource &__res)# Constructs a
basic_resource_reffrom a reference to a type that satisfies theresourceconcept and that supports all of the specified properties.- Parameters:
__res – The resource reference to be wrapped.
- Pre:
synchronous_resource_with<_Resource, _Properties...>istrue.- Pre:
If
_Kindis_ResourceKind::_Asynchronous,resource_with<_Resource, _Properties...>istrue.- Pre:
If
__resrefers to a specialization ofbasic_any_resourceor a type derived from such,__res.has_value()istrue.
-
template<_ResourceKind _OtherKind, class ..._OtherProperties>
basic_resource_ref( - basic_resource_ref<_OtherKind, _OtherProperties...> __res,
Conversion from type-erased resource reference with a superset of the required properties.
- Parameters:
__res – The other type-erased resource reference to copy from.
- Pre:
_OtherKindis equal to either_Kindor_ResourceKind::_Asynchronous.- Pre:
The set
_OtherProperties...is a superset of_Properties....- Post:
*thisand__resboth refer to the same resource object.
-
basic_resource_ref &operator=(const basic_resource_ref &__other)#
Rebinds
*thisto refer to the object to which__otherrefers.- Post:
*thisand__otherboth refer to the same resource object.
-
template<class _Resource>
basic_resource_ref &operator=( - _Resource &__res,
Rebinds the wrapped reference to an object whose type satisfies the
resourceconcept and that supports all of the specified properties.- Parameters:
__res – The reference to the resource to be wrapped by the
basic_resource_ref.- Pre:
synchronous_resource_with<_Resource, _Properties...>istrue.- Pre:
If
_Kindis_ResourceKind::_Asynchronous,synchronous_resource_with<_Resource, _Properties...>istrue.- Pre:
If
__resrefers to a specialization ofbasic_any_resourceor a type derived from such,__res.has_value()istrue.
-
template<_ResourceKind _OtherKind, class ..._OtherProperties>
basic_resource_ref &operator=( - basic_resource_ref<_OtherKind, _OtherProperties...> __res,
Rebinds
*thisto refer to the object to which__otherrefers.- Parameters:
__res – The other type-erased resource reference to copy from.
- Pre:
_OtherKindis equal to either_Kindor_ResourceKind::_Asynchronous.- Pre:
The set
_OtherProperties...is a superset of_Properties....- Post:
*thisand__resboth refer to the same resource object.
-
template<_ResourceKind _OtherKind, class ..._OtherProperties>
bool operator==( - const basic_resource_ref<_OtherKind, _OtherProperties...> &__rhs,
Equality comparison between two type-erased resource references.
- Parameters:
__rhs – The other type-erased resource reference.
- Pre:
_OtherKindis equal to either_Kindor_ResourceKind::_Asynchronous.- Pre:
The set
_Properties...is equal to the set_OtherProperties....- Returns:
trueif both resources refer to objects of the same type and those objects compare equal. Otherwise, returnsfalse.
- void *allocate_sync(
- size_t __size,
- size_t __align = alignof(cuda::std::max_align_t),
Calls
allocate_syncon the wrapped reference with the specified arguments.- Returns:
obj.allocate_sync(__size, __align), whereobjis the wrapped reference.
- void deallocate_sync(
- void *__pv,
- size_t __size,
- size_t __align = alignof(cuda::std::max_align_t),
Calls
deallocate_syncon the wrapped reference with the specified arguments.- Pre:
__pvmust be a pointer that was previously returned by a call toallocateon the object referenced by*this.- Returns:
obj.deallocate_sync(__pv, __size, __align), whereobjis the wrapped reference.
- void *allocate(
- cuda::stream_ref __stream,
- size_t __size,
- size_t __align,
Calls
allocateon the wrapped reference with the specified arguments.Warning
The returned pointer is not valid until
__streamhas been synchronized.- Pre:
_Kindis_ResourceKind::_Asynchronous.- Returns:
obj.allocate(__stream, __size, __align), whereobjis the wrapped reference.
-
void *allocate(cuda::stream_ref __stream, size_t __size)#
Equivalent to
.allocate(__stream, __size,
alignof(::cuda::std::max_align_t))
- void deallocate(
- cuda::stream_ref __stream,
- void *__pv,
- size_t __size,
- size_t __align,
Calls
deallocateon the wrapped reference with the specified arguments.- Pre:
_Kindis_ResourceKind::_Asynchronous.- Pre:
__pvmust be a pointer that was previously returned by a call toallocateon the object referenced by*this.- Returns:
obj.deallocate(__stream, __pv, __size, __align), whereobjis the wrapped reference.
-
void deallocate(cuda::stream_ref __stream, void *__pv, size_t __size)#
Equivalent to
.deallocate(__stream, __pv, __size,
alignof(::cuda::std::max_align_t), __stream)
-
const cuda::std::type_info &type() const noexcept#
- Returns:
A reference to the
type_infoobject for the type of the object to which*thisrefers.
Friends
-
template<class _Property>
friend decltype(auto) get_property( - const basic_resource_ref &__res,
- _Property __prop,
Forwards a property query to the type-erased reference.
- Template Parameters:
_Property –
- Parameters:
__res – The
basic_resource_refobject__prop – The property to query
- Pre:
_Propertyis a type in_Properties....- Returns:
The result of calling
get_property(__obj, __prop), where__objis the type-erased reference stored in__res.
-
template<class _Property>
friend auto try_get_property( - const basic_resource_ref &__res,
- _Property __prop,
Attempts to forward a property query to the type-erased object and returns a _
boolean-testable_ object that contains the result, if any.- Template Parameters:
_Property –
- Parameters:
__res – The
any_synchronous_resourceobject__prop – The property to query
- Pre:
has_value()istrue.- Returns:
Let:
objbe the wrapped reference.ValueTypebe the associated value type of__prop.ReturnTypebeboolifValueTypeisvoid. Otherwise,ReturnTypeiscuda::std::optional<ValueType>._OtherPropertiesbe the pack of type parameters of the wrapper type that first type-erasedobj. [Note:_OtherPropertiesis different than_Propertieswhen*thisis the result of an interface-narrowing conversion. — end note]
try_get_property(__res, __prop)has typeReturnType. If_Propertyis not in the pack_OtherProperties, returnsReturnType(). Otherwise:Returns
trueifValueTypeisvoid.Returns
ReturnType(get_property(obj, __prop))otherwise.