[ox/std] Add comparison operators to String

This commit is contained in:
Gary Talent 2021-07-23 21:29:17 -05:00
parent 39b1292b91
commit 78d444c2e5

View File

@ -86,6 +86,14 @@ class BasicString {
bool operator!=(const BasicString &other) const noexcept;
bool operator<(const BasicString &other) const noexcept;
bool operator>(const BasicString &other) const noexcept;
bool operator<=(const BasicString &other) const noexcept;
bool operator>=(const BasicString &other) const noexcept;
char operator[](std::size_t i) const noexcept;
char &operator[](std::size_t i) noexcept;
@ -350,6 +358,26 @@ bool BasicString<SmallStringSize>::operator!=(const BasicString &other) const no
return !operator==(other);
}
template<std::size_t SmallStringSize>
bool BasicString<SmallStringSize>::operator<(const BasicString &other) const noexcept {
return ox_strcmp(c_str(), other.c_str()) < 0;
}
template<std::size_t SmallStringSize>
bool BasicString<SmallStringSize>::operator>(const BasicString &other) const noexcept {
return ox_strcmp(c_str(), other.c_str()) > 0;
}
template<std::size_t SmallStringSize>
bool BasicString<SmallStringSize>::operator<=(const BasicString &other) const noexcept {
return ox_strcmp(c_str(), other.c_str()) < 1;
}
template<std::size_t SmallStringSize>
bool BasicString<SmallStringSize>::operator>=(const BasicString &other) const noexcept {
return ox_strcmp(c_str(), other.c_str()) > -1;
}
template<std::size_t SmallStringSize>
char BasicString<SmallStringSize>::operator[](std::size_t i) const noexcept {
return m_buff[i];