sincerely
Singaporean
If you have not done so, read this full tutorial on how to use SGEXTN to build an application.
(no source file, everything inside header)
template ‹typename T› class SGLSpan;
part of SGEXTN module SG_Containers
span for any type of data
list of all including inherited members
preprocessor file inclusion directive: #include ‹SGLSpan.h›
CMake target for BuildLah: SGEXTN::SG_Containers
see this link for more information about BuildLah
parent class: (none)
children classes: (none)
SGLSpan(T* dataInternal, int lengthInternal);
[[nodiscard]] const T& at(int i) const;
[[nodiscard]] T& at(int i);
[[nodiscard]] int length() const;
[[nodiscard]] const T* pointerToData(int n) const;
[[nodiscard]] T* pointerToData(int n);
[[nodiscard]] SGLSpan subspan(int start, int length) const;
[[nodiscard]] SGLSpan subspanLeft(int length) const;
[[nodiscard]] SGLSpan subspanRight(int length) const;
SGLSpan provides a template based span that can be used with any data type. SGLSpan does not own the data that it allows access to. Deleting heap data accessed through SGLSpan is undefined behaviour in the form of double delete. This is a template based class with no separate source file.
SGLSpan stores a pointer to the start of the span and the number of elements in the span.
Creates a SGLSpan starting from dataInternal with a length of lengthInternal.
Negative lengthInternal will cause a crash.
dataInternal being nullptr will cause a crash.
If any memory between dataInternal (inclusive) and dataInternal + lengthInternal (exclusive) is not allocated, have been deleted, or if the 2 endpoints come from different data structures, creating the span is undefined behaviour.
Using the span in any way after the host data structure is deleted is undefined behaviour
To avoid undefined behaviour, do not allocate any SGLSpan on the heap.
Returns a constant reference to the element at index i of the SGLSpan.
If i is out of bounds, this causes a crash.
Returns a reference to the element at index i of the SGLSpan.
This returns a reference and not a copy. Assigning to the returned value (using it as a lvalue) modifies the host data structure.
If i is out of bounds, this causes a crash.
Returns the length of the SGLSpan.
This is constant after the creation of the SGLSpan.
Returns a read only pointer to the element at index n of the original span.
It is ok for n to be out of bounds as long as the returned pointer is not dereferenced. This can be done intentionally to define bounds for SGLSort.
The returned value may function as an iterator.
Dereferencing the returned pointer when n is out of bounds is undefined behaviour.
Returns a pointer to the element at index n of the original span.
It is ok for n to be out of bounds as long as the returned pointer is not dereferenced. This can be done intentionally to define bounds for SGLSort.
The returned value may function as an iterator.
Dereferencing the returned pointer when n is out of bounds is undefined behaviour.
Returns a subspan starting at index start of the original span with a length of length.
Negative length will crash.
If start or start + length - 1 is out of bounds, this will crash.
Returns a subspan containing the first length elements of the original span.
Negative length will crash.
If length is greater than the length of the span, this will crash.
Returns a subspan containing the last length elements of the original span.
Negative length will crash.
If length is greater than the length of the span, this will crash.
©2025 05524F.sg (Singapore)