6#include <AH/STL/algorithm>
8#if __cplusplus >= 201400L
9#define USE_CONSTEXPR_ARRAY_HELPERS constexpr
11#define USE_CONSTEXPR_ARRAY_HELPERS
27template <
class T,
class V>
31 : value(start), increment(increment) {}
63template <
class T,
size_t N,
class G>
66 std::generate(array.begin(), array.end(),
generator);
83template <
size_t N,
class G>
87 std::generate(array.begin(), array.end(),
generator);
104template <
class T,
size_t N,
class U>
107 std::transform(std::begin(
src), std::end(
src), std::begin(
dest),
108 [](
const U &
src) {
return T(
src); });
115template <
class F,
class U,
size_t N>
119 std::transform(std::begin(
src), std::end(
src), std::begin(
dest),
f);
123#if !defined(__GNUC__) || (__GNUC__ > 7) || \
124 (__GNUC__ == 7 && __GNUC_MINOR__ >= 3) || defined(DOXYGEN)
128template <
class T,
size_t N,
class... Args>
133template <
class T,
size_t N,
class... Args>
135 Array<T, N> array{{}};
136 for (
auto &el : array)
174template <
class T,
size_t N,
class U,
class V = U>
196template <
class T,
size_t M,
size_t N>
201 for (
size_t i = 0;
i <
M; ++
i, ++r)
203 for (
size_t i = 0;
i < N; ++
i, ++r)
208template <
class T1,
class T2,
size_t N1,
size_t N2,
bool Reverse1,
209 bool Reverse2,
bool Const1,
bool Const2>
214 for (
size_t i = 0;
i <
N1; ++
i)
215 for (
size_t j = 0;
j <
N2; ++
j)
220template <
class T1,
class T2,
size_t N1,
size_t N2,
bool Reverse1,
bool Const1>
227template <
class T1,
class T2,
size_t N1,
size_t N2,
bool Reverse2,
bool Const2>
234template <
class T1,
class T2,
size_t N1,
size_t N2>
250template <
class T,
size_t N,
bool Reverse,
bool Const>
251std::enable_if_t<std::is_arithmetic<T>::value, std::ostream &>
253 for (
const T &el : a.template slice<0, N - 2>())
259template <
class T,
size_t N>
260std::enable_if_t<std::is_arithmetic<T>::value, std::ostream &>
262 return os << a.slice();
273template <
class T,
size_t N,
bool Reverse,
bool Const>
274std::enable_if_t<std::is_arithmetic<T>::value, Print &>
276 for (
const T &el : a.template slice<0, N - 2>())
282template <
class T,
size_t N>
283std::enable_if_t<std::is_arithmetic<T>::value, Print &>
285 return os << a.slice();
#define BEGIN_AH_NAMESPACE
#define USE_CONSTEXPR_ARRAY_HELPERS
Print & operator<<(Print &os, Cable c)
A class for serial-in/parallel-out shift registers, like the 74HC595 that are connected to the SPI bu...
Utility class that acts as a functor to return incremental values.
Incrementor(T start=0, V increment=1)
Array< T, N > generateIncrementalArray(U start=0, V increment=V(1))
Generate an array where the first value is given, and the subsequent values are calculated as the pre...
Array< decltype(T1() *T2()), N1+N2 - 1 > distribute(const ArraySlice< T1, N1, Reverse1, Const1 > &a, const ArraySlice< T2, N2, Reverse2, Const2 > &b)
Array< T, N > copyAs(const Array< U, N > &src)
Copy an Array to an Array of a different type.
Array< T, N > fillArray(Args... args)
Fill the array with the same value for each element.
Array< decltype(F{}(U{})), N > apply(const Array< U, N > &src, F f)
Apply a function to all elements of the array and return a copy.
Array< T, N > generateArray(G generator)
Generate an array using the given generator.
Array< T, M+N > cat(const Array< T, M > &a, const Array< T, N > &b)
Concatenate two arrays.
An array wrapper for easy copying, comparing, and iterating.