flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
flexiblesusy::Dynamic_array_view< ElementType > Class Template Reference

secure array wrapper More...

#include <array_view.hpp>

Collaboration diagram for flexiblesusy::Dynamic_array_view< ElementType >:
Collaboration graph

Public Types

using Const_iterator_t = Iterator_t
 
using Element_t = ElementType
 
using Index_t = std::ptrdiff_t
 
using Iterator_t = Pointer_t
 
using Pointer_t = Element_t *
 
using Reference_t = Element_t &
 

Public Member Functions

Iterator_t begin () const noexcept
 
Const_iterator_t cbegin () const noexcept
 
Const_iterator_t cend () const noexcept
 
constexpr Pointer_t data () const noexcept
 
constexpr Dynamic_array_view () noexcept=default
 
template<std::size_t N>
constexpr Dynamic_array_view (ElementType(&arr)[N]) noexcept
 
constexpr Dynamic_array_view (Pointer_t first, Pointer_t last) noexcept
 
constexpr Dynamic_array_view (Pointer_t p, Index_t l) noexcept
 
constexpr bool empty () const noexcept
 
Iterator_t end () const noexcept
 
Reference_t operator[] (Index_t idx)
 
Element_t operator[] (Index_t idx) const
 
constexpr Index_t size () const noexcept
 

Private Member Functions

void check_range (Index_t idx) const
 

Private Attributes

Index_t len {0}
 
Pointer_t ptr {nullptr}
 

Detailed Description

template<typename ElementType>
class flexiblesusy::Dynamic_array_view< ElementType >

secure array wrapper

This class represtents a secure wrapper for a C-style array, for which the size is not known at compile time. The class allows to read/write the wrapped C-style array through the subscript operator[].

Examples:

double a[4] = { 1., 2., 3., 4. };
double elem = av[1]; // read 2nd element
double a[4] = { 1., 2., 3., 4. };
double elem = av[1]; // read 2nd element
double a[4] = { 1., 2., 3., 4. };
av[1] = 0; // write 2nd element
double a[4] = { 1., 2., 3., 4. };
const auto av = make_dynamic_array_view(a);
double elem = av[1]; // read 2nd element
constexpr Dynamic_array_view< ElementType > make_dynamic_array_view(ElementType *ptr, std::ptrdiff_t len)
Definition: array_view.hpp:125
double a[4] = { 1., 2., 3., 4. };
const auto av = make_dynamic_array_view(a, 4);
double elem = av[1]; // read 2nd element

Definition at line 72 of file array_view.hpp.

Member Typedef Documentation

◆ Const_iterator_t

template<typename ElementType >
using flexiblesusy::Dynamic_array_view< ElementType >::Const_iterator_t = Iterator_t

Definition at line 79 of file array_view.hpp.

◆ Element_t

template<typename ElementType >
using flexiblesusy::Dynamic_array_view< ElementType >::Element_t = ElementType

Definition at line 75 of file array_view.hpp.

◆ Index_t

template<typename ElementType >
using flexiblesusy::Dynamic_array_view< ElementType >::Index_t = std::ptrdiff_t

Definition at line 76 of file array_view.hpp.

◆ Iterator_t

template<typename ElementType >
using flexiblesusy::Dynamic_array_view< ElementType >::Iterator_t = Pointer_t

Definition at line 78 of file array_view.hpp.

◆ Pointer_t

template<typename ElementType >
using flexiblesusy::Dynamic_array_view< ElementType >::Pointer_t = Element_t*

Definition at line 77 of file array_view.hpp.

◆ Reference_t

template<typename ElementType >
using flexiblesusy::Dynamic_array_view< ElementType >::Reference_t = Element_t&

Definition at line 80 of file array_view.hpp.

Constructor & Destructor Documentation

◆ Dynamic_array_view() [1/4]

template<typename ElementType >
constexpr flexiblesusy::Dynamic_array_view< ElementType >::Dynamic_array_view ( )
constexprdefaultnoexcept

◆ Dynamic_array_view() [2/4]

template<typename ElementType >
constexpr flexiblesusy::Dynamic_array_view< ElementType >::Dynamic_array_view ( Pointer_t  p,
Index_t  l 
)
inlineconstexprnoexcept

Definition at line 83 of file array_view.hpp.

◆ Dynamic_array_view() [3/4]

template<typename ElementType >
constexpr flexiblesusy::Dynamic_array_view< ElementType >::Dynamic_array_view ( Pointer_t  first,
Pointer_t  last 
)
inlineconstexprnoexcept

Definition at line 85 of file array_view.hpp.

◆ Dynamic_array_view() [4/4]

template<typename ElementType >
template<std::size_t N>
constexpr flexiblesusy::Dynamic_array_view< ElementType >::Dynamic_array_view ( ElementType(&)  arr[N])
inlineconstexprnoexcept

Definition at line 88 of file array_view.hpp.

Member Function Documentation

◆ begin()

template<typename ElementType >
Iterator_t flexiblesusy::Dynamic_array_view< ElementType >::begin ( ) const
inlinenoexcept

◆ cbegin()

template<typename ElementType >
Const_iterator_t flexiblesusy::Dynamic_array_view< ElementType >::cbegin ( ) const
inlinenoexcept

◆ cend()

template<typename ElementType >
Const_iterator_t flexiblesusy::Dynamic_array_view< ElementType >::cend ( ) const
inlinenoexcept

◆ check_range()

template<typename ElementType >
void flexiblesusy::Dynamic_array_view< ElementType >::check_range ( Index_t  idx) const
inlineprivate

◆ data()

template<typename ElementType >
constexpr Pointer_t flexiblesusy::Dynamic_array_view< ElementType >::data ( ) const
inlineconstexprnoexcept

◆ empty()

template<typename ElementType >
constexpr bool flexiblesusy::Dynamic_array_view< ElementType >::empty ( ) const
inlineconstexprnoexcept

◆ end()

template<typename ElementType >
Iterator_t flexiblesusy::Dynamic_array_view< ElementType >::end ( ) const
inlinenoexcept

◆ operator[]() [1/2]

template<typename ElementType >
Reference_t flexiblesusy::Dynamic_array_view< ElementType >::operator[] ( Index_t  idx)
inline

◆ operator[]() [2/2]

template<typename ElementType >
Element_t flexiblesusy::Dynamic_array_view< ElementType >::operator[] ( Index_t  idx) const
inline

◆ size()

template<typename ElementType >
constexpr Index_t flexiblesusy::Dynamic_array_view< ElementType >::size ( ) const
inlineconstexprnoexcept

Member Data Documentation

◆ len

◆ ptr


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