|
|
|
|
|
by uecker
378 days ago
|
|
In this case, the generic span type is just
#define span(T) struct CONCAT(span_, T) { ssize_t N; T* data; }
And the array to span macro would just create such an object form an array by storing the length of the array and the address of the first element.
#define array2span(T, x) ({ auto __y = &(x); (span(T)){ array_lengthof(__y), &(__y)[0] }; }) |
|