util/StringView: add method substr()
This commit is contained in:
parent
d4135935e4
commit
a63d0ee8fc
|
@ -88,6 +88,19 @@ struct BasicStringView : ConstBuffer<T> {
|
||||||
using ConstBuffer<T>::pop_back;
|
using ConstBuffer<T>::pop_back;
|
||||||
using ConstBuffer<T>::skip_front;
|
using ConstBuffer<T>::skip_front;
|
||||||
|
|
||||||
|
constexpr BasicStringView<T> substr(size_type pos,
|
||||||
|
size_type count) const noexcept {
|
||||||
|
return {data + pos, count};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr BasicStringView<T> substr(size_type pos) const noexcept {
|
||||||
|
return {data + pos, size - pos};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr BasicStringView<T> substr(const char *start) const noexcept {
|
||||||
|
return {start, size_t(data + size - start)};
|
||||||
|
}
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
pointer Find(value_type ch) const noexcept {
|
pointer Find(value_type ch) const noexcept {
|
||||||
return StringFind(data, ch, this->size);
|
return StringFind(data, ch, this->size);
|
||||||
|
|
Loading…
Reference in New Issue