[ox/std] Fix BString assign and compare
This commit is contained in:
parent
08899074cf
commit
9561a68483
13
deps/ox/src/ox/std/bstring.hpp
vendored
13
deps/ox/src/ox/std/bstring.hpp
vendored
@ -111,7 +111,7 @@ constexpr BString<size> &BString<size>::operator=(const char *str) noexcept {
|
||||
}
|
||||
ox_memcpy(m_buff, str, strLen);
|
||||
// make sure last element is a null terminator
|
||||
m_buff[cap() - 1] = 0;
|
||||
m_buff[cap()] = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -168,16 +168,7 @@ constexpr BString<size> BString<size>::operator+(Integer_c auto i) const noexcep
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr bool BString<buffLen>::operator==(const BString<buffLen> &other) const noexcept {
|
||||
bool retval = true;
|
||||
std::size_t i = 0;
|
||||
while (i < buffLen && (m_buff[i] || other.m_buff[i])) {
|
||||
if (m_buff[i] != other.m_buff[i]) {
|
||||
retval = false;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return retval;
|
||||
return ox::StringView(*this) == ox::StringView(other);
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
|
Loading…
Reference in New Issue
Block a user