Tannic
A C++ Tensor Library
Loading...
Searching...
No Matches
tannic::Buffer Class Reference

Managed memory buffer with explicit ownership. More...

#include <buffer.hpp>

Public Member Functions

 Buffer (std::size_t nbytes, Environment environment=Host{})
 Constructs a buffer with specified size and environment.
 
 Buffer (const Buffer &)=delete
 
Bufferoperator= (const Buffer &)=delete
 
 Buffer (Buffer &&other) noexcept
 Move constructor transfers ownership.
 
Bufferoperator= (Buffer &&other) noexcept
 Move assignment transfers ownership.
 
 ~Buffer ()
 Destructor releases owned memory.
 
void * address ()
 Gets writable pointer to memory.
 
const void * address () const
 Gets read-only pointer to memory

 
std::size_t nbytes () const
 Gets buffer size in bytes.
 
Environment const & environment () const
 Gets the environment used for this buffer.
 

Detailed Description

Managed memory buffer with explicit ownership.

Wraps a contiguous memory region with:

  • Size tracking
  • Environment awareness
  • Move semantics for ownership transfer
  • Const-correct access methods

Constructor & Destructor Documentation

◆ Buffer() [1/3]

tannic::Buffer::Buffer ( std::size_t  nbytes,
Environment  environment = Host{} 
)

Constructs a buffer with specified size and environment.

Parameters
nbytesSize of memory region in bytes
environmentEnvironment to use (defaults to Host)

◆ Buffer() [2/3]

tannic::Buffer::Buffer ( const Buffer )
delete

◆ Buffer() [3/3]

tannic::Buffer::Buffer ( Buffer &&  other)
noexcept

Move constructor transfers ownership.

Parameters
otherSource buffer to move from

◆ ~Buffer()

tannic::Buffer::~Buffer ( )

Destructor releases owned memory.

Member Function Documentation

◆ address() [1/2]

void * tannic::Buffer::address ( )

Gets writable pointer to memory.

Returns
Pointer to allocated memory

◆ address() [2/2]

const void * tannic::Buffer::address ( ) const

Gets read-only pointer to memory

Returns
Const pointer to allocated memory

◆ environment()

Environment const & tannic::Buffer::environment ( ) const

Gets the environment used for this buffer.

Returns
Reference to the environment instance

◆ nbytes()

std::size_t tannic::Buffer::nbytes ( ) const

Gets buffer size in bytes.

Returns
Size of allocated memory region

◆ operator=() [1/2]

Buffer & tannic::Buffer::operator= ( Buffer &&  other)
noexcept

Move assignment transfers ownership.

Parameters
otherSource buffer to move from
Returns
Reference to this buffer

◆ operator=() [2/2]

Buffer & tannic::Buffer::operator= ( const Buffer )
delete

The documentation for this class was generated from the following file: