[ox/std] Make substr support CStringView, and always return a StringView
This commit is contained in:
parent
232a166833
commit
fc5e63a4d7
4
deps/ox/src/ox/std/strops.hpp
vendored
4
deps/ox/src/ox/std/strops.hpp
vendored
@ -20,7 +20,7 @@ namespace ox {
|
|||||||
|
|
||||||
template<OxString_c Str>
|
template<OxString_c Str>
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr Str substr(Str const&str, std::size_t pos) noexcept {
|
constexpr ox::StringView substr(Str const&str, std::size_t pos) noexcept {
|
||||||
if (str.len() >= pos) {
|
if (str.len() >= pos) {
|
||||||
return Str(str.data() + pos, str.len() - pos);
|
return Str(str.data() + pos, str.len() - pos);
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ constexpr Str substr(Str const&str, std::size_t pos) noexcept {
|
|||||||
|
|
||||||
template<OxString_c Str>
|
template<OxString_c Str>
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr Str substr(Str const&str, std::size_t start, std::size_t end) noexcept {
|
constexpr ox::StringView substr(Str const&str, std::size_t start, std::size_t end) noexcept {
|
||||||
if (str.len() >= start && end >= start) {
|
if (str.len() >= start && end >= start) {
|
||||||
return Str(str.data() + start, end - start);
|
return Str(str.data() + start, end - start);
|
||||||
}
|
}
|
||||||
|
5
deps/ox/src/ox/std/typetraits.hpp
vendored
5
deps/ox/src/ox/std/typetraits.hpp
vendored
@ -273,6 +273,7 @@ template<std::size_t SmallStringSize>
|
|||||||
class BasicString;
|
class BasicString;
|
||||||
template<std::size_t sz>
|
template<std::size_t sz>
|
||||||
class BString;
|
class BString;
|
||||||
|
class CStringView;
|
||||||
class StringLiteral;
|
class StringLiteral;
|
||||||
class StringView;
|
class StringView;
|
||||||
|
|
||||||
@ -292,6 +293,10 @@ constexpr auto isOxString(const BString<sz>*) noexcept {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr auto isOxString(const CStringView*) noexcept {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr auto isOxString(const StringLiteral*) noexcept {
|
constexpr auto isOxString(const StringLiteral*) noexcept {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user