[ox/std] Add lastIndexOf(StringView, char)
This commit is contained in:
parent
3f83a254d2
commit
5cbf789374
11
deps/ox/src/ox/std/strops.hpp
vendored
11
deps/ox/src/ox/std/strops.hpp
vendored
@ -132,4 +132,15 @@ constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, CRStringVi
|
||||
return out;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr ox::Result<std::size_t> lastIndexOf(ox::CRStringView str, int character) noexcept {
|
||||
ox::Result<std::size_t> retval = OxError(1, "Character not found");
|
||||
for (auto i = static_cast<int>(str.bytes() - 1); i >= 0; --i) {
|
||||
if (str[static_cast<std::size_t>(i)] == character) {
|
||||
retval = static_cast<std::size_t>(i);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user