Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
arene::base::default_accessor< ElementType > Class Template Reference

accesses a single element from a pointer and an index More...

Inheritance diagram for arene::base::default_accessor< ElementType >:
Inheritance graph

Public Types

using data_handle_type = ElementType*
 data handle type Refers to a group of elements. In this case, a pointer.
 
using element_type = ElementType
 element type to access
 
using offset_policy = default_accessor
 offset policy type
 
using reference = ElementType&
 reference type Returned on element to access. In this case, an lvalue reference.
 

Public Member Functions

constexpr default_accessor () noexcept=default
 default constructor
 
template<class OtherElementType, constraints< std::enable_if_t< std::is_convertible< OtherElementType(*)[], element_type(*)[]>::value > > = nullptr>
constexpr default_accessor (default_accessor< OtherElementType >) noexcept
 converting constructor
 
constexpr auto access (data_handle_type ptr, std::size_t index) const noexcept -> reference
 obtain the element at the specified index
 
constexpr auto offset (data_handle_type ptr, std::size_t index) const noexcept -> data_handle_type
 apply an offset to a pointer
 

Detailed Description

template<class ElementType>
class arene::base::default_accessor< ElementType >

accesses a single element from a pointer and an index

Template Parameters
ElementTypecomplete object type that is accessed by default_accessor

Backport of std::default_accessor from C++23. The default_accessor class template is the default AccessorPolicy of mdspan if no user-specified accessor policy is provided. It defines the data_handle_type as a pointer to the ElementType and access will return a reference to the ElementType.

Member Typedef Documentation

◆ data_handle_type

template<class ElementType>
using arene::base::default_accessor< ElementType >::data_handle_type = ElementType*

data handle type Refers to a group of elements. In this case, a pointer.

◆ element_type

template<class ElementType>
using arene::base::default_accessor< ElementType >::element_type = ElementType

element type to access

◆ offset_policy

template<class ElementType>
using arene::base::default_accessor< ElementType >::offset_policy = default_accessor

offset policy type

◆ reference

template<class ElementType>
using arene::base::default_accessor< ElementType >::reference = ElementType&

reference type Returned on element to access. In this case, an lvalue reference.

Constructor & Destructor Documentation

◆ default_accessor() [1/2]

template<class ElementType>
arene::base::default_accessor< ElementType >::default_accessor ( )
constexprdefaultnoexcept

default constructor

Note
This constructor has no visible effect

◆ default_accessor() [2/2]

template<class ElementType>
template<class OtherElementType, constraints< std::enable_if_t< std::is_convertible< OtherElementType(*)[], element_type(*)[]>::value > > = nullptr>
arene::base::default_accessor< ElementType >::default_accessor ( default_accessor< OtherElementType > )
inlineconstexprnoexcept

converting constructor

Template Parameters
OtherElementTypeelement type of the other default_accessor
Note
This constructor has no visible effect

Member Function Documentation

◆ access()

template<class ElementType>
auto arene::base::default_accessor< ElementType >::access ( data_handle_type ptr,
std::size_t index ) const -> reference
inlineconstexprnoexcept

obtain the element at the specified index

Parameters
ptrpointer to an element
indexoffset from the first element
Returns
reference to the element at the specified index

◆ offset()

template<class ElementType>
auto arene::base::default_accessor< ElementType >::offset ( data_handle_type ptr,
std::size_t index ) const -> data_handle_type
inlineconstexprnoexcept

apply an offset to a pointer

Parameters
ptrpointer to an element
indexoffset to apply
Returns
data handle after applying the offset

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