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

#include <nda/mem/handle.hpp>

Detailed Description

template<typename T, AddressSpace AdrSp = Host>
struct nda::mem::handle_borrowed< T, AdrSp >

A non-owning handle for a memory block on the heap.

Template Parameters
TValue type of the data.
AdrSpnda::mem::AddressSpace in which the memory is allocated.

Definition at line 858 of file handle.hpp.

Public Types

using value_type = T
 Value type of the data.
 

Public Member Functions

 handle_borrowed ()=default
 Default constructor leaves the handle in a null state (nullptr).
 
template<Handle H>
requires (address_space == H::address_space and (std::is_const_v<value_type> or !std::is_const_v<typename H::value_type>) and std::is_same_v<const value_type, const typename H::value_type>)
 handle_borrowed (H const &h, long offset=0) noexcept
 Construct a borrowed handle from a another handle.
 
 handle_borrowed (handle_borrowed const &)=default
 Default copy constructor.
 
 handle_borrowed (T *ptr) noexcept
 Construct a borrowed handle from a pointer to the data.
 
T * data () const noexcept
 Get a pointer to the stored data.
 
bool is_null () const noexcept
 Check if the handle is in a null state.
 
handle_borrowedoperator= (handle_borrowed &&)=default
 Default move assignment operator.
 
handle_borrowedoperator= (handle_borrowed const &)=default
 Default copy assignment operator.
 
T const & operator[] (long i) const noexcept
 Subscript operator to access the data.
 
T & operator[] (long i) noexcept
 Subscript operator to access the data.
 
handle_heap< T0 > const * parent () const
 Get a pointer to the parent handle.
 

Static Public Attributes

static constexpr auto address_space = AdrSp
 nda::mem::AddressSpace in which the memory is allocated.
 

Constructor & Destructor Documentation

◆ handle_borrowed() [1/2]

template<typename T , AddressSpace AdrSp = Host>
nda::mem::handle_borrowed< T, AdrSp >::handle_borrowed ( T * ptr)
inlinenoexcept

Construct a borrowed handle from a pointer to the data.

Parameters
ptrPointer to the start of the data.

Definition at line 892 of file handle.hpp.

◆ handle_borrowed() [2/2]

template<typename T , AddressSpace AdrSp = Host>
template<Handle H>
requires (address_space == H::address_space and (std::is_const_v<value_type> or !std::is_const_v<typename H::value_type>) and std::is_same_v<const value_type, const typename H::value_type>)
nda::mem::handle_borrowed< T, AdrSp >::handle_borrowed ( H const & h,
long offset = 0 )
inlinenoexcept

Construct a borrowed handle from a another handle.

Template Parameters
Hnda::mem::Handle type.
Parameters
hOther handle.
offsetPointer offset from the start of the data (in number of elements).

Definition at line 904 of file handle.hpp.

Member Function Documentation

◆ data()

template<typename T , AddressSpace AdrSp = Host>
T * nda::mem::handle_borrowed< T, AdrSp >::data ( ) const
inlinenodiscardnoexcept

Get a pointer to the stored data.

Returns
Pointer to the start of the handled memory.

Definition at line 940 of file handle.hpp.

◆ is_null()

template<typename T , AddressSpace AdrSp = Host>
bool nda::mem::handle_borrowed< T, AdrSp >::is_null ( ) const
inlinenodiscardnoexcept

Check if the handle is in a null state.

Returns
True if the data is a nullptr.

Definition at line 928 of file handle.hpp.

◆ operator[]() [1/2]

template<typename T , AddressSpace AdrSp = Host>
T const & nda::mem::handle_borrowed< T, AdrSp >::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 922 of file handle.hpp.

◆ operator[]() [2/2]

template<typename T , AddressSpace AdrSp = Host>
T & nda::mem::handle_borrowed< T, AdrSp >::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 914 of file handle.hpp.

◆ parent()

template<typename T , AddressSpace AdrSp = Host>
handle_heap< T0 > const * nda::mem::handle_borrowed< T, AdrSp >::parent ( ) const
inlinenodiscard

Get a pointer to the parent handle.

Returns
Pointer to the parent handle.

Definition at line 934 of file handle.hpp.


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