cuda::experimental::uninitialized_buffer

Defined in /home/runner/work/cccl/cccl/cudax/include/cuda/experimental/__container/uninitialized_buffer.cuh

template<class _Tp, class ..._Properties>
class uninitialized_buffer

Uninitialized type safe memory storage

uninitialized_buffer provides a typed buffer allocated from a given memory resource. It handles alignment and release of the allocation. The memory is uninitialized, so that a user needs to ensure elements are properly constructed.

In addition to being type safe, uninitialized_buffer also takes a set of properties to ensure that e.g. execution space constraints are checked at compile time. However, we can only forward stateless properties. If a user wants to use a stateful one, then they need to implement get_property(const device_buffer&, Property).

Template Parameters
  • _Tp – the type to be stored in the buffer

  • _Properties... – The properties the allocated memory satisfies

Public Types

using value_type = _Tp
using reference = _Tp&
using pointer = _Tp*
using size_type = size_t

Public Functions

inline uninitialized_buffer(__resource __mr, const size_t __count)

Constructs a uninitialized_buffer, allocating sufficient storage for __count elements through __mr.

Note

Depending on the alignment requirements of T the size of the underlying allocation might be larger than count * sizeof(T).

Note

Only allocates memory when __count > 0

Parameters
  • __mr – The memory resource to allocate the buffer with.

  • __count – The desired size of the buffer.

uninitialized_buffer(const uninitialized_buffer&) = delete
uninitialized_buffer &operator=(const uninitialized_buffer&) = delete
inline uninitialized_buffer(uninitialized_buffer &&__other) noexcept

Move construction.

Parameters

__other – Another uninitialized_buffer

inline uninitialized_buffer &operator=(uninitialized_buffer &&__other) noexcept

Move assignment.

Parameters

__other – Another uninitialized_buffer

inline ~uninitialized_buffer()

Destroys an uninitialized_buffer deallocating the buffer.

Warning

The destructor does not destroy any objects that may or may not reside within the buffer. It is the user’s responsibility to ensure that all objects within the buffer have been properly destroyed.

inline pointer begin() const noexcept

Returns an aligned pointer to the buffer.

inline pointer end() const noexcept

Returns an aligned pointer to end of the buffer.

inline pointer data() const noexcept

Returns an aligned pointer to the buffer.

inline constexpr size_type size() const noexcept

Returns the size of the buffer.

inline const __resource &get_resource() const noexcept

Returns a c const reference to the any_resource that holds the memory resource used to allocate the buffer

inline constexpr void swap(uninitialized_buffer &__other) noexcept

Swaps the contents with those of another uninitialized_buffer.

Parameters

__other – The other uninitialized_buffer.