19template <
typename T,
size_t N>
class array {
36 explicit array(
const T &value) {
38 fill_n(
data_, N, value);
96 bool empty() const noexcept {
return N == 0; }
117 static T empty_value;
124template <
typename T,
size_t N>
127 for (
size_t i = 0; i < N; ++i) {
128 if (lhs[i] != rhs[i]) {
134template <
typename T,
size_t N>
136 return !(lhs == rhs);
139template <
typename T,
size_t N>
141 array<T, N> &rhs)
noexcept(
noexcept(lhs.swap(rhs))) {
155#ifndef FASTLED_VARIABLE_LENGTH_ARRAY_NEEDS_EMULATION
156#if defined(__clang__) || defined(ARDUINO_GIGA_M7) || defined(ARDUINO_GIGA)
161#define FASTLED_VARIABLE_LENGTH_ARRAY_NEEDS_EMULATION 1
164#define FASTLED_VARIABLE_LENGTH_ARRAY_NEEDS_EMULATION 0
168#if !FASTLED_VARIABLE_LENGTH_ARRAY_NEEDS_EMULATION
169#define FASTLED_STACK_ARRAY(TYPE, NAME, SIZE) \
171 memset(NAME, 0, sizeof(TYPE) * (SIZE))
172#elif __has_include(<alloca.h>)
174#define FASTLED_STACK_ARRAY(TYPE, NAME, SIZE) \
175 TYPE *NAME = reinterpret_cast<TYPE *>(alloca(sizeof(TYPE) * (SIZE))); \
176 memset(NAME, 0, sizeof(TYPE) * (SIZE))
177#elif __has_include(<cstdlib>)
179#define FASTLED_STACK_ARRAY(TYPE, NAME, SIZE) \
180 TYPE *NAME = reinterpret_cast<TYPE *>(alloca(sizeof(TYPE) * (SIZE))); \
181 memset(NAME, 0, sizeof(TYPE) * (SIZE))
183#error "Compiler does not allow variable type arrays."
const_reference operator[](size_type pos) const
ptrdiff_t difference_type
const_pointer const_iterator
bool empty() const noexcept
size_type size() const noexcept
array & operator=(array &&)=default
array(const array &)=default
size_type max_size() const noexcept
const value_type * const_pointer
const_iterator end() const noexcept
const value_type & const_reference
void fill(const T &value)
T & operator[](size_type pos)
array & operator=(const array &)=default
iterator begin() noexcept
const T & at(size_type pos) const
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)
bool operator==(const array< T, N > &lhs, const array< T, N > &rhs)
Implements a simple red square effect for 2D LED grids.