Skip to content

ArrayElementProxy

#include <array_element_proxy.hh>
struct ArrayElementProxy

Defined in src/lib/ncarray/array_element_proxy.hh:49

The element proxy can be returned by arrays during indexing to provide reference based access to the underlying data.

This mostly provides improved ergonomics.

In general, operator T& style coercion/cast functions do NOT type check. The get<T> variants will type check in DEBUG builds using assertions.

The assignment operator= will perform a cast. The set<T> will type check in DEBUG builds using assertions.

Name Kind Owner
m_data variable Declared here
m_dtype variable Declared here
operator T& function Declared here
operator const T & function Declared here
operator= function Declared here
get function Declared here
get function Declared here
set function Declared here
Return Name Description
void * m_data
DType m_dtype

void * m_data

Defined in src/lib/ncarray/array_element_proxy.hh:50


DType m_dtype

Defined in src/lib/ncarray/array_element_proxy.hh:51

Return Name Description
NCA_HD operator T& const inline Coerce to the respective type if the type is among the standard array DTypes.
NCA_HD operator const T & const inline Coerce to the respective type if the type is among the standard array DTypes.
NCA_HDArrayElementProxy & operator= inline Assign val to the underlying array element referenced.
NCA_HD T & get inline Retrieve the underlying array element as a reference of the indicated type.
NCA_HD const T & get const inline Retrieve the underlying array element as a reference of the indicated type.
NCA_HD void set inline Assign the underlying array data element the value of val.

const inline

template<typename T, typename = enable_if_t<is_in_type_list_v<T, all_supported_types>>> inline NCA_HD operator T&() const

Defined in src/lib/ncarray/array_element_proxy.hh:63

Coerce to the respective type if the type is among the standard array DTypes.

This function does NOT check the actual datatype of the array.

  • T The datatype to coerce to. Enabled only for standard DTypes to prevent issues, particularly with bool coercions.

Reference to the array element as the requested type.


const inline

template<typename T, typename = enable_if_t<is_in_type_list_v<T, all_supported_types>>> inline NCA_HD operator const T &() const

Defined in src/lib/ncarray/array_element_proxy.hh:77

Coerce to the respective type if the type is among the standard array DTypes.

This function does NOT check the actual datatype of the array.

  • T The datatype to coerce to. Enabled only for standard DTypes to prevent issues, particularly with bool coercions.

Const reference to the array element as the requested type.


inline

template<typename T> inline NCA_HDArrayElementProxy & operator=(const T & val)

Defined in src/lib/ncarray/array_element_proxy.hh:95

Assign val to the underlying array element referenced.

This function will cast val as appropriate.

Todo: Consider whether dispatch support is required for extended types like Key/Val structs.

  • T The datatype of the value to be assigned.
  • val The value to assign to the array element.

The ArrayElementProxy.


inline

template<typename T> inline NCA_HD T & get()

Defined in src/lib/ncarray/array_element_proxy.hh:117

Retrieve the underlying array element as a reference of the indicated type.

This function will check the types match in DEBUG builds with assertions.

  • T The datatype to coerce the array element to.

Reference to the array element as the requested type.


const inline

template<typename T> inline NCA_HD const T & get() const

Defined in src/lib/ncarray/array_element_proxy.hh:131

Retrieve the underlying array element as a reference of the indicated type.

This function will check the types match in DEBUG builds with assertions.

  • T The datatype to coerce the array element to.

Const reference to the array element as the requested type.


inline

template<typename T> inline NCA_HD void set(const T & val)

Defined in src/lib/ncarray/array_element_proxy.hh:145

Assign the underlying array data element the value of val.

This function will check the types match in DEBUG builds with assertions.

  • T The datatype to coerce the array element to.

Reference to the array element as the requested type.