TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
nda::mem::handle_stack< T, Size >

#include <nda/mem/handle.hpp>

Detailed Description

template<typename T, size_t Size>
struct nda::mem::handle_stack< T, Size >

A handle for a memory block on the stack.

Note
This handle only works with the Host nda::mem::AddressSpace.
Template Parameters
TValue type of the data.
SizeSize of the data (number of elements).

Definition at line 359 of file handle.hpp.

Public Types

using value_type = T
 Value type of the data.
 

Public Member Functions

 handle_stack ()=default
 Default constructor leaves the data uninitialized.
 
 handle_stack (handle_stack &&h) noexcept
 Move constructor simply calls the copy assignment operator.
 
 handle_stack (handle_stack const &h) noexcept
 Copy constructor simply calls the copy assignment operator.
 
 handle_stack (long)
 Construct a handle and initialize the data depending on the value type.
 
 handle_stack (long, do_not_initialize_t)
 Construct a handle and do not initialize the data.
 
 handle_stack (long, init_zero_t)
 Construct a handle and initialize the data to zero (only for scalar and complex types).
 
 ~handle_stack () noexcept
 Destructor for the handle.
 
T * data () const noexcept
 Get a pointer to the stored data.
 
handle_stackoperator= (handle_stack &&h) noexcept
 Move assignment operator simply calls the copy assignment operator.
 
handle_stackoperator= (handle_stack const &h)
 Copy assignment operator makes a deep copy of the data from the source handle using placement new.
 
T const & operator[] (long i) const noexcept
 Subscript operator to access the data.
 
T & operator[] (long i) noexcept
 Subscript operator to access the data.
 

Static Public Member Functions

static constexpr bool is_null () noexcept
 Check if the handle is in a null state.
 
static constexpr long size () noexcept
 Get the size of the handle.
 

Static Public Attributes

static constexpr auto address_space = Host
 nda::mem::AddressSpace in which the memory is allocated (always on Host).
 

Constructor & Destructor Documentation

◆ ~handle_stack()

template<typename T , size_t Size>
nda::mem::handle_stack< T, Size >::~handle_stack ( )
inlinenoexcept

Destructor for the handle.

For non-trivial objects, it explicitly calls their destructors. Otherwise, it does nothing.

Definition at line 378 of file handle.hpp.

◆ handle_stack() [1/3]

template<typename T , size_t Size>
nda::mem::handle_stack< T, Size >::handle_stack ( handle_stack< T, Size > && h)
inlinenoexcept

Move constructor simply calls the copy assignment operator.

If an exception occurs in the constructor of T, the program terminates.

Parameters
hSource handle.

Definition at line 393 of file handle.hpp.

◆ handle_stack() [2/3]

template<typename T , size_t Size>
nda::mem::handle_stack< T, Size >::handle_stack ( handle_stack< T, Size > const & h)
inlinenoexcept

Copy constructor simply calls the copy assignment operator.

If an exception occurs in the constructor of T, the program terminates.

Parameters
hSource handle.

Definition at line 410 of file handle.hpp.

◆ handle_stack() [3/3]

template<typename T , size_t Size>
nda::mem::handle_stack< T, Size >::handle_stack ( long )
inline

Construct a handle and initialize the data depending on the value type.

The data is initialized as follows:

  • If T is not trivial and not complex, the data is default constructed by placement new operator calls.
  • Otherwise, the data is not initialized.

Definition at line 437 of file handle.hpp.

Member Function Documentation

◆ data()

template<typename T , size_t Size>
T * nda::mem::handle_stack< T, Size >::data ( ) const
inlinenodiscardnoexcept

Get a pointer to the stored data.

Returns
Pointer to the start of the handled memory.

Definition at line 469 of file handle.hpp.

◆ is_null()

template<typename T , size_t Size>
static constexpr bool nda::mem::handle_stack< T, Size >::is_null ( )
inlinestaticconstexprnoexcept

Check if the handle is in a null state.

Returns
False (there is no null state on the stack).

Definition at line 463 of file handle.hpp.

◆ operator=() [1/2]

template<typename T , size_t Size>
handle_stack & nda::mem::handle_stack< T, Size >::operator= ( handle_stack< T, Size > && h)
inlinenoexcept

Move assignment operator simply calls the copy assignment operator.

If an exception occurs in the constructor of T, the program terminates.

Parameters
hSource handle.

Definition at line 400 of file handle.hpp.

◆ operator=() [2/2]

template<typename T , size_t Size>
handle_stack & nda::mem::handle_stack< T, Size >::operator= ( handle_stack< T, Size > const & h)
inline

Copy assignment operator makes a deep copy of the data from the source handle using placement new.

Parameters
hSource handle.

Definition at line 416 of file handle.hpp.

◆ operator[]() [1/2]

template<typename T , size_t Size>
T const & nda::mem::handle_stack< T, Size >::operator[] ( long i) const
inlinenodiscardnoexcept

Subscript operator to access the data.

Parameters
iIndex of the element to access.
Returns
Const reference to the element at the given index.

Definition at line 457 of file handle.hpp.

◆ operator[]() [2/2]

template<typename T , size_t Size>
T & nda::mem::handle_stack< T, Size >::operator[] ( long i)
inlinenodiscardnoexcept

Subscript operator to access the data.

Parameters
iIndex of the element to access.
Returns
Reference to the element at the given index.

Definition at line 449 of file handle.hpp.

◆ size()

template<typename T , size_t Size>
static constexpr long nda::mem::handle_stack< T, Size >::size ( )
inlinestaticconstexprnoexcept

Get the size of the handle.

Returns
Number of elements of type T in the handled memory.

Definition at line 475 of file handle.hpp.


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