Control Surface  1.2.0
MIDI Control Surface library for Arduino
Classes | Public Member Functions | Private Types | Private Attributes | List of all members
ArraySlice< T, N, Reverse, Const > Class Template Reference

Class for a view on a slice of an array. More...

#include <AH/Containers/Array.hpp>

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

Classes

class  Iterator
 

Public Member Functions

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

Private Types

using ElementRefType = typename std::conditional< Const, const T &, T & >::type
 
using ElementPtrType = typename std::conditional< Const, const T *, T * >::type
 

Private Attributes

ElementPtrType array
 

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 168 of file Array.hpp.

Member Typedef Documentation

◆ ElementRefType

using ElementRefType = typename std::conditional<Const, const T &, T &>::type
private

Definition at line 169 of file Array.hpp.

◆ ElementPtrType

using ElementPtrType = typename std::conditional<Const, const T *, T *>::type
private

Definition at line 171 of file Array.hpp.

Constructor & Destructor Documentation

◆ ArraySlice()

ArraySlice ( ElementPtrType  array)
inline

Constructor.

Definition at line 176 of file Array.hpp.

Member Function Documentation

◆ operator Array< T, N >()

operator Array< T, N > ( ) const
inline

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

Definition at line 179 of file Array.hpp.

◆ asArray()

Array<T, N> asArray ( ) const
inline

Definition at line 181 of file Array.hpp.

◆ operator[]()

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 246 of file Array.hpp.

◆ begin()

Iterator begin ( ) const
inline

Definition at line 257 of file Array.hpp.

◆ end()

Iterator end ( ) const
inline

Definition at line 264 of file Array.hpp.

◆ slice()

ArraySlice<T, abs_diff(End, Start) + 1, Reverse ^ (End < Start), Const> slice ( ) const

Member Data Documentation

◆ array

ElementPtrType array
private

Definition at line 276 of file Array.hpp.


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