#include <nda/mem/handle.hpp>
template<typename T, Allocator A = mallocator<>>
struct nda::mem::handle_heap< T, A >
A handle for a memory block on the heap.
By default it uses nda::mem::mallocator to allocate/deallocate memory.
- Template Parameters
-
Definition at line 86 of file handle.hpp.
|
|
using | allocator_type = A |
| | nda::mem::Allocator type.
|
|
using | value_type = T |
| | Value type of the data.
|
|
|
| handle_heap ()=default |
| | Default constructor leaves the handle in a null state (nullptr and size 0).
|
| template<OwningHandle< value_type > H> |
| | handle_heap (H const &h) |
| | Construct a handle by making a deep copy of the data from another handle.
|
| | handle_heap (handle_heap &&h) noexcept |
| | Move constructor simply copies the pointers and size and resets the source handle to a null state.
|
| | handle_heap (handle_heap const &h) |
| | Copy constructor makes a deep copy of the data from another handle.
|
| | handle_heap (long size) |
| | Construct a handle by allocating memory for the data of a given size and initializing it depending on the value type.
|
| | handle_heap (long size, do_not_initialize_t) |
| | Construct a handle by allocating memory for the data of a given size but without initializing it.
|
| | handle_heap (long size, init_zero_t) |
| | Construct a handle by allocating memory for the data of a given size and initializing it to zero.
|
| | ~handle_heap () noexcept |
| | Destructor for the handle.
|
| T * | data () const noexcept |
| | Get a pointer to the stored data.
|
| std::shared_ptr< void > | get_sptr () const |
| | Get a shared pointer to the memory block.
|
| bool | is_null () const noexcept |
| | Check if the handle is in a null state.
|
| handle_heap & | operator= (handle_heap &&h) noexcept |
| | Move assignment operator first releases the resources held by the current handle and then moves the resources from the source to the current handle.
|
| handle_heap & | operator= (handle_heap const &h) |
| | Copy assignment operator utilizes the copy constructor and move assignment operator to make a deep copy of the data and size from the source handle.
|
| template<Allocator AS> |
| handle_heap & | operator= (handle_heap< T, AS > const &h) |
| | Assignment operator utilizes another constructor and move assignment to make a deep copy of the data and size from the source handle.
|
| T const & | operator[] (long i) const noexcept |
| | Subscript operator to access the data.
|
| T & | operator[] (long i) noexcept |
| | Subscript operator to access the data.
|
| long | size () const noexcept |
| | Get the size of the handle.
|
|
|
static constexpr auto | address_space = allocator_type::address_space |
| | nda::mem::AddressSpace in which the memory is allocated.
|
◆ ~handle_heap()
template<typename T, Allocator A = mallocator<>>
Destructor for the handle.
If the shared pointer is set, it does nothing. Otherwise, it explicitly calls the destructor of non-trivial objects and deallocates the memory.
Definition at line 152 of file handle.hpp.
◆ handle_heap() [1/6]
template<typename T, Allocator A = mallocator<>>
Move constructor simply copies the pointers and size and resets the source handle to a null state.
- Parameters
-
Definition at line 163 of file handle.hpp.
◆ handle_heap() [2/6]
template<typename T, Allocator A = mallocator<>>
Copy constructor makes a deep copy of the data from another handle.
- Parameters
-
Definition at line 193 of file handle.hpp.
◆ handle_heap() [3/6]
template<typename T, Allocator A = mallocator<>>
Construct a handle by making a deep copy of the data from another handle.
- Template Parameters
-
- Parameters
-
Definition at line 220 of file handle.hpp.
◆ handle_heap() [4/6]
template<typename T, Allocator A = mallocator<>>
Construct a handle by allocating memory for the data of a given size but without initializing it.
- Parameters
-
| size | Size of the data (number of elements). |
Definition at line 248 of file handle.hpp.
◆ handle_heap() [5/6]
template<typename T, Allocator A = mallocator<>>
Construct a handle by allocating memory for the data of a given size and initializing it to zero.
- Parameters
-
| size | Size of the data (number of elements). |
Definition at line 260 of file handle.hpp.
◆ handle_heap() [6/6]
template<typename T, Allocator A = mallocator<>>
Construct a handle by allocating memory for the data of a given size and initializing it depending on the value type.
The data is initialized as follows:
- If T is std::complex and nda::mem::init_dcmplx is true, the data is initialized to zero.
- If T is not trivial and not complex, the data is default constructed by placement new operator calls.
- Otherwise, the data is not initialized.
- Parameters
-
| size | Size of the data (number of elements). |
Definition at line 279 of file handle.hpp.
◆ data()
template<typename T, Allocator A = mallocator<>>
Get a pointer to the stored data.
- Returns
- Pointer to the start of the handled memory.
Definition at line 328 of file handle.hpp.
◆ get_sptr()
template<typename T, Allocator A = mallocator<>>
Get a shared pointer to the memory block.
- Returns
- A copy of the shared pointer stored in the current handle.
Definition at line 142 of file handle.hpp.
◆ is_null()
template<typename T, Allocator A = mallocator<>>
Check if the handle is in a null state.
- Returns
- True if the data is a nullptr (and the size is 0).
Definition at line 316 of file handle.hpp.
◆ operator=() [1/3]
template<typename T, Allocator A = mallocator<>>
Move assignment operator first releases the resources held by the current handle and then moves the resources from the source to the current handle.
- Parameters
-
Definition at line 174 of file handle.hpp.
◆ operator=() [2/3]
template<typename T, Allocator A = mallocator<>>
Copy assignment operator utilizes the copy constructor and move assignment operator to make a deep copy of the data and size from the source handle.
- Parameters
-
Definition at line 208 of file handle.hpp.
◆ operator=() [3/3]
template<typename T, Allocator A = mallocator<>>
template<Allocator AS>
Assignment operator utilizes another constructor and move assignment to make a deep copy of the data and size from the source handle.
- Template Parameters
-
- Parameters
-
| h | Source handle with a different allocator. |
Definition at line 239 of file handle.hpp.
◆ operator[]() [1/2]
template<typename T, Allocator A = mallocator<>>
Subscript operator to access the data.
- Parameters
-
| i | Index of the element to access. |
- Returns
- Const reference to the element at the given index.
Definition at line 310 of file handle.hpp.
◆ operator[]() [2/2]
template<typename T, Allocator A = mallocator<>>
Subscript operator to access the data.
- Parameters
-
| i | Index of the element to access. |
- Returns
- Reference to the element at the given index.
Definition at line 302 of file handle.hpp.
◆ size()
template<typename T, Allocator A = mallocator<>>
Get the size of the handle.
- Returns
- Number of elements of type T in the handled memory.
Definition at line 334 of file handle.hpp.
The documentation for this struct was generated from the following file: