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