28template <
typename T, fl::size N>
class array {
45 explicit array(
const T &value) {
47 fill_n(
data_, N, value);
51 array(fl::initializer_list<T> list) {
53 for (
auto it = list.begin(); it != list.end() && i < N; ++it, ++i) {
78 const T &
at(fl::size
pos)
const {
113 bool empty() const noexcept {
return N == 0; }
115 fl::size
size() const noexcept {
return N; }
121 for (fl::size i = 0; i < N; ++i) {
127 for (fl::size i = 0; i < N; ++i) {
134 static T empty_value;
141template <
typename T, fl::size N>
144 for (fl::size i = 0; i < N; ++i) {
145 if (lhs[i] != rhs[i]) {
151template <
typename T, fl::size N>
153 return !(lhs == rhs);
156template <
typename T, fl::size N>
158 array<T, N> &rhs)
noexcept(
noexcept(lhs.swap(rhs))) {
172#ifndef FASTLED_VARIABLE_LENGTH_ARRAY_NEEDS_EMULATION
173#if defined(__clang__) || defined(ARDUINO_GIGA_M7) || defined(ARDUINO_GIGA)
178#define FASTLED_VARIABLE_LENGTH_ARRAY_NEEDS_EMULATION 1
181#define FASTLED_VARIABLE_LENGTH_ARRAY_NEEDS_EMULATION 0
185#if !FASTLED_VARIABLE_LENGTH_ARRAY_NEEDS_EMULATION
186#define FASTLED_STACK_ARRAY(TYPE, NAME, SIZE) \
188 fl::memfill(NAME, 0, sizeof(TYPE) * (SIZE))
189#elif FL_HAS_INCLUDE(<alloca.h>)
191#define FASTLED_STACK_ARRAY(TYPE, NAME, SIZE) \
192 TYPE *NAME = fl::bit_cast_ptr<TYPE>(alloca(sizeof(TYPE) * (SIZE))); \
193 fl::memfill(NAME, 0, sizeof(TYPE) * (SIZE))
194#elif FL_HAS_INCLUDE(<cstdlib>)
196#define FASTLED_STACK_ARRAY(TYPE, NAME, SIZE) \
197 TYPE *NAME = fl::bit_cast_ptr<TYPE>(alloca(sizeof(TYPE) * (SIZE))); \
198 fl::memfill(NAME, 0, sizeof(TYPE) * (SIZE))
200#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)