FastLED 3.10.6
Loading...
Searching...
No Matches
span.h
Go to the documentation of this file.
1#pragma once
2
3
4#include "fl/math/math.h"
5#include "fl/math/geometry.h"
6#include "fl/stl/bit_cast.h"
9#include "fl/stl/int.h"
10#include "fl/stl/noexcept.h"
11
12namespace fl {
13
14namespace detail {
16}
17
18template <typename T, fl::size INLINED_SIZE> class FixedVector;
19
20template <typename T> class vector;
21
22template <typename T, fl::size INLINED_SIZE> class VectorN;
23
24// Backward compat alias
25template <typename T, fl::size INLINED_SIZE> using InlinedVector = VectorN<T, INLINED_SIZE>;
26
27template <typename T, fl::size N> class array;
28
29// Special value to indicate dynamic extent (runtime-determined size)
30constexpr fl::size dynamic_extent = fl::size(-1);
31
32// Forward declaration for static extent specialization
33template <typename T, fl::size Extent = dynamic_extent> class span;
34
35// ======= SFINAE TRAITS FOR GENERIC CONTAINER SUPPORT =======
36// Detect if a type has .data() method
37template <typename T>
39 private:
40 typedef fl::u8 yes;
41 typedef fl::u16 no;
42
43 template <typename C>
44 static yes test(decltype(&C::data)) FL_NO_EXCEPT;
45
46 template <typename>
47 static no test(...) FL_NO_EXCEPT;
48
49 public:
50 static constexpr bool value = sizeof(test<T>(nullptr)) == sizeof(yes);
51};
52
53// Detect if a type has .size() method
54template <typename T>
56 private:
57 typedef fl::u8 yes;
58 typedef fl::u16 no;
59
60 template <typename C>
61 static yes test(decltype(&C::size)) FL_NO_EXCEPT;
62
63 template <typename>
64 static no test(...) FL_NO_EXCEPT;
65
66 public:
67 static constexpr bool value = sizeof(test<T>(nullptr)) == sizeof(yes);
68};
69
70// Combined check for containers with both .data() and .size()
71template <typename T>
75
76// span<int> is equivalent to int* with a length. It is used to pass around
77// arrays of integers with a length, without needing to pass around a separate
78// length parameter.
79// It works just like an array of objects, but it also knows its length.
80//
81// This is the dynamic extent specialization (Extent == dynamic_extent).
82template <typename T> class span<T, dynamic_extent> {
83 public:
84 // ======= STANDARD CONTAINER TYPE ALIASES =======
85 using element_type = T;
87 using size_type = fl::size;
88 using difference_type = fl::i32;
89 using pointer = T*;
90 using const_pointer = const T*;
91 using reference = T&;
92 using const_reference = const T&;
93 using iterator = T*;
94 using const_iterator = const T*;
95 using reverse_iterator = T*;
96 using const_reverse_iterator = const T*;
97
98 static constexpr fl::size extent = dynamic_extent;
99
100 // ======= CONSTRUCTORS =======
101 span() FL_NO_EXCEPT : mData(nullptr), mSize(0) {}
103
104 // ======= INITIALIZER LIST CONSTRUCTOR DELETED =======
105 // P2447R6 (C++26) adds span(initializer_list<T>) but the backing array is
106 // always a temporary, so storing a span from a braced-init-list is UB unless
107 // consumed in the same expression. Deleted to prevent dangling references.
108 span(fl::initializer_list<value_type> init) FL_NO_EXCEPT = delete;
109
110 // ======= CONTAINER CONSTRUCTORS =======
111 // Simple constructors that work for all cases
114
115 template <fl::size INLINED_SIZE>
118
119 template <fl::size INLINED_SIZE>
122
123 // Additional constructors for const conversion (U -> const U)
124 template<typename U>
127
128 template<typename U, fl::size INLINED_SIZE>
131
132 template<typename U, fl::size INLINED_SIZE>
135
136 // ======= NON-CONST CONTAINER CONVERSIONS =======
137 // Non-const versions for mutable spans
140
141 template <fl::size INLINED_SIZE>
144
145 template <fl::size INLINED_SIZE>
148
149 // ======= GENERIC CONTAINER CONSTRUCTOR =======
150 // Generic constructor for any container with .data() and .size()
151 // Uses SFINAE to only enable for appropriate containers
152 // This excludes span itself and already-specialized containers
153 template<typename Container>
160
161 // Const version for const containers
162 template<typename Container>
169
170 // ======= FL::ARRAY CONVERSIONS =======
171 // fl::array<T> -> span<T>
172 template <fl::size N>
174 : mData(arr.data()), mSize(N) {}
175
176 template <fl::size N>
178 : mData(arr.data()), mSize(N) {}
179
180 // fl::array<U> -> span<T> (for type conversions like U -> const U)
181 template <typename U, fl::size N>
183 : mData(arr.data()), mSize(N) {}
184
185 template <typename U, fl::size N>
187 : mData(arr.data()), mSize(N) {}
188
189 // ======= C-STYLE ARRAY CONVERSIONS =======
190 // T[] -> span<T>
191 template <fl::size ARRAYSIZE>
192 span(T (&array)[ARRAYSIZE]) FL_NO_EXCEPT
193 : mData(array), mSize(ARRAYSIZE) {}
194
195 // U[] -> span<T> (for type conversions like U -> const U)
196 template <typename U, fl::size ARRAYSIZE>
197 span(U (&array)[ARRAYSIZE]) FL_NO_EXCEPT
198 : mData(array), mSize(ARRAYSIZE) {}
199
200 // const U[] -> span<T> (for const arrays)
201 template <typename U, fl::size ARRAYSIZE>
202 span(const U (&array)[ARRAYSIZE]) FL_NO_EXCEPT
203 : mData(array), mSize(ARRAYSIZE) {}
204
205 // ======= ITERATOR CONVERSIONS =======
206 template <typename U>
214
215 template <typename Iterator>
216 span(Iterator begin, Iterator end,
218 nullptr) FL_NO_EXCEPT
219 : mData(begin == end ? nullptr : &(*begin)),
220 mSize(begin == end ? 0 : end - begin) {}
221
222 span(const span &other) FL_NO_EXCEPT : mData(other.mData), mSize(other.mSize) {}
223
225 mData = other.mData;
226 mSize = other.mSize;
227 return *this;
228 }
229
230 // Automatic promotion to const span<const T, dynamic_extent>
232
233 T &operator[](fl::size index) FL_NO_EXCEPT {
234 // No bounds checking in embedded environment
235 return mData[index];
236 }
237
238 const T &operator[](fl::size index) const FL_NO_EXCEPT {
239 // No bounds checking in embedded environment
240 return mData[index];
241 }
242
243 // ======= ITERATORS =======
247
251
255
259
260 // ======= SIZE AND ACCESS =======
261 fl::size length() const FL_NO_EXCEPT { return mSize; }
262 fl::size size() const FL_NO_EXCEPT { return mSize; }
263 fl::size size_bytes() const FL_NO_EXCEPT { return mSize * sizeof(T); }
264
265 const T *data() const FL_NO_EXCEPT { return mData; }
266 T *data() FL_NO_EXCEPT { return mData; }
267
268 // ======= SUBVIEWS =======
269 // Runtime-sized subviews (existing slice methods)
270 span<T, dynamic_extent> slice(fl::size start, fl::size end) const FL_NO_EXCEPT {
271 // No bounds checking in embedded environment
272 return span<T, dynamic_extent>(mData + start, end - start);
273 }
274
276 // No bounds checking in embedded environment
277 return span<T, dynamic_extent>(mData + start, mSize - start);
278 }
279
280 // std::span-compatible subspan (runtime version)
282 if (count == dynamic_extent) {
284 }
285 return span<T, dynamic_extent>(mData + offset, count);
286 }
287
288 // Compile-time sized first N elements - returns static extent span
289 template<fl::size N>
291 return span<T, N>(mData, N);
292 }
293
294 // Runtime-sized first count elements
296 return span<T, dynamic_extent>(mData, count);
297 }
298
299 // Compile-time sized last N elements - returns static extent span
300 template<fl::size N>
302 return span<T, N>(mData + mSize - N, N);
303 }
304
305 // Runtime-sized last count elements
307 return span<T, dynamic_extent>(mData + mSize - count, count);
308 }
309
310 // Compile-time sized subspan - returns static extent span
311 template<fl::size Offset, fl::size Count = dynamic_extent>
313 if (Count == dynamic_extent) {
314 return span<T, dynamic_extent>(mData + Offset, mSize - Offset);
315 }
316 return span<T, Count>(mData + Offset, Count);
317 }
318
319 // Find the first occurrence of a value in the slice
320 // Returns the index of the first occurrence if found, or fl::size(-1) if not
321 // found
322 fl::size find(const T &value) const FL_NO_EXCEPT {
323 for (fl::size i = 0; i < mSize; ++i) {
324 if (mData[i] == value) {
325 return i;
326 }
327 }
328 return fl::size(-1);
329 }
330
332 if (mSize == 0) {
333 return false;
334 }
335 ++mData;
336 --mSize;
337 return true;
338 }
339
341 if (mSize == 0) {
342 return false;
343 }
344 --mSize;
345 return true;
346 }
347
348 T &front() FL_NO_EXCEPT { return *mData; }
349
350 const T &front() const FL_NO_EXCEPT { return *mData; }
351
352 T &back() FL_NO_EXCEPT { return *(mData + mSize - 1); }
353
354 const T &back() const FL_NO_EXCEPT { return *(mData + mSize - 1); }
355
356 bool empty() const FL_NO_EXCEPT { return mSize == 0; }
357
358 // ======= COMPARISON OPERATORS =======
359 // Lexicographical comparison - compares element by element
361 if (mSize != other.mSize) return false;
362 for (fl::size i = 0; i < mSize; ++i) {
363 if (!(mData[i] == other.mData[i])) return false;
364 }
365 return true;
366 }
367
369 return !(*this == other);
370 }
371
373 fl::size min_size = mSize < other.mSize ? mSize : other.mSize;
374 for (fl::size i = 0; i < min_size; ++i) {
375 if (mData[i] < other.mData[i]) return true;
376 if (other.mData[i] < mData[i]) return false;
377 }
378 return mSize < other.mSize;
379 }
380
382 return !(other < *this);
383 }
384
386 return other < *this;
387 }
388
390 return !(*this < other);
391 }
392
393 private:
394 template <typename U>
395 static fl::size pointer_range_size(U *begin, U *end) FL_NO_EXCEPT {
396 if (end < begin) {
398 return 0;
399 }
400 return static_cast<fl::size>(end - begin);
401 }
402
404 fl::size mSize;
405};
406
407// ======= STATIC EXTENT SPECIALIZATION =======
408// span with compile-time known size (static extent)
409// This specialization stores size at compile-time, reducing runtime overhead
410template <typename T, fl::size Extent> class span {
411 public:
412 // ======= STANDARD CONTAINER TYPE ALIASES =======
413 using element_type = T;
415 using size_type = fl::size;
416 using difference_type = fl::i32;
417 using pointer = T*;
418 using const_pointer = const T*;
419 using reference = T&;
420 using const_reference = const T&;
421 using iterator = T*;
422 using const_iterator = const T*;
424 using const_reverse_iterator = const T*;
425
426 static constexpr fl::size extent = Extent;
427
428 // ======= CONSTRUCTORS =======
429 span() FL_NO_EXCEPT : mData(nullptr) {}
430 span(T *data, fl::size size) FL_NO_EXCEPT : mData(data) {
431 // In debug builds, could assert size == Extent
432 (void)size; // Suppress unused parameter warning
433 }
434
435 // Constructor from C-array with matching size
436 // Matches std::span: when the argument is an array of exactly Extent
437 // elements, size is known at compile time and no runtime length is
438 // required. See std::span<T, N>::span(std::type_identity_t<T>(&)[N]).
439 span(T (&array)[Extent]) FL_NO_EXCEPT : mData(array) {}
440
441 // Copy constructor
442 span(const span &other) FL_NO_EXCEPT : mData(other.mData) {}
443
445 mData = other.mData;
446 return *this;
447 }
448
449 // Automatic promotion to const span<const T, Extent>
450 operator span<const T, Extent>() const FL_NO_EXCEPT { return span<const T, Extent>(mData, Extent); }
451
452 // Conversion to dynamic extent
454
455 // ======= ELEMENT ACCESS =======
456 T &operator[](fl::size index) FL_NO_EXCEPT {
457 return mData[index];
458 }
459
460 const T &operator[](fl::size index) const FL_NO_EXCEPT {
461 return mData[index];
462 }
463
464 // ======= ITERATORS =======
468
469 iterator end() FL_NO_EXCEPT { return mData + Extent; }
470 const_iterator end() const FL_NO_EXCEPT { return mData + Extent; }
471 const_iterator cend() const FL_NO_EXCEPT { return mData + Extent; }
472
473 reverse_iterator rbegin() FL_NO_EXCEPT { return mData + Extent - 1; }
474 const_reverse_iterator rbegin() const FL_NO_EXCEPT { return mData + Extent - 1; }
475 const_reverse_iterator crbegin() const FL_NO_EXCEPT { return mData + Extent - 1; }
476
480
481 // ======= SIZE AND ACCESS =======
482 constexpr fl::size length() const FL_NO_EXCEPT { return Extent; }
483 constexpr fl::size size() const FL_NO_EXCEPT { return Extent; }
484 constexpr fl::size size_bytes() const FL_NO_EXCEPT { return Extent * sizeof(T); }
485
486 const T *data() const FL_NO_EXCEPT { return mData; }
487 T *data() FL_NO_EXCEPT { return mData; }
488
489 // ======= SUBVIEWS =======
490 // Compile-time sized first N elements
491 template<fl::size N>
493 return span<T, N>(mData, N);
494 }
495
496 // Runtime-sized first count elements
498 return span<T, dynamic_extent>(mData, count);
499 }
500
501 // Compile-time sized last N elements
502 template<fl::size N>
504 return span<T, N>(mData + Extent - N, N);
505 }
506
507 // Runtime-sized last count elements
509 return span<T, dynamic_extent>(mData + Extent - count, count);
510 }
511
512 // Compile-time sized subspan
513 template<fl::size Offset, fl::size Count = dynamic_extent>
515 if (Count == dynamic_extent) {
516 return span<T, Extent - Offset>(mData + Offset, Extent - Offset);
517 }
518 return span<T, Count>(mData + Offset, Count);
519 }
520
521 // Runtime subspan
523 if (count == dynamic_extent) {
524 return span<T, dynamic_extent>(mData + offset, Extent - offset);
525 }
526 return span<T, dynamic_extent>(mData + offset, count);
527 }
528
529 T &front() FL_NO_EXCEPT { return *mData; }
530 const T &front() const FL_NO_EXCEPT { return *mData; }
531
532 T &back() FL_NO_EXCEPT { return *(mData + Extent - 1); }
533 const T &back() const FL_NO_EXCEPT { return *(mData + Extent - 1); }
534
535 constexpr bool empty() const FL_NO_EXCEPT { return Extent == 0; }
536
537 // ======= COMPARISON OPERATORS =======
538 bool operator==(const span<T, Extent>& other) const FL_NO_EXCEPT {
539 for (fl::size i = 0; i < Extent; ++i) {
540 if (!(mData[i] == other.mData[i])) return false;
541 }
542 return true;
543 }
544
545 bool operator!=(const span<T, Extent>& other) const FL_NO_EXCEPT {
546 return !(*this == other);
547 }
548
549 bool operator<(const span<T, Extent>& other) const FL_NO_EXCEPT {
550 for (fl::size i = 0; i < Extent; ++i) {
551 if (mData[i] < other.mData[i]) return true;
552 if (other.mData[i] < mData[i]) return false;
553 }
554 return false; // Equal when all elements are equal
555 }
556
557 bool operator<=(const span<T, Extent>& other) const FL_NO_EXCEPT {
558 return !(other < *this);
559 }
560
561 bool operator>(const span<T, Extent>& other) const FL_NO_EXCEPT {
562 return other < *this;
563 }
564
565 bool operator>=(const span<T, Extent>& other) const FL_NO_EXCEPT {
566 return !(*this < other);
567 }
568
569 private:
571 // Note: No mSize member - size is known at compile-time via Extent
572};
573
574// ======= BYTE VIEW CONVERSION FUNCTIONS =======
575// Convert span to read-only byte view
576template<typename T, fl::size Extent>
577span<const fl::u8, (Extent == dynamic_extent) ? dynamic_extent : (Extent * sizeof(T))>
578as_bytes(const span<T, Extent>& s) FL_NO_EXCEPT {
579 if (Extent == dynamic_extent) {
582 s.size_bytes()
583 );
584 } else {
585 return span<const fl::u8, Extent * sizeof(T)>(
587 );
588 }
589}
590
591// Convert span to writable byte view
592template<typename T, fl::size Extent>
593span<fl::u8, (Extent == dynamic_extent) ? dynamic_extent : (Extent * sizeof(T))>
595 if (Extent == dynamic_extent) {
597 fl::bit_cast<fl::u8*>(s.data()),
598 s.size_bytes()
599 );
600 } else {
601 return span<fl::u8, Extent * sizeof(T)>(
602 fl::bit_cast<fl::u8*>(s.data())
603 );
604 }
605}
606
607template <typename T> class MatrixSlice {
608 public:
609 // represents a window into a matrix
610 // bottom-left and top-right corners are passed as plain ints
612 MatrixSlice(T *data, i32 dataWidth, i32 dataHeight,
613 i32 bottomLeftX, i32 bottomLeftY, i32 topRightX,
614 i32 topRightY)
615 FL_NO_EXCEPT : mData(data), mDataWidth(dataWidth), mDataHeight(dataHeight),
616 mBottomLeft{bottomLeftX, bottomLeftY},
617 mTopRight{topRightX, topRightY} {}
618
619 MatrixSlice(const MatrixSlice &other) FL_NO_EXCEPT = default;
621
622 // outputs a vec2 but takes x,y as inputs
623 vec2<i32> getParentCoord(i32 x_local, i32 y_local) const FL_NO_EXCEPT {
624 return {x_local + mBottomLeft.x, y_local + mBottomLeft.y};
625 }
626
627 vec2<i32> getLocalCoord(i32 x_world, i32 y_world) const FL_NO_EXCEPT {
628 // clamp to [mBottomLeft, mTopRight]
629 i32 x_clamped = fl::clamp(x_world, mBottomLeft.x, mTopRight.x);
630 i32 y_clamped = fl::clamp(y_world, mBottomLeft.y, mTopRight.y);
631 // convert to local
632 return {x_clamped - mBottomLeft.x, y_clamped - mBottomLeft.y};
633 }
634
635 // element access via (x,y)
636 T &operator()(i32 x, i32 y) FL_NO_EXCEPT { return at(x, y); }
637
638 // Add access like slice[y][x]
640 i32 parentRow = row + mBottomLeft.y;
641 return mData + parentRow * mDataWidth + mBottomLeft.x;
642 }
643
644 T &at(i32 x, i32 y) FL_NO_EXCEPT {
645 auto parent = getParentCoord(x, y);
646 return mData[parent.x + parent.y * mDataWidth];
647 }
648
649 const T &at(i32 x, i32 y) const FL_NO_EXCEPT {
650 auto parent = getParentCoord(x, y);
651 return mData[parent.x + parent.y * mDataWidth];
652 }
653
654 private:
655 T *mData = nullptr;
656 i32 mDataWidth = 0;
657 i32 mDataHeight = 0;
660};
661
662} // namespace fl
vec2< i32 > getParentCoord(i32 x_local, i32 y_local) const FL_NO_EXCEPT
Definition span.h:623
i32 mDataWidth
Definition span.h:656
T & at(i32 x, i32 y) FL_NO_EXCEPT
Definition span.h:644
vec2< i32 > mBottomLeft
Definition span.h:658
const T & at(i32 x, i32 y) const FL_NO_EXCEPT
Definition span.h:649
MatrixSlice & operator=(const MatrixSlice &other) FL_NO_EXCEPT=default
vec2< i32 > mTopRight
Definition span.h:659
T * operator[](i32 row) FL_NO_EXCEPT
Definition span.h:639
i32 mDataHeight
Definition span.h:657
MatrixSlice() FL_NO_EXCEPT=default
vec2< i32 > getLocalCoord(i32 x_world, i32 y_world) const FL_NO_EXCEPT
Definition span.h:627
MatrixSlice(const MatrixSlice &other) FL_NO_EXCEPT=default
T & operator()(i32 x, i32 y) FL_NO_EXCEPT
Definition span.h:636
A fixed-size array implementation similar to std::array.
Definition array.h:27
static no test(...) FL_NO_EXCEPT
static constexpr bool value
Definition span.h:50
static yes test(decltype(&C::data)) FL_NO_EXCEPT
static constexpr bool value
Definition span.h:67
static yes test(decltype(&C::size)) FL_NO_EXCEPT
static no test(...) FL_NO_EXCEPT
typename fl::remove_cv< T >::type value_type
Definition span.h:86
span(array< U, N > &arr) FL_NO_EXCEPT
Definition span.h:186
const T * const_reverse_iterator
Definition span.h:96
span() FL_NO_EXCEPT
Definition span.h:101
static constexpr fl::size extent
Definition span.h:98
span< T, N > first() const FL_NO_EXCEPT
Definition span.h:290
span(const span &other) FL_NO_EXCEPT
Definition span.h:222
span & operator=(const span &other) FL_NO_EXCEPT
Definition span.h:224
span(Container &c, typename fl::enable_if< has_data_and_size< Container >::value &&!fl::is_same< typename fl::decay< Container >::type, span< T, dynamic_extent > >::value &&!fl::is_base_of< span< T, dynamic_extent >, Container >::value >::type *=nullptr) FL_NO_EXCEPT
Definition span.h:154
span(const VectorN< T, INLINED_SIZE > &vector) FL_NO_EXCEPT
Definition span.h:120
const T * data() const FL_NO_EXCEPT
Definition span.h:265
span(const fl::vector< T > &vector) FL_NO_EXCEPT
Definition span.h:112
const_reverse_iterator rbegin() const FL_NO_EXCEPT
Definition span.h:253
span< T, N > last() const FL_NO_EXCEPT
Definition span.h:301
span< T, Count > subspan() const FL_NO_EXCEPT
Definition span.h:312
reverse_iterator rend() FL_NO_EXCEPT
Definition span.h:256
iterator end() FL_NO_EXCEPT
Definition span.h:248
span(const FixedVector< U, INLINED_SIZE > &vector) FL_NO_EXCEPT
Definition span.h:129
const_iterator end() const FL_NO_EXCEPT
Definition span.h:249
span(VectorN< T, INLINED_SIZE > &vector) FL_NO_EXCEPT
Definition span.h:146
span(const Container &c, typename fl::enable_if< has_data_and_size< Container >::value &&!fl::is_same< typename fl::decay< Container >::type, span< T, dynamic_extent > >::value &&!fl::is_base_of< span< T, dynamic_extent >, Container >::value >::type *=nullptr) FL_NO_EXCEPT
Definition span.h:163
bool operator!=(const span< T, dynamic_extent > &other) const FL_NO_EXCEPT
Definition span.h:368
span(fl::vector< T > &vector) FL_NO_EXCEPT
Definition span.h:138
const_reverse_iterator rend() const FL_NO_EXCEPT
Definition span.h:257
const_reverse_iterator crend() const FL_NO_EXCEPT
Definition span.h:258
span(T *data, fl::size size) FL_NO_EXCEPT
Definition span.h:102
T & operator[](fl::size index) FL_NO_EXCEPT
Definition span.h:233
span< T, dynamic_extent > first(fl::size count) const FL_NO_EXCEPT
Definition span.h:295
static fl::size pointer_range_size(U *begin, U *end) FL_NO_EXCEPT
Definition span.h:395
span(T(&array)[ARRAYSIZE]) FL_NO_EXCEPT
Definition span.h:192
const T & operator[](fl::size index) const FL_NO_EXCEPT
Definition span.h:238
span(const VectorN< U, INLINED_SIZE > &vector) FL_NO_EXCEPT
Definition span.h:133
const_iterator cbegin() const FL_NO_EXCEPT
Definition span.h:246
span(Iterator begin, Iterator end, typename fl::enable_if<!fl::is_pointer< Iterator >::value >::type *=nullptr) FL_NO_EXCEPT
Definition span.h:216
const T & front() const FL_NO_EXCEPT
Definition span.h:350
const_iterator begin() const FL_NO_EXCEPT
Definition span.h:245
T * data() FL_NO_EXCEPT
Definition span.h:266
reverse_iterator rbegin() FL_NO_EXCEPT
Definition span.h:252
T & back() FL_NO_EXCEPT
Definition span.h:352
span< T, dynamic_extent > slice(fl::size start, fl::size end) const FL_NO_EXCEPT
Definition span.h:270
bool operator<(const span< T, dynamic_extent > &other) const FL_NO_EXCEPT
Definition span.h:372
bool pop_back() FL_NO_EXCEPT
Definition span.h:340
span< T, dynamic_extent > slice(fl::size start) const FL_NO_EXCEPT
Definition span.h:275
const_iterator cend() const FL_NO_EXCEPT
Definition span.h:250
bool empty() const FL_NO_EXCEPT
Definition span.h:356
bool operator==(const span< T, dynamic_extent > &other) const FL_NO_EXCEPT
Definition span.h:360
span(const FixedVector< T, INLINED_SIZE > &vector) FL_NO_EXCEPT
Definition span.h:116
span(FixedVector< T, INLINED_SIZE > &vector) FL_NO_EXCEPT
Definition span.h:142
span(U *begin, U *end, typename fl::enable_if< fl::is_same< typename fl::remove_const< U >::type, typename fl::remove_const< T >::type >::value &&(!fl::is_const< U >::value||fl::is_const< T >::value)>::type *=nullptr) FL_NO_EXCEPT
Definition span.h:207
T & front() FL_NO_EXCEPT
Definition span.h:348
bool pop_front() FL_NO_EXCEPT
Definition span.h:331
span< T, dynamic_extent > last(fl::size count) const FL_NO_EXCEPT
Definition span.h:306
const_reverse_iterator crbegin() const FL_NO_EXCEPT
Definition span.h:254
bool operator<=(const span< T, dynamic_extent > &other) const FL_NO_EXCEPT
Definition span.h:381
span< T, dynamic_extent > subspan(fl::size offset, fl::size count=dynamic_extent) const FL_NO_EXCEPT
Definition span.h:281
span(U(&array)[ARRAYSIZE]) FL_NO_EXCEPT
Definition span.h:197
iterator begin() FL_NO_EXCEPT
Definition span.h:244
bool operator>=(const span< T, dynamic_extent > &other) const FL_NO_EXCEPT
Definition span.h:389
fl::size size_bytes() const FL_NO_EXCEPT
Definition span.h:263
span(array< T, N > &arr) FL_NO_EXCEPT
Definition span.h:177
fl::size find(const T &value) const FL_NO_EXCEPT
Definition span.h:322
span(const array< U, N > &arr) FL_NO_EXCEPT
Definition span.h:182
span(const fl::vector< U > &vector) FL_NO_EXCEPT
Definition span.h:125
fl::size length() const FL_NO_EXCEPT
Definition span.h:261
const T & back() const FL_NO_EXCEPT
Definition span.h:354
span(fl::initializer_list< value_type > init) FL_NO_EXCEPT=delete
span(const U(&array)[ARRAYSIZE]) FL_NO_EXCEPT
Definition span.h:202
span(const array< T, N > &arr) FL_NO_EXCEPT
Definition span.h:173
bool operator>(const span< T, dynamic_extent > &other) const FL_NO_EXCEPT
Definition span.h:385
fl::size size() const FL_NO_EXCEPT
Definition span.h:262
const_reverse_iterator crend() const FL_NO_EXCEPT
Definition span.h:479
reverse_iterator rbegin() FL_NO_EXCEPT
Definition span.h:473
const_iterator cend() const FL_NO_EXCEPT
Definition span.h:471
span< T, Count > subspan() const FL_NO_EXCEPT
Definition span.h:514
constexpr bool empty() const FL_NO_EXCEPT
Definition span.h:535
span< T, N > first() const FL_NO_EXCEPT
Definition span.h:492
const_iterator cbegin() const FL_NO_EXCEPT
Definition span.h:467
fl::size size_type
Definition span.h:415
T & reference
Definition span.h:419
const T & front() const FL_NO_EXCEPT
Definition span.h:530
T element_type
Definition span.h:413
span() FL_NO_EXCEPT
Definition span.h:429
const T * data() const FL_NO_EXCEPT
Definition span.h:486
const T & const_reference
Definition span.h:420
const T * const_iterator
Definition span.h:422
span< T, dynamic_extent > subspan(fl::size offset, fl::size count=dynamic_extent) const FL_NO_EXCEPT
Definition span.h:522
bool operator>(const span< T, Extent > &other) const FL_NO_EXCEPT
Definition span.h:561
const T * const_reverse_iterator
Definition span.h:424
T * data() FL_NO_EXCEPT
Definition span.h:487
fl::i32 difference_type
Definition span.h:416
T * pointer
Definition span.h:417
T & operator[](fl::size index) FL_NO_EXCEPT
Definition span.h:456
bool operator<=(const span< T, Extent > &other) const FL_NO_EXCEPT
Definition span.h:557
const_iterator begin() const FL_NO_EXCEPT
Definition span.h:466
span< T, dynamic_extent > last(fl::size count) const FL_NO_EXCEPT
Definition span.h:508
span(const span &other) FL_NO_EXCEPT
Definition span.h:442
T * iterator
Definition span.h:421
const_iterator end() const FL_NO_EXCEPT
Definition span.h:470
const_reverse_iterator crbegin() const FL_NO_EXCEPT
Definition span.h:475
bool operator>=(const span< T, Extent > &other) const FL_NO_EXCEPT
Definition span.h:565
const_reverse_iterator rend() const FL_NO_EXCEPT
Definition span.h:478
iterator end() FL_NO_EXCEPT
Definition span.h:469
reverse_iterator rend() FL_NO_EXCEPT
Definition span.h:477
span(T(&array)[Extent]) FL_NO_EXCEPT
Definition span.h:439
const T & operator[](fl::size index) const FL_NO_EXCEPT
Definition span.h:460
constexpr fl::size size() const FL_NO_EXCEPT
Definition span.h:483
T * mData
Definition span.h:570
const_reverse_iterator rbegin() const FL_NO_EXCEPT
Definition span.h:474
T & back() FL_NO_EXCEPT
Definition span.h:532
constexpr fl::size size_bytes() const FL_NO_EXCEPT
Definition span.h:484
span< T, N > last() const FL_NO_EXCEPT
Definition span.h:503
span & operator=(const span &other) FL_NO_EXCEPT
Definition span.h:444
T & front() FL_NO_EXCEPT
Definition span.h:529
span< T, dynamic_extent > first(fl::size count) const FL_NO_EXCEPT
Definition span.h:497
bool operator==(const span< T, Extent > &other) const FL_NO_EXCEPT
Definition span.h:538
const T & back() const FL_NO_EXCEPT
Definition span.h:533
static constexpr fl::size extent
Definition span.h:426
bool operator<(const span< T, Extent > &other) const FL_NO_EXCEPT
Definition span.h:549
const T * const_pointer
Definition span.h:418
iterator begin() FL_NO_EXCEPT
Definition span.h:465
T * reverse_iterator
Definition span.h:423
bool operator!=(const span< T, Extent > &other) const FL_NO_EXCEPT
Definition span.h:545
span(T *data, fl::size size) FL_NO_EXCEPT
Definition span.h:430
typename fl::remove_cv< T >::type value_type
Definition span.h:414
constexpr fl::size length() const FL_NO_EXCEPT
Definition span.h:482
fl::size size() const FL_NO_EXCEPT
T * data() FL_NO_EXCEPT
Definition vector.h:619
#define constexpr
Declares that it is possible to evaluate a value at compile time, introduced in C++11.
Definition cpp_compat.h:15
fl::UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
void span_invalid_pointer_range() FL_NO_EXCEPT
Definition span.cpp.hpp:10
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_info.h:57
unsigned char u8
Definition stdint.h:131
constexpr int type_rank< T >::value
VectorN< T, INLINED_SIZE > InlinedVector
Definition span.h:25
void init(Context &ctx, int w, int h)
Definition engine.h:133
span< fl::u8,(Extent==dynamic_extent) ? dynamic_extent :(Extent *sizeof(T))> as_writable_bytes(span< T, Extent > &s) FL_NO_EXCEPT
Definition span.h:594
constexpr enable_if< is_fixed_point< T >::value, T >::type clamp(T x, T lo, T hi) FL_NO_EXCEPT
span< const fl::u8,(Extent==dynamic_extent) ? dynamic_extent :(Extent *sizeof(T))> as_bytes(const span< T, Extent > &s) FL_NO_EXCEPT
Definition span.h:578
InputGamut g FL_NO_EXCEPT
Definition rgbw.h:121
constexpr fl::size dynamic_extent
Definition span.h:30
To bit_cast(const From &from) FL_NO_EXCEPT
Definition bit_cast.h:48
Base definition for an LED controller.
Definition crgb.hpp:179
typename conditional< is_array< U >::value, typename remove_extent< U >::type *, typename conditional< is_function< U >::value, typename add_pointer< U >::type, typename remove_cv< U >::type >::type >::type type
static constexpr bool value
Definition span.h:73