mirror of
https://github.com/skyline-emu/skyline.git
synced 2025-01-01 10:05:29 +03:00
Add Nullability for Optional Semantics to span
Nullability allow for optional semantics where a span may be explicitly invalidated with `nullptr` being used as a sentinel value for it and a boolean operator that allows trivial checking for if the span is valid or not.
This commit is contained in:
parent
c11962e8e4
commit
97cfcba0da
@ -27,6 +27,8 @@ namespace skyline {
|
|||||||
*/
|
*/
|
||||||
constexpr span(T &spn) : std::span<T, Extent>(&spn, 1) {}
|
constexpr span(T &spn) : std::span<T, Extent>(&spn, 1) {}
|
||||||
|
|
||||||
|
constexpr span(nullptr_t) : std::span<T, Extent>() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief We want to support implicitly casting from std::string_view -> span as it's just a specialization of a data view which span is a generic form of, the opposite doesn't hold true as not all data held by a span is string data therefore the conversion isn't implicit there
|
* @brief We want to support implicitly casting from std::string_view -> span as it's just a specialization of a data view which span is a generic form of, the opposite doesn't hold true as not all data held by a span is string data therefore the conversion isn't implicit there
|
||||||
*/
|
*/
|
||||||
@ -84,6 +86,13 @@ namespace skyline {
|
|||||||
return this->begin() <= other.begin() && this->end() >= other.end();
|
return this->begin() <= other.begin() && this->end() >= other.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return If the span is valid by not being null
|
||||||
|
*/
|
||||||
|
constexpr bool valid() {
|
||||||
|
return this->data() != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/** Comparision operators for equality and binary searches **/
|
/** Comparision operators for equality and binary searches **/
|
||||||
|
|
||||||
constexpr bool operator==(const span<T, Extent>& other) const {
|
constexpr bool operator==(const span<T, Extent>& other) const {
|
||||||
|
Loading…
Reference in New Issue
Block a user