tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
basic_string_view.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2#ifndef TETL_BASIC_STRING_VIEW_STRING_VIEW_HPP
3#define TETL_BASIC_STRING_VIEW_STRING_VIEW_HPP
4
14#include <etl/_iterator/end.hpp>
23#include <etl/_utility/swap.hpp>
24
25namespace etl {
26
33template <typename Char, typename Traits = etl::char_traits<Char>>
35 using traits_type = Traits;
36 using value_type = Char;
37 using pointer = Char*;
38 using const_pointer = Char const*;
39 using reference = Char&;
40 using const_reference = Char const&;
41 using const_iterator = Char const*;
47
50 constexpr basic_string_view() noexcept = default;
51
55 constexpr basic_string_view(basic_string_view const& other) noexcept = default;
56
63 constexpr basic_string_view(Char const* str, size_type size)
64 : _begin{str}
65 , _size{size}
66 {
67 }
68
74 constexpr basic_string_view(Char const* str)
75 : _begin{str}
76 , _size{traits_type::length(str)}
77 {
78 }
79
80 constexpr basic_string_view(nullptr_t /*null*/) = delete;
81
86 template <typename Iter>
87 requires(detail::RandomAccessIterator<Iter>)
88 constexpr basic_string_view(Iter first, Iter last)
89 : basic_string_view{first, static_cast<size_type>(last - first)}
90 {
91 }
92
93 ~basic_string_view() noexcept = default;
94
96 constexpr auto operator=(basic_string_view const& view) noexcept -> basic_string_view& = default;
97
99 [[nodiscard]] constexpr auto begin() const noexcept -> const_iterator { return cbegin(); }
100
102 [[nodiscard]] constexpr auto cbegin() const noexcept -> const_iterator { return _begin; }
103
107 [[nodiscard]] constexpr auto end() const noexcept -> const_iterator { return cend(); }
108
112 [[nodiscard]] constexpr auto cend() const noexcept -> const_iterator { return _begin + _size; }
113
116 [[nodiscard]] constexpr auto rbegin() const noexcept -> const_reverse_iterator { return crbegin(); }
117
120 [[nodiscard]] constexpr auto crbegin() const noexcept -> const_reverse_iterator
121 {
122 return const_reverse_iterator(end());
123 }
124
131 [[nodiscard]] constexpr auto rend() const noexcept -> const_reverse_iterator { return crend(); }
132
139 [[nodiscard]] constexpr auto crend() const noexcept -> const_reverse_iterator
140 {
142 }
143
146 [[nodiscard]] constexpr auto operator[](size_type pos) const -> const_reference
147 {
148 TETL_PRECONDITION(pos < size());
149 return unsafe_at(pos);
150 }
151
154 [[nodiscard]] constexpr auto front() const -> const_reference
155 {
157 return unsafe_at(0);
158 }
159
162 [[nodiscard]] constexpr auto back() const -> const_reference
163 {
165 return unsafe_at(_size - 1);
166 }
167
171 [[nodiscard]] constexpr auto data() const noexcept -> const_pointer { return _begin; }
172
174 [[nodiscard]] constexpr auto size() const noexcept -> size_type { return length(); }
175
177 [[nodiscard]] constexpr auto length() const noexcept -> size_type { return _size; }
178
181 [[nodiscard]] constexpr auto max_size() const noexcept -> size_type { return size_type(-1); }
182
184 [[nodiscard]] constexpr auto empty() const noexcept -> bool { return _size == 0; }
185
188 constexpr auto remove_prefix(size_type n) -> void
189 {
190 TETL_PRECONDITION(n <= size());
191 _begin += n;
192 _size -= n;
193 }
194
197 constexpr auto remove_suffix(size_type n) -> void
198 {
199 TETL_PRECONDITION(n <= size());
200 _size = _size - n;
201 }
202
204 constexpr auto swap(basic_string_view& v) noexcept -> void
205 {
206 etl::swap(_begin, v._begin);
207 etl::swap(_size, v._size);
208 }
209
213 [[nodiscard]] constexpr auto copy(Char* dest, size_type count, size_type pos = 0) const -> size_type
214 {
215 TETL_PRECONDITION(pos <= size());
216 auto const rcount = etl::min(count, size() - pos);
217 traits_type::copy(dest, data() + pos, rcount);
218 return rcount;
219 }
220
223 [[nodiscard]] constexpr auto substr(size_type pos = 0, size_type count = npos) const -> basic_string_view
224 {
225 TETL_PRECONDITION(pos <= size());
226 auto const rcount = etl::min(count, size() - pos);
227 return basic_string_view{_begin + pos, rcount};
228 }
229
233 [[nodiscard]] constexpr auto compare(basic_string_view v) const noexcept -> int
234 {
235 auto const rlen = etl::min(size(), v.size());
236 auto const res = traits_type::compare(data(), v.data(), rlen);
237
238 if (res < 0) {
239 return -1;
240 }
241 if (res > 0) {
242 return 1;
243 }
244
245 if (size() < v.size()) {
246 return -1;
247 }
248 if (size() > v.size()) {
249 return 1;
250 }
251
252 return 0;
253 }
254
256 [[nodiscard]] constexpr auto compare(size_type pos1, size_type count1, basic_string_view v) const -> int
257 {
258 return substr(pos1, count1).compare(v);
259 }
260
262 [[nodiscard]] constexpr auto
263 compare(size_type pos1, size_type count1, basic_string_view v, size_type pos2, size_type count2) const -> int
264 {
265 return substr(pos1, count1).compare(v.substr(pos2, count2));
266 }
267
269 [[nodiscard]] constexpr auto compare(Char const* s) const -> int { return compare(basic_string_view(s)); }
270
272 [[nodiscard]] constexpr auto compare(size_type pos1, size_type count1, Char const* s) const -> int
273 {
274 return substr(pos1, count1).compare(basic_string_view(s));
275 }
276
278 [[nodiscard]] constexpr auto compare(size_type pos1, size_type count1, Char const* s, size_type count2) const -> int
279 {
280 return substr(pos1, count1).compare(basic_string_view(s, count2));
281 }
282
286 [[nodiscard]] constexpr auto starts_with(basic_string_view sv) const noexcept -> bool
287 {
288 return substr(0, sv.size()) == sv;
289 }
290
294 [[nodiscard]] constexpr auto starts_with(Char c) const noexcept -> bool
295 {
296 return !empty() && traits_type::eq(front(), c);
297 }
298
303 [[nodiscard]] constexpr auto starts_with(Char const* str) const -> bool
304 {
305 return starts_with(basic_string_view(str));
306 }
307
313 [[nodiscard]] constexpr auto ends_with(basic_string_view sv) const noexcept -> bool
314 {
315 return size() >= sv.size() && compare(size() - sv.size(), npos, sv) == 0;
316 }
317
322 [[nodiscard]] constexpr auto ends_with(Char c) const noexcept -> bool { return !empty() && Traits::eq(back(), c); }
323
328 constexpr auto ends_with(Char const* str) const -> bool { return ends_with(basic_string_view(str)); }
329
335 [[nodiscard]] constexpr auto find(basic_string_view v, size_type pos = 0) const noexcept -> size_type
336 {
337 if (v.size() > size() - pos) {
338 return npos;
339 }
340
341 for (size_type outerIdx = pos; outerIdx < size(); ++outerIdx) {
342 if (unsafe_at(outerIdx) == v.front()) {
343 auto found = [&] {
344 for (size_type innerIdx = 0; innerIdx < v.size(); ++innerIdx) {
345 auto offset = outerIdx + innerIdx;
346 if (unsafe_at(offset) != v[innerIdx]) {
347 return false;
348 }
349 }
350
351 return true;
352 }();
353
354 if (found) {
355 return outerIdx;
356 }
357 }
358 }
359
360 return npos;
361 }
362
368 [[nodiscard]] constexpr auto find(Char ch, size_type pos = 0) const noexcept -> size_type
369 {
370 return find(basic_string_view(&ch, 1), pos);
371 }
372
378 constexpr auto find(Char const* s, size_type pos, size_type count) const -> size_type
379 {
380 return find(basic_string_view(s, count), pos);
381 }
382
388 constexpr auto find(Char const* s, size_type pos = 0) const -> size_type { return find(basic_string_view(s), pos); }
389
395 [[nodiscard]] constexpr auto rfind(basic_string_view sv, size_type pos = npos) const noexcept -> size_type
396 {
397 pos = etl::min(pos, size());
398 if (sv.size() < size() - pos) {
399 pos += sv.size();
400 } else {
401 pos = size();
402 }
403
404 auto const* r = etl::find_end(data(), data() + pos, sv.begin(), sv.end(), Traits::eq);
405 if (sv.size() > 0 && r == data() + pos) {
406 return npos;
407 }
408 return static_cast<size_type>(r - data());
409 }
410
416 [[nodiscard]] constexpr auto rfind(Char c, size_type pos = npos) const noexcept -> size_type
417 {
418 if (size() < 1) {
419 return npos;
420 }
421
422 if (pos < size()) {
423 ++pos;
424 } else {
425 pos = size();
426 }
427 for (auto const* s = data() + pos; s != data();) {
428 if (Traits::eq(*--s, c)) {
429 return static_cast<size_type>(s - data());
430 }
431 }
432 return npos;
433 }
434
440 constexpr auto rfind(Char const* s, size_type pos, size_type count) const noexcept -> size_type
441 {
442 return rfind({s, count}, pos);
443 }
444
450 constexpr auto rfind(Char const* s, size_type pos = npos) const noexcept -> size_type
451 {
452 return rfind({s, traits_type::length(s)}, pos);
453 }
454
461 [[nodiscard]] constexpr auto find_first_of(basic_string_view v, size_type pos = 0) const noexcept -> size_type
462 {
463 for (size_type idx = pos; idx < size(); ++idx) {
464 for (auto const c : v) {
465 if (c == unsafe_at(idx)) {
466 return idx;
467 }
468 }
469 }
470
471 return npos;
472 }
473
480 [[nodiscard]] constexpr auto find_first_of(Char c, size_type pos = 0) const noexcept -> size_type
481 {
482 return find_first_of(basic_string_view(&c, 1), pos);
483 }
484
491 constexpr auto find_first_of(Char const* s, size_type pos, size_type count) const -> size_type
492 {
493 return find_first_of(basic_string_view(s, count), pos);
494 }
495
502 constexpr auto find_first_of(Char const* s, size_type pos = 0) const -> size_type
503 {
504 return find_first_of(basic_string_view(s), pos);
505 }
506
512 [[nodiscard]] constexpr auto find_first_not_of(basic_string_view sv, size_type pos = 0) const noexcept -> size_type
513 {
514 auto const* str = data();
515 if (pos < size()) {
516 auto const* last = str + size();
517 for (auto const* s = str + pos; s != last; ++s) {
518 if (Traits::find(sv.data(), sv.size(), *s) == nullptr) {
519 return static_cast<size_type>(s - str);
520 }
521 }
522 }
523 return npos;
524 }
525
531 [[nodiscard]] constexpr auto find_first_not_of(Char c, size_type pos = 0) const noexcept -> size_type
532 {
533 if (pos < size()) {
534 auto const* last = data() + size();
535 for (auto const* s = data() + pos; s != last; ++s) {
536 if (!Traits::eq(*s, c)) {
537 return static_cast<size_type>(s - data());
538 }
539 }
540 }
541 return npos;
542 }
543
549 [[nodiscard]] constexpr auto find_first_not_of(Char const* s, size_type pos, size_type count) const -> size_type
550 {
551 return find_first_not_of({s, count}, pos);
552 }
553
559 [[nodiscard]] constexpr auto find_first_not_of(Char const* s, size_type pos = 0) const -> size_type
560 {
561 return find_first_not_of({s, traits_type::length(s)}, pos);
562 }
563
572 [[nodiscard]] constexpr auto find_last_of(basic_string_view v, size_type pos = npos) const noexcept -> size_type
573 {
574 auto offset = etl::clamp<size_type>(pos, 0, size() - 1);
575 do { // NOLINT(cppcoreguidelines-avoid-do-while)
576 auto const current = unsafe_at(offset);
577 for (auto const ch : v) {
578 if (ch == current) {
579 return offset;
580 }
581 }
582 } while (offset-- != 0);
583
584 return npos;
585 }
586
595 [[nodiscard]] constexpr auto find_last_of(Char c, size_type pos = npos) const noexcept -> size_type
596 {
597 return find_last_of(basic_string_view(&c, 1), pos);
598 }
599
608 constexpr auto find_last_of(Char const* s, size_type pos, size_type count) const -> size_type
609 {
610 return find_last_of(basic_string_view(s, count), pos);
611 }
612
621 constexpr auto find_last_of(Char const* s, size_type pos = npos) const -> size_type
622 {
623 return find_last_of(basic_string_view(s), pos);
624 }
625
631 [[nodiscard]] constexpr auto find_last_not_of(basic_string_view v, size_type pos = npos) const noexcept -> size_type
632 {
633 auto offset = etl::clamp<size_type>(pos, 0, size() - 1);
634 do { // NOLINT(cppcoreguidelines-avoid-do-while)
635 auto equals = [&](auto ch) { return ch == unsafe_at(offset); };
636 if (etl::none_of(v.begin(), v.end(), equals)) {
637 return offset;
638 }
639 } while (offset-- != 0);
640
641 return npos;
642 }
643
650 [[nodiscard]] constexpr auto find_last_not_of(Char c, size_type pos = npos) const noexcept -> size_type
651 {
652 return find_last_not_of(basic_string_view(&c, 1), pos);
653 }
654
661 [[nodiscard]] constexpr auto find_last_not_of(const_pointer s, size_type pos, size_type count) const -> size_type
662 {
664 }
665
672 [[nodiscard]] constexpr auto find_last_not_of(const_pointer s, size_type pos = npos) const -> size_type
673 {
674 return find_last_not_of(basic_string_view(s), pos);
675 }
676
678 [[nodiscard]] constexpr auto contains(basic_string_view sv) const noexcept -> bool { return find(sv) != npos; }
679
681 [[nodiscard]] constexpr auto contains(Char c) const noexcept -> bool { return find(c) != npos; }
682
684 [[nodiscard]] constexpr auto contains(Char const* s) const -> bool { return find(s) != npos; }
685
693 static constexpr size_type npos = size_type(-1);
694
695private:
696 [[nodiscard]] constexpr auto unsafe_at(size_type pos) const -> const_reference { return _begin[pos]; }
697
698 const_pointer _begin = nullptr;
699 size_type _size = 0;
700};
701
705
709
713
717
721
722inline namespace literals {
723inline namespace string_view_literals {
724
726[[nodiscard]] constexpr auto operator""_sv(char const* str, etl::size_t len) noexcept -> etl::string_view
727{
728 return {str, len};
729}
730
732[[nodiscard]] constexpr auto operator""_sv(wchar_t const* str, etl::size_t len) noexcept -> etl::wstring_view
733{
734 return {str, len};
735}
736
738[[nodiscard]] constexpr auto operator""_sv(char8_t const* str, etl::size_t len) noexcept -> etl::u8string_view
739{
740 return {str, len};
741}
742
744[[nodiscard]] constexpr auto operator""_sv(char16_t const* str, etl::size_t len) noexcept -> etl::u16string_view
745{
746 return {str, len};
747}
748
750[[nodiscard]] constexpr auto operator""_sv(char32_t const* str, etl::size_t len) noexcept -> etl::u32string_view
751{
752 return {str, len};
753}
754
755} // namespace string_view_literals
756} // namespace literals
757
758namespace ranges {
759
760template <typename Char, typename Traits>
762
763} // namespace ranges
764
771template <typename Char, typename Traits>
772[[nodiscard]] constexpr auto
774{
775 if (lhs.size() != rhs.size()) {
776 return false;
777 }
778 return lhs.compare(rhs) == 0;
779}
780
787template <typename Char, typename Traits>
788[[nodiscard]] constexpr auto
790{
791 return lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
792}
793
794template <typename Char, typename Traits, int = 1>
795[[nodiscard]] constexpr auto
797{
798 return lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
799}
800
801template <typename Char, typename Traits, int = 2>
802[[nodiscard]] constexpr auto
804{
805 return lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
806}
807
814template <typename Char, typename Traits>
815[[nodiscard]] constexpr auto
817{
818 return (lhs < rhs) or (lhs == rhs);
819}
820
821template <typename Char, typename Traits, int = 1>
822[[nodiscard]] constexpr auto
824{
825 return (lhs < rhs) or (lhs == rhs);
826}
827
828template <typename Char, typename Traits, int = 2>
829[[nodiscard]] constexpr auto
831{
832 return (lhs < rhs) or (lhs == rhs);
833}
834
841template <typename Char, typename Traits>
842[[nodiscard]] constexpr auto
844{
845 return !(lhs < rhs) and !(lhs == rhs);
846}
847
848template <typename Char, typename Traits, int = 1>
849[[nodiscard]] constexpr auto
851{
852 return !(lhs < rhs) and !(lhs == rhs);
853}
854
855template <typename Char, typename Traits, int = 2>
856[[nodiscard]] constexpr auto
858{
859 return !(lhs < rhs) and !(lhs == rhs);
860}
861
868template <typename Char, typename Traits>
869[[nodiscard]] constexpr auto
871{
872 return lhs > rhs or lhs == rhs;
873}
874
875template <typename Char, typename Traits, int = 1>
876[[nodiscard]] constexpr auto
878{
879 return lhs > rhs or lhs == rhs;
880}
881
882template <typename Char, typename Traits, int = 2>
883[[nodiscard]] constexpr auto
885{
886 return lhs > rhs or lhs == rhs;
887}
888
889} // namespace etl
890
891#endif // TETL_BASIC_STRING_VIEW_STRING_VIEW_HPP
#define TETL_PRECONDITION(...)
Definition check.hpp:16
constexpr auto clamp(Type const &v, Type const &lo, Type const &hi, Compare comp) -> Type const &
If v compares less than lo, returns lo; otherwise if hi compares less than v, returns hi; otherwise r...
Definition clamp.hpp:17
constexpr auto min(Type const &a, Type const &b, Compare comp) noexcept -> Type const &
Returns the smaller of a and b, using a compare function.
Definition min.hpp:13
constexpr auto none_of(InputIt first, InputIt last, Predicate p) -> bool
Checks if unary predicate p returns true for no elements in the range [first, last).
Definition none_of.hpp:13
constexpr auto find_end(ForwardIt1 first, ForwardIt1 last, ForwardIt2 sFirst, ForwardIt2 sLast, Predicate p) -> ForwardIt1
Searches for the last occurrence of the sequence [sFirst, sLast) in the range [first,...
Definition find_end.hpp:25
constexpr auto lexicographical_compare(InputIt1 f1, InputIt1 l1, InputIt2 f2, InputIt2 l2, Compare comp) -> bool
Checks if the first range [f1, l1) is lexicographically less than the second range [f2,...
Definition lexicographical_compare.hpp:17
constexpr auto count(InputIt first, InputIt last, T const &value) -> typename iterator_traits< InputIt >::difference_type
Returns the number of elements in the range [first, last) satisfying specific criteria....
Definition count.hpp:21
constexpr auto size(C const &c) noexcept(noexcept(c.size())) -> decltype(c.size())
Returns the size of the given container c or array array. Returns c.size(), converted to the return t...
Definition size.hpp:18
constexpr bool enable_borrowed_range
Definition enable_borrowed_range.hpp:10
basic_string_view< char32_t, etl::char_traits< char32_t > > u32string_view
Typedef for common character type char32_t
Definition basic_string_view.hpp:720
basic_string_view< char, etl::char_traits< char > > string_view
Typedef for common character type char
Definition basic_string_view.hpp:704
basic_string_view< char16_t, etl::char_traits< char16_t > > u16string_view
Typedef for common character type char16_t
Definition basic_string_view.hpp:716
basic_string_view< wchar_t, etl::char_traits< wchar_t > > wstring_view
Typedef for common character type wchar_t
Definition basic_string_view.hpp:708
basic_string_view< char8_t, etl::char_traits< char8_t > > u8string_view
Typedef for common character type char8_t
Definition basic_string_view.hpp:712
typename type_identity< T >::type type_identity_t
Definition type_identity.hpp:16
Definition basic_string_view.hpp:723
Definition day.hpp:116
Definition ranges_in_fun_result.hpp:11
Definition adjacent_find.hpp:8
constexpr auto operator==(inplace_function< R(Args...), Capacity, Alignment > const &f, nullptr_t) noexcept -> bool
Compares a etl::inplace_function with a null pointer. Empty functions (that is, functions without a c...
Definition inplace_function.hpp:262
constexpr auto operator<(etl::reverse_iterator< Iter1 > const &lhs, etl::reverse_iterator< Iter2 > const &rhs) -> bool
Compares the underlying iterators. Inverse comparisons are applied in order to take into account that...
Definition reverse_iterator.hpp:167
TETL_BUILTIN_PTRDIFF ptrdiff_t
etl::ptrdiff_t is the signed integer type of the result of subtracting two pointers.
Definition ptrdiff_t.hpp:14
constexpr auto operator<=(etl::reverse_iterator< Iter1 > const &lhs, etl::reverse_iterator< Iter2 > const &rhs) -> bool
Compares the underlying iterators. Inverse comparisons are applied in order to take into account that...
Definition reverse_iterator.hpp:177
auto swap(inplace_function< R(Args...), Capacity, Alignment > &lhs, inplace_function< R(Args...), Capacity, Alignment > &rhs) noexcept -> void
Overloads the etl::swap algorithm for etl::inplace_function. Exchanges the state of lhs with that of ...
Definition inplace_function.hpp:249
constexpr auto operator>(etl::reverse_iterator< Iter1 > const &lhs, etl::reverse_iterator< Iter2 > const &rhs) -> bool
Compares the underlying iterators. Inverse comparisons are applied in order to take into account that...
Definition reverse_iterator.hpp:185
constexpr auto operator>=(etl::reverse_iterator< Iter1 > const &lhs, etl::reverse_iterator< Iter2 > const &rhs) -> bool
Compares the underlying iterators. Inverse comparisons are applied in order to take into account that...
Definition reverse_iterator.hpp:195
TETL_BUILTIN_SIZET size_t
etl::size_t is the unsigned integer type of the result of the sizeof operator.
Definition size_t.hpp:14
decltype(nullptr) nullptr_t
etl::nullptr_t is the type of the null pointer literal, nullptr. It is a distinct type that is not it...
Definition nullptr_t.hpp:13
The class template basic_string_view describes an object that can refer to a constant contiguous sequ...
Definition basic_string_view.hpp:34
constexpr auto compare(size_type pos1, size_type count1, Char const *s) const -> int
Compares two character sequences. Equivalent to substr(pos1, count1).compare(basic_string_view(s)).
Definition basic_string_view.hpp:272
CharT * pointer
Definition basic_string_view.hpp:37
constexpr auto compare(size_type pos1, size_type count1, Char const *s, size_type count2) const -> int
Compares two character sequences. Equivalent to substr(pos1, count1).compare(basic_string_view(s,...
Definition basic_string_view.hpp:278
constexpr auto ends_with(Char const *str) const -> bool
Checks if the string view ends with the given suffix, where the the prefix is a null-terminated chara...
Definition basic_string_view.hpp:328
const_reverse_iterator reverse_iterator
Definition basic_string_view.hpp:46
constexpr auto rfind(Char const *s, size_type pos=npos) const noexcept -> size_type
Finds the last substring equal to the given character sequence. Equivalent to rfind(basic_string_view...
Definition basic_string_view.hpp:450
constexpr auto back() const -> const_reference
Returns reference to the last character in the view.
Definition basic_string_view.hpp:162
constexpr auto compare(Char const *s) const -> int
Compares two character sequences. Equivalent to compare(basic_string_view(s)).
Definition basic_string_view.hpp:269
constexpr auto find_first_of(Char const *s, size_type pos=0) const -> size_type
Finds the first character equal to any of the characters in the given character sequence....
Definition basic_string_view.hpp:502
static constexpr size_type npos
Definition basic_string_view.hpp:693
etl::ptrdiff_t difference_type
Definition basic_string_view.hpp:44
constexpr auto find_first_not_of(basic_string_view sv, size_type pos=0) const noexcept -> size_type
Finds the first character not equal to any of the characters in the given character sequence.
Definition basic_string_view.hpp:512
constexpr auto rfind(basic_string_view sv, size_type pos=npos) const noexcept -> size_type
Finds the last substring equal to the given character sequence. Finds the last occurence of v in this...
Definition basic_string_view.hpp:395
~basic_string_view() noexcept=default
etl::size_t size_type
Definition basic_string_view.hpp:43
constexpr auto crbegin() const noexcept -> const_reverse_iterator
Returns a reverse iterator to the first character of the reversed view. It corresponds to the last ch...
Definition basic_string_view.hpp:120
constexpr auto rfind(Char const *s, size_type pos, size_type count) const noexcept -> size_type
Finds the last substring equal to the given character sequence. Equivalent to rfind(basic_string_view...
Definition basic_string_view.hpp:440
etl::reverse_iterator< const_iterator > const_reverse_iterator
Definition basic_string_view.hpp:45
CharT const & const_reference
Definition basic_string_view.hpp:40
constexpr auto starts_with(Char const *str) const -> bool
Checks if the string view begins with the given prefix, where the the prefix is a null-terminated cha...
Definition basic_string_view.hpp:303
constexpr auto find(Char const *s, size_type pos=0) const -> size_type
Finds the first substring equal to the given character sequence. Equivalent to find(basic_string_view...
Definition basic_string_view.hpp:388
constexpr auto rbegin() const noexcept -> const_reverse_iterator
Returns a reverse iterator to the first character of the reversed view. It corresponds to the last ch...
Definition basic_string_view.hpp:116
constexpr auto copy(Char *dest, size_type count, size_type pos=0) const -> size_type
Copies the substring [pos, pos + rcount) to the character array pointed to by dest,...
Definition basic_string_view.hpp:213
constexpr auto find_last_of(Char const *s, size_type pos, size_type count) const -> size_type
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string_view.hpp:608
constexpr auto find(Char ch, size_type pos=0) const noexcept -> size_type
Finds the first substring equal to the given character sequence. Equivalent to find(basic_string_view...
Definition basic_string_view.hpp:368
constexpr auto compare(size_type pos1, size_type count1, basic_string_view v) const -> int
Compares two character sequences. Equivalent to substr(pos1, count1).compare(v).
Definition basic_string_view.hpp:256
constexpr auto find(basic_string_view v, size_type pos=0) const noexcept -> size_type
Finds the first substring equal to the given character sequence. Finds the first occurence of v in th...
Definition basic_string_view.hpp:335
constexpr auto find_last_of(Char const *s, size_type pos=npos) const -> size_type
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string_view.hpp:621
constexpr auto find_first_not_of(Char const *s, size_type pos, size_type count) const -> size_type
Finds the first character not equal to any of the characters in the given character sequence.
Definition basic_string_view.hpp:549
constexpr auto find_last_not_of(const_pointer s, size_type pos=npos) const -> size_type
Finds the last character not equal to any of the characters in the given character sequence....
Definition basic_string_view.hpp:672
constexpr auto find_last_not_of(Char c, size_type pos=npos) const noexcept -> size_type
Finds the last character not equal to any of the characters in the given character sequence....
Definition basic_string_view.hpp:650
constexpr auto contains(basic_string_view sv) const noexcept -> bool
Checks if the string contains the given substring.
Definition basic_string_view.hpp:678
constexpr auto rfind(Char c, size_type pos=npos) const noexcept -> size_type
Finds the last substring equal to the given character sequence. Equivalent to rfind(basic_string_view...
Definition basic_string_view.hpp:416
constexpr auto find_last_not_of(const_pointer s, size_type pos, size_type count) const -> size_type
Finds the last character not equal to any of the characters in the given character sequence....
Definition basic_string_view.hpp:661
constexpr auto ends_with(Char c) const noexcept -> bool
Checks if the string view ends with the given suffix, where the prefix is a single character.
Definition basic_string_view.hpp:322
constexpr basic_string_view(nullptr_t)=delete
constexpr basic_string_view() noexcept=default
Default constructor. Constructs an empty basic_string_view. After construction, data() is equal to nu...
etl::char_traits< CharT > traits_type
Definition basic_string_view.hpp:35
constexpr auto compare(basic_string_view v) const noexcept -> int
Compares two character sequences.
Definition basic_string_view.hpp:233
constexpr auto begin() const noexcept -> const_iterator
Definition basic_string_view.hpp:99
constexpr auto cbegin() const noexcept -> const_iterator
Returns an iterator to the first character of the view.
Definition basic_string_view.hpp:102
constexpr auto contains(Char c) const noexcept -> bool
Checks if the string contains the given substring.
Definition basic_string_view.hpp:681
CharT const * const_pointer
Definition basic_string_view.hpp:38
constexpr basic_string_view(Iter first, Iter last)
Constructs a basic_string_view over the range [first, last). The behavior is undefined if [first,...
Definition basic_string_view.hpp:88
constexpr auto contains(Char const *s) const -> bool
Checks if the string contains the given substring.
Definition basic_string_view.hpp:684
constexpr auto front() const -> const_reference
Returns reference to the first character in the view.
Definition basic_string_view.hpp:154
constexpr auto empty() const noexcept -> bool
Checks if the view has no characters, i.e. whether size() == 0.
Definition basic_string_view.hpp:184
constexpr auto compare(size_type pos1, size_type count1, basic_string_view v, size_type pos2, size_type count2) const -> int
Compares two character sequences. Equivalent to substr(pos1, count1).compare(v.substr(pos2,...
Definition basic_string_view.hpp:263
constexpr auto starts_with(basic_string_view sv) const noexcept -> bool
Checks if the string view begins with the given prefix, where the prefix is a string view.
Definition basic_string_view.hpp:286
CharT & reference
Definition basic_string_view.hpp:39
constexpr auto substr(size_type pos=0, size_type count=npos) const -> basic_string_view
Returns a view of the substring [pos, pos + rcount), where rcount is the smaller of count and size() ...
Definition basic_string_view.hpp:223
constexpr auto remove_suffix(size_type n) -> void
Moves the end of the view back by n characters.
Definition basic_string_view.hpp:197
constexpr auto find_last_of(Char c, size_type pos=npos) const noexcept -> size_type
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string_view.hpp:595
constexpr auto find(Char const *s, size_type pos, size_type count) const -> size_type
Finds the first substring equal to the given character sequence. Equivalent to find(basic_string_view...
Definition basic_string_view.hpp:378
constexpr auto find_last_of(basic_string_view v, size_type pos=npos) const noexcept -> size_type
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string_view.hpp:572
constexpr auto length() const noexcept -> size_type
Definition basic_string_view.hpp:177
constexpr auto find_first_of(Char const *s, size_type pos, size_type count) const -> size_type
Finds the first character equal to any of the characters in the given character sequence....
Definition basic_string_view.hpp:491
CharT const * const_iterator
Definition basic_string_view.hpp:41
const_iterator iterator
Definition basic_string_view.hpp:42
constexpr auto swap(basic_string_view &v) noexcept -> void
Exchanges the view with that of v.
Definition basic_string_view.hpp:204
constexpr auto max_size() const noexcept -> size_type
The largest possible number of char-like objects that can be referred to by a basic_string_view.
Definition basic_string_view.hpp:181
constexpr basic_string_view(Char const *str)
Constructs a view of the null-terminated character string pointed to by s, not including the terminat...
Definition basic_string_view.hpp:74
constexpr auto end() const noexcept -> const_iterator
Returns an iterator to the character following the last character of the view. This character acts as...
Definition basic_string_view.hpp:107
constexpr auto remove_prefix(size_type n) -> void
Moves the start of the view forward by n characters.
Definition basic_string_view.hpp:188
constexpr auto starts_with(Char c) const noexcept -> bool
Checks if the string view begins with the given prefix, where the prefix is a single character.
Definition basic_string_view.hpp:294
constexpr auto operator[](size_type pos) const -> const_reference
Returns a const reference to the character at specified location pos.
Definition basic_string_view.hpp:146
constexpr auto find_first_not_of(Char const *s, size_type pos=0) const -> size_type
Finds the first character not equal to any of the characters in the given character sequence.
Definition basic_string_view.hpp:559
constexpr auto find_last_not_of(basic_string_view v, size_type pos=npos) const noexcept -> size_type
Finds the last character not equal to any of the characters of v in this view, starting at position p...
Definition basic_string_view.hpp:631
constexpr auto find_first_of(Char c, size_type pos=0) const noexcept -> size_type
Finds the first character equal to any of the characters in the given character sequence....
Definition basic_string_view.hpp:480
constexpr auto crend() const noexcept -> const_reverse_iterator
Returns a reverse iterator to the character following the last character of the reversed view.
Definition basic_string_view.hpp:139
constexpr auto ends_with(basic_string_view sv) const noexcept -> bool
Checks if the string view ends with the given suffix, where the prefix is a string view.
Definition basic_string_view.hpp:313
constexpr auto find_first_of(basic_string_view v, size_type pos=0) const noexcept -> size_type
Finds the first character equal to any of the characters in the given character sequence....
Definition basic_string_view.hpp:461
constexpr auto data() const noexcept -> const_pointer
Returns a pointer to the underlying character array. The pointer is such that the range [data(); data...
Definition basic_string_view.hpp:171
constexpr auto rend() const noexcept -> const_reverse_iterator
Returns a reverse iterator to the character following the last character of the reversed view.
Definition basic_string_view.hpp:131
CharT value_type
Definition basic_string_view.hpp:36
constexpr auto size() const noexcept -> size_type
Definition basic_string_view.hpp:174
constexpr auto cend() const noexcept -> const_iterator
Returns an iterator to the character following the last character of the view. This character acts as...
Definition basic_string_view.hpp:112
constexpr auto find_first_not_of(Char c, size_type pos=0) const noexcept -> size_type
Finds the first character not equal to any of the characters in the given character sequence.
Definition basic_string_view.hpp:531
reverse_iterator is an iterator adaptor that reverses the direction of a given iterator....
Definition reverse_iterator.hpp:22