Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Types | Private Attributes | Related Symbols | List of all members
ArraySlice< T, N, Reverse, Const > Class Template Reference

#include <AH/Containers/Array.hpp>

Detailed Description

template<class T, size_t N, bool Reverse = false, bool Const = true>
class AH::ArraySlice< T, N, Reverse, Const >

Class for a view on a slice of an array.

Doesn't copy the contents of the array, it's just a reference to the original array.

Template Parameters
TThe type of elements of the Array.
NThe size of the slice.
ReverseWhether the slice is reversed or not.
ConstWhether to save a read-only or mutable reference to the Array.

Definition at line 164 of file Array.hpp.

+ Collaboration diagram for ArraySlice< T, N, Reverse, Const >:

Public Types

using iterator
 

Public Member Functions

 ArraySlice (ElementPtrType array)
 Constructor.
 
 operator Array< T, N > () const
 Implicit conversion from slice to new array (creates a copy).
 
Array< T, N > asArray () const
 
ElementRefType operator[] (size_t index) const
 Get the element at the given index.
 
iterator begin () const
 
iterator end () const
 
template<size_t Start, size_t End>
ArraySlice< T, abs_diff(End, Start)+1, Reverse ^(End< Start), Constslice () const
 
template<size_t Start, size_t End>
auto slice () const -> ArraySlice< T, abs_diff(End, Start)+1, Reverse ^(End< Start), Const >
 

Private Types

using ElementRefType
 
using ElementPtrType
 

Private Attributes

ElementPtrType array
 

Related Symbols

(Note that these are not member symbols.)

template<class T , size_t N, bool Reverse, bool Const>
ArraySlice< T, N, Reverse, Const >::iterator operator+ (typename ArraySlice< T, N, Reverse, Const >::iterator::difference_type n, typename ArraySlice< T, N, Reverse, Const >::iterator a)
 <T, N, Reverse, Const>iterator
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
bool operator== (ArraySlice< T1, N1, Reverse1, Const1 > a, ArraySlice< T2, N2, Reverse2, Const2 > b)
 Slice == Slice.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse2, bool Const2>
bool operator== (const Array< T1, N1 > &a, ArraySlice< T2, N2, Reverse2, Const2 > b)
 Array == Slice.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Const1>
bool operator== (ArraySlice< T1, N1, Reverse1, Const1 > a, const Array< T2, N2 > &b)
 Slice == Array.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
bool operator!= (ArraySlice< T1, N1, Reverse1, Const1 > a, ArraySlice< T2, N2, Reverse2, Const2 > b)
 Slice != Slice.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse2, bool Const2>
bool operator!= (const Array< T1, N1 > &a, ArraySlice< T2, N2, Reverse2, Const2 > b)
 Array != Slice.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Const1>
bool operator!= (ArraySlice< T1, N1, Reverse1, Const1 > a, const Array< T2, N2 > &b)
 Slice != Array.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
Array< decltype(T1 {}+T2 {}), N1operator+ (ArraySlice< T1, N1, Reverse1, Const1 > a, ArraySlice< T2, N2, Reverse2, Const2 > b)
 Slice + Slice.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
const ArraySlice< T1, N1, Reverse1, Const1 > & operator+= (const ArraySlice< T1, N1, Reverse1, Const1 > &a, const ArraySlice< T2, N2, Reverse2, Const2 > &b)
 Slice += Slice.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
Array< decltype(T1 {} - T2 {}), N1operator- (ArraySlice< T1, N1, Reverse1, Const1 > a, ArraySlice< T2, N2, Reverse2, Const2 > b)
 Slice - Slice.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
const ArraySlice< T1, N1, Reverse1, Const1 > & operator-= (const ArraySlice< T1, N1, Reverse1, Const1 > &a, const ArraySlice< T2, N2, Reverse2, Const2 > &b)
 Slice -= Slice.
 
template<class T1 , class T2 , size_t N1, bool Reverse1, bool Const1>
Array< decltype(T1 {} *T2 {}), N1operator* (ArraySlice< T1, N1, Reverse1, Const1 > a, T2 b)
 Slice * Scalar.
 
template<class T1 , class T2 , size_t N2, bool Reverse2, bool Const2>
Array< decltype(T1 {} *T2 {}), N2operator* (T1 a, ArraySlice< T2, N2, Reverse2, Const2 > b)
 Scalar * Slice.
 
template<class T1 , class T2 , size_t N1, bool Reverse1, bool Const1>
const ArraySlice< T1, N1, Reverse1, Const1 > & operator*= (const ArraySlice< T1, N1, Reverse1, Const1 > &a, T2 b)
 Slice *= Scalar.
 
template<class T1 , class T2 , size_t N1, bool Reverse1, bool Const1>
Array< decltype(T1 {}/T2 {}), N1operator/ (ArraySlice< T1, N1, Reverse1, Const1 > a, T2 b)
 Slice / Scalar.
 
template<class T1 , class T2 , size_t N1, bool Reverse1, bool Const1>
const ArraySlice< T1, N1, Reverse1, Const1 > & operator/= (const ArraySlice< T1, N1, Reverse1, Const1 > &a, T2 b)
 Slice /= Scalar.
 
template<class T , size_t N, bool Reverse, bool Const>
Array< decltype(-T {}), N > operator- (ArraySlice< T, N, Reverse, Const > a)
 -Slice
 

Member Typedef Documentation

◆ ElementRefType

template<class T , size_t N, bool Reverse = false, bool Const = true>
using ElementRefType
private
Initial value:
typename std::conditional<Const, const T &, T &>::type

Definition at line 165 of file Array.hpp.

◆ ElementPtrType

template<class T , size_t N, bool Reverse = false, bool Const = true>
using ElementPtrType
private
Initial value:
typename std::conditional<Const, const T *, T *>::type

Definition at line 167 of file Array.hpp.

◆ iterator

template<class T , size_t N, bool Reverse = false, bool Const = true>
using iterator
Initial value:
typename std::conditional<
Reverse, std::reverse_iterator<ElementPtrType>, ElementPtrType>::type
typename std::conditional< Const, const T *, T * >::type ElementPtrType
Definition Array.hpp:167

Definition at line 184 of file Array.hpp.

Constructor & Destructor Documentation

◆ ArraySlice()

template<class T , size_t N, bool Reverse = false, bool Const = true>
ArraySlice ( ElementPtrType array)
inline

Constructor.

Definition at line 172 of file Array.hpp.

Member Function Documentation

◆ operator Array< T, N >()

template<class T , size_t N, bool Reverse = false, bool Const = true>
operator Array< T, N > ( ) const
inline

Implicit conversion from slice to new array (creates a copy).

Definition at line 175 of file Array.hpp.

◆ asArray()

template<class T , size_t N, bool Reverse = false, bool Const = true>
Array< T, N > asArray ( ) const
inline

Definition at line 177 of file Array.hpp.

◆ operator[]()

template<class T , size_t N, bool Reverse = false, bool Const = true>
ElementRefType operator[] ( size_t index) const
inline

Get the element at the given index.

Note
Bounds checking is performed. If fatal errors are disabled, the last element is returned if the index is out of bounds.
Parameters
indexThe (zero-based) index of the element to return.

Definition at line 196 of file Array.hpp.

◆ begin()

template<class T , size_t N, bool Reverse = false, bool Const = true>
iterator begin ( ) const
inline

Definition at line 207 of file Array.hpp.

◆ end()

template<class T , size_t N, bool Reverse = false, bool Const = true>
iterator end ( ) const
inline

Definition at line 214 of file Array.hpp.

◆ slice()

template<class T , size_t N, bool Reverse = false, bool Const = true>
template<size_t Start, size_t End>
ArraySlice< T, abs_diff(End, Start)+1, Reverse ^(End< Start), Const > slice ( ) const

Member Data Documentation

◆ array

template<class T , size_t N, bool Reverse = false, bool Const = true>
ElementPtrType array
private

Definition at line 226 of file Array.hpp.


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