[ox/std] Add toStdStringView and endsWith functions
This commit is contained in:
parent
6cfa8dd40d
commit
55ea405a54
10
deps/ox/src/ox/std/stringview.hpp
vendored
10
deps/ox/src/ox/std/stringview.hpp
vendored
@ -8,6 +8,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef OX_USE_STDLIB
|
||||
#include <string_view>
|
||||
#endif
|
||||
|
||||
#include "iterator.hpp"
|
||||
#include "strops.hpp"
|
||||
#include "types.hpp"
|
||||
@ -264,6 +268,12 @@ constexpr bool endsWith(CRStringView base, CRStringView ending) noexcept {
|
||||
return base.len() >= endingLen && ox_strcmp(base.data() + (base.len() - endingLen), ending) == 0;
|
||||
}
|
||||
|
||||
#ifdef OX_USE_STDLIB
|
||||
constexpr auto toStdStringView(CRStringView sv) noexcept {
|
||||
return std::string_view(sv.data(), sv.bytes());
|
||||
}
|
||||
#endif
|
||||
|
||||
static_assert(StringView("Read").bytes() == 4);
|
||||
static_assert(StringView("Read") == StringView("Read"));
|
||||
static_assert(StringView("Read") != StringView("Write"));
|
||||
|
Loading…
Reference in New Issue
Block a user