mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-04 23:55:08 +01: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(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
|
||||
*/
|
||||
@ -84,6 +86,13 @@ namespace skyline {
|
||||
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 **/
|
||||
|
||||
constexpr bool operator==(const span<T, Extent>& other) const {
|
||||
|
Loading…
Reference in New Issue
Block a user