ArrayElementProxy
ArrayElementProxy
Section titled “ArrayElementProxy”#include <array_element_proxy.hh>struct ArrayElementProxyDefined 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.
List of all members
Section titled “List of all members”| 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 |
Public Attributes
Section titled “Public Attributes”| Return | Name | Description |
|---|---|---|
void * |
m_data |
|
DType |
m_dtype |
m_data
Section titled “m_data”void * m_dataDefined in src/lib/ncarray/array_element_proxy.hh:50
m_dtype
Section titled “m_dtype”DType m_dtypeDefined in src/lib/ncarray/array_element_proxy.hh:51
Public Methods
Section titled “Public Methods”| 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. |
operator T&
Section titled “operator T&”const inline
template<typename T, typename = enable_if_t<is_in_type_list_v<T, all_supported_types>>> inline NCA_HD operator T&() constDefined 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.
Parameters
Section titled “Parameters”TThe datatype to coerce to. Enabled only for standard DTypes to prevent issues, particularly with bool coercions.
Returns
Section titled “Returns”Reference to the array element as the requested type.
operator const T &
Section titled “operator const T &”const inline
template<typename T, typename = enable_if_t<is_in_type_list_v<T, all_supported_types>>> inline NCA_HD operator const T &() constDefined 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.
Parameters
Section titled “Parameters”TThe datatype to coerce to. Enabled only for standard DTypes to prevent issues, particularly with bool coercions.
Returns
Section titled “Returns”Const reference to the array element as the requested type.
operator=
Section titled “operator=”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.
Parameters
Section titled “Parameters”TThe datatype of the value to be assigned.
Parameters
Section titled “Parameters”valThe value to assign to the array element.
Returns
Section titled “Returns”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.
Parameters
Section titled “Parameters”TThe datatype to coerce the array element to.
Returns
Section titled “Returns”Reference to the array element as the requested type.
const inline
template<typename T> inline NCA_HD const T & get() constDefined 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.
Parameters
Section titled “Parameters”TThe datatype to coerce the array element to.
Returns
Section titled “Returns”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.
Parameters
Section titled “Parameters”TThe datatype to coerce the array element to.
Returns
Section titled “Returns”Reference to the array element as the requested type.