27template <
typename T, fl::size N>
class array {
44 explicit array(
const T &value) {
46 fill_n(
data_, N, value);
50 array(fl::initializer_list<T> list) {
52 for (
auto it = list.begin(); it != list.end() && i < N; ++it, ++i) {
77 const T &
at(fl::size
pos)
const {
112 bool empty() const noexcept {
return N == 0; }
114 fl::size
size() const noexcept {
return N; }
120 for (fl::size i = 0; i < N; ++i) {
126 for (fl::size i = 0; i < N; ++i) {
133 static T empty_value;
140template <
typename T, fl::size N>
143 for (fl::size i = 0; i < N; ++i) {
144 if (lhs[i] != rhs[i]) {
150template <
typename T, fl::size N>
152 return !(lhs == rhs);
155template <
typename T, fl::size N>
157 array<T, N> &rhs)
noexcept(
noexcept(lhs.swap(rhs))) {
171#ifndef FASTLED_VARIABLE_LENGTH_ARRAY_NEEDS_EMULATION
172#if defined(__clang__) || defined(ARDUINO_GIGA_M7) || defined(ARDUINO_GIGA)
177#define FASTLED_VARIABLE_LENGTH_ARRAY_NEEDS_EMULATION 1
180#define FASTLED_VARIABLE_LENGTH_ARRAY_NEEDS_EMULATION 0
184#if !FASTLED_VARIABLE_LENGTH_ARRAY_NEEDS_EMULATION
185#define FASTLED_STACK_ARRAY(TYPE, NAME, SIZE) \
187 fl::memfill(NAME, 0, sizeof(TYPE) * (SIZE))
188#elif __has_include(<alloca.h>)
190#define FASTLED_STACK_ARRAY(TYPE, NAME, SIZE) \
191 TYPE *NAME = fl::bit_cast_ptr<TYPE>(alloca(sizeof(TYPE) * (SIZE))); \
192 fl::memfill(NAME, 0, sizeof(TYPE) * (SIZE))
193#elif __has_include(<cstdlib>)
195#define FASTLED_STACK_ARRAY(TYPE, NAME, SIZE) \
196 TYPE *NAME = fl::bit_cast_ptr<TYPE>(alloca(sizeof(TYPE) * (SIZE))); \
197 fl::memfill(NAME, 0, sizeof(TYPE) * (SIZE))
199#error "Compiler does not allow variable type arrays."
fl::size max_size() const noexcept
ptrdiff_t difference_type
const_pointer const_iterator
const_reference operator[](fl::size pos) const
bool empty() const noexcept
array & operator=(array &&)=default
array(const array &)=default
T & operator[](fl::size pos)
const value_type * const_pointer
const_iterator end() const noexcept
array(fl::initializer_list< T > list)
const value_type & const_reference
void fill(const T &value)
array & operator=(const array &)=default
const T & at(fl::size pos) const
iterator begin() noexcept
fl::size size() const noexcept
const_iterator begin() const noexcept
const_pointer data() const noexcept
const_iterator cbegin() const noexcept
A fixed-size array implementation similar to std::array.
void swap(array< T, N > &lhs, array< T, N > &rhs) noexcept(noexcept(lhs.swap(rhs)))
bool operator!=(const array< T, N > &lhs, const array< T, N > &rhs)
__PTRDIFF_TYPE__ ptrdiff_t
bool operator==(const array< T, N > &lhs, const array< T, N > &rhs)