OpenVDB 13.1.0
Loading...
Searching...
No Matches
BufferView< T > Class Template Reference

Non-owning, trivially copyable view of a contiguous range of T elements, with span semantics. More...

#include <nanovdb/cuda/Buffer.h>

Public Member Functions

 BufferView ()=default
 Default c-tor of an empty view.
 BufferView (T *data, size_t count)
 C-tor viewing a contiguous range; the caller guarantees the underlying storage outlives every use of the view.
T * data () const
 Returns a pointer to the viewed elements, or nullptr if empty.
size_t size () const
 Returns the number of viewed elements.
size_t size_bytes () const
 Returns the size of the viewed range in bytes.
bool empty () const
 Returns true if this view references no elements.
void destroy ()
 Detaches the view (nulls the pointer and zeroes the size) without touching the underlying storage – the view is non-owning, so "destroying" it releases nothing. This is the one deliberate deviation from std::span, required by the buffer static interface the handles consume through reset().
void clear ()
 Detaches the view.

Detailed Description

template<typename T>
class nanovdb::cuda::BufferView< T >

Non-owning, trivially copyable view of a contiguous range of T elements, with span semantics.

Template Parameters
Telement type; spell constness in the element type (e.g. BufferView<const std::byte> is the read-only form), since const on the view itself is shallow.

Constructor & Destructor Documentation

◆ BufferView() [1/2]

template<typename T>
BufferView ( )
default

Default c-tor of an empty view.

◆ BufferView() [2/2]

template<typename T>
BufferView ( T * data,
size_t count )
inline

C-tor viewing a contiguous range; the caller guarantees the underlying storage outlives every use of the view.

Parameters
datapointer to the first element
countnumber of elements
Exceptions
std::runtime_errorif data is null while count is non-zero.

Member Function Documentation

◆ clear()

template<typename T>
void clear ( )
inline

Detaches the view.

Deprecated
Use destroy(): the handles now dispatch to it directly.

◆ data()

template<typename T>
T * data ( ) const
inline

Returns a pointer to the viewed elements, or nullptr if empty.

◆ destroy()

template<typename T>
void destroy ( )
inline

Detaches the view (nulls the pointer and zeroes the size) without touching the underlying storage – the view is non-owning, so "destroying" it releases nothing. This is the one deliberate deviation from std::span, required by the buffer static interface the handles consume through reset().

◆ empty()

template<typename T>
bool empty ( ) const
inline

Returns true if this view references no elements.

◆ size()

template<typename T>
size_t size ( ) const
inline

Returns the number of viewed elements.

◆ size_bytes()

template<typename T>
size_t size_bytes ( ) const
inline

Returns the size of the viewed range in bytes.