Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
cstring_view.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <helios/assert.hpp>
4
5#include <algorithm>
6#include <compare>
7#include <cstddef>
8#include <format>
9#include <iostream>
10#include <iterator>
11#include <string>
12#include <string_view>
13
14namespace helios {
15
16/**
17 * @brief A view of a null-terminated C string.
18 * @tparam CharT Character type
19 * @tparam Traits Character traits type
20 */
21template <typename CharT, typename Traits = std::char_traits<CharT>>
23public:
24 using traits_type = Traits;
25 using value_type = CharT;
26 using pointer = const CharT*;
27 using const_pointer = const CharT*;
28 using reference = const CharT&;
29 using const_reference = const CharT&;
30 using iterator = const CharT*;
31 using const_iterator = const CharT*;
32 using reverse_iterator = std::reverse_iterator<iterator>;
33 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
34 using size_type = size_t;
35 using difference_type = ptrdiff_t;
36
37 static constexpr size_type npos = static_cast<size_type>(-1);
38
39 BasicCStringView() = delete;
40
41 /**
42 * @brief Constructs from a string.
43 * @param string Source string
44 */
45 constexpr explicit BasicCStringView(
46 const std::basic_string<CharT, Traits>& string) noexcept
47 : size_(string.size()), data_(string.data()) {}
48
49 /**
50 * @brief Constructs from a null-terminated C string.
51 * @param str Source C string
52 */
53 constexpr BasicCStringView(const CharT* str) noexcept
54 : size_(std::char_traits<CharT>::length(str)), data_(str) {}
55
56 BasicCStringView(std::nullptr_t) = delete;
57 constexpr BasicCStringView(const BasicCStringView&) noexcept = default;
58 constexpr BasicCStringView(BasicCStringView&&) noexcept = default;
59 constexpr ~BasicCStringView() noexcept = default;
60
61 constexpr BasicCStringView& operator=(const BasicCStringView&) noexcept =
62 default;
63 constexpr BasicCStringView& operator=(BasicCStringView&&) noexcept = default;
64
65 /**
66 * @brief Assigns a `std::basic_string`.
67 * @param string String to assign
68 * @return Reference to this
69 */
71 const std::basic_string<CharT, Traits>& string) noexcept;
72
73 /**
74 * @brief Assigns a null-terminated C string.
75 * @param str C string to assign
76 * @return Reference to this
77 */
78 constexpr BasicCStringView& Assign(const CharT* str) noexcept;
79
80 /**
81 * @brief Copies characters to a buffer.
82 * @warning Triggers assertion if `pos > Size()`.
83 * @param dest Destination buffer
84 * @param count Maximum number of characters to copy
85 * @param pos Starting position
86 * @return Number of characters copied
87 */
88 constexpr size_type Copy(CharT* dest, size_type count,
89 size_type pos = 0) const noexcept;
90
91 /**
92 * @brief Swaps contents with another `BasicCStringView`.
93 * @param other String to swap with
94 */
95 constexpr void Swap(BasicCStringView& other) noexcept;
96 friend constexpr void swap(BasicCStringView& lhs,
97 BasicCStringView& rhs) noexcept {
98 lhs.Swap(rhs);
99 }
100
101 /**
102 * @brief Compares with another string.
103 * @param other String to compare with
104 * @return Negative if less, zero if equal, positive if greater
105 */
106 [[nodiscard]] constexpr int Compare(
107 std::basic_string_view<CharT, Traits> other) const noexcept {
108 return View().compare(other);
109 }
110
111 /**
112 * @brief Compares with another c string view.
113 * @param other C string view to compare with
114 * @return Negative if less, zero if equal, positive if greater
115 */
116 [[nodiscard]] constexpr int Compare(
117 BasicCStringView<CharT, Traits> other) const noexcept {
118 return View().compare(other.View());
119 }
120
121 /**
122 * @brief Finds first occurrence of substring.
123 * @param sv Substring to search for
124 * @param pos Starting position
125 * @return Position of first occurrence, or `npos` if not found
126 */
127 [[nodiscard]] constexpr size_type Find(
128 std::basic_string_view<CharT, Traits> sv,
129 size_type pos = 0) const noexcept {
130 return View().find(sv, pos);
131 }
132
133 /**
134 * @brief Finds first occurrence of character.
135 * @param ch Character to search for
136 * @param pos Starting position
137 * @return Position of first occurrence, or `npos` if not found
138 */
139 [[nodiscard]] constexpr size_type Find(CharT ch,
140 size_type pos = 0) const noexcept {
141 return View().find(ch, pos);
142 }
143
144 /**
145 * @brief Finds last occurrence of substring.
146 * @param sv Substring to search for
147 * @param pos Starting position (searches backwards from here)
148 * @return Position of last occurrence, or `npos` if not found
149 */
150 [[nodiscard]] constexpr size_type RFind(
151 std::basic_string_view<CharT, Traits> sv,
152 size_type pos = npos) const noexcept {
153 return View().rfind(sv, pos);
154 }
155
156 /**
157 * @brief Finds last occurrence of character.
158 * @param ch Character to search for
159 * @param pos Starting position (searches backwards from here)
160 * @return Position of last occurrence, or `npos` if not found
161 */
162 [[nodiscard]] constexpr size_type RFind(CharT ch,
163 size_type pos = npos) const noexcept {
164 return View().rfind(ch, pos);
165 }
166
167 /**
168 * @brief Finds first occurrence of any character in sv.
169 * @param sv Characters to search for
170 * @param pos Starting position
171 * @return Position of first occurrence, or `npos` if not found
172 */
173 [[nodiscard]] constexpr size_type FindFirstOf(
174 std::basic_string_view<CharT, Traits> sv,
175 size_type pos = 0) const noexcept {
176 return View().find_first_of(sv, pos);
177 }
178
179 /**
180 * @brief Finds last occurrence of any character in sv.
181 * @param sv Characters to search for
182 * @param pos Starting position (searches backwards from here)
183 * @return Position of last occurrence, or `npos` if not found
184 */
185 [[nodiscard]] constexpr size_type FindLastOf(
186 std::basic_string_view<CharT, Traits> sv,
187 size_type pos = npos) const noexcept {
188 return View().find_last_of(sv, pos);
189 }
190
191 /**
192 * @brief Finds first character not in sv.
193 * @param sv Characters to exclude
194 * @param pos Starting position
195 * @return Position of first non-matching character, or `npos` if not found
196 */
197 [[nodiscard]] constexpr size_type FindFirstNotOf(
198 std::basic_string_view<CharT, Traits> sv,
199 size_type pos = 0) const noexcept {
200 return View().find_first_not_of(sv, pos);
201 }
202
203 /**
204 * @brief Finds last character not in sv.
205 * @param sv Characters to exclude
206 * @param pos Starting position (searches backwards from here)
207 * @return Position of last non-matching character, or `npos` if not found
208 */
209 [[nodiscard]] constexpr size_type FindLastNotOf(
210 std::basic_string_view<CharT, Traits> sv,
211 size_type pos = npos) const noexcept {
212 return View().find_last_not_of(sv, pos);
213 }
214
215 /**
216 * @brief Accesses character at specified position.
217 * @warning Triggers assertion if `pos >= Size()`.
218 * @param pos Position of the character
219 * @return Reference to the character
220 */
221 [[nodiscard]] constexpr reference operator[](size_type pos) noexcept;
222
223 /**
224 * @brief Accesses character at specified position (const).
225 * @warning Triggers assertion if `pos >= Size()`.
226 * @param pos Position of the character
227 * @return Const reference to the character
228 */
229 [[nodiscard]] constexpr const_reference operator[](
230 size_type pos) const noexcept;
231
232 /**
233 * @brief Assigns a `std::basic_string`.
234 * @param string String to assign
235 * @return Reference to this
236 */
238 const std::basic_string<CharT, Traits>& string) noexcept;
239
240 /**
241 * @brief Assigns a null-terminated C string.
242 * @param str C string to assign
243 * @return Reference to this
244 */
245 constexpr BasicCStringView& operator=(const CharT* str) noexcept;
246
247 /**
248 * @brief Converts to `std::basic_string_view`.
249 * @return String view of the content
250 */
251 [[nodiscard]] constexpr operator std::basic_string_view<CharT, Traits>()
252 const noexcept {
253 return std::basic_string_view<CharT, Traits>(data_, size_);
254 }
255
256 [[nodiscard]] constexpr auto operator<=>(
257 BasicCStringView<CharT, Traits> other) const noexcept
258 -> std::strong_ordering;
259
260 [[nodiscard]] constexpr auto operator<=>(
261 std::basic_string_view<CharT, Traits> other) const noexcept
262 -> std::strong_ordering;
263
264 /**
265 * @brief Checks if the string is empty.
266 * @return True if `Size() == 0`
267 */
268 [[nodiscard]] constexpr bool Empty() const noexcept { return size_ == 0; }
269
270 /**
271 * @brief Checks if string starts with prefix.
272 * @param sv Prefix to check
273 * @return True if string starts with sv
274 */
275 [[nodiscard]] constexpr bool StartsWith(
276 std::basic_string_view<CharT, Traits> sv) const noexcept {
277 return View().starts_with(sv);
278 }
279
280 /**
281 * @brief Checks if string starts with character.
282 * @param ch Character to check
283 * @return True if string starts with ch
284 */
285 [[nodiscard]] constexpr bool StartsWith(CharT ch) const noexcept {
286 return !Empty() && Front() == ch;
287 }
288
289 /**
290 * @brief Checks if string ends with suffix.
291 * @param sv Suffix to check
292 * @return True if string ends with sv
293 */
294 [[nodiscard]] constexpr bool EndsWith(
295 std::basic_string_view<CharT, Traits> sv) const noexcept {
296 return View().ends_with(sv);
297 }
298
299 /**
300 * @brief Checks if string ends with character.
301 * @param ch Character to check
302 * @return True if string ends with ch
303 */
304 [[nodiscard]] constexpr bool EndsWith(CharT ch) const noexcept {
305 return !Empty() && Back() == ch;
306 }
307
308 /**
309 * @brief Checks if string contains substring.
310 * @param sv Substring to search for
311 * @return True if string contains sv
312 */
313 [[nodiscard]] constexpr bool Contains(
314 std::basic_string_view<CharT, Traits> sv) const noexcept {
315 return View().find(sv) != npos;
316 }
317
318 /**
319 * @brief Checks if string contains character.
320 * @param ch Character to search for
321 * @return True if string contains ch
322 */
323 [[nodiscard]] constexpr bool Contains(CharT ch) const noexcept {
324 return View().find(ch) != npos;
325 }
326
327 /**
328 * @brief Returns the number of characters.
329 * @return Number of characters (excluding null terminator)
330 */
331 [[nodiscard]] constexpr size_type Size() const noexcept { return size_; }
332
333 /**
334 * @brief Returns the number of characters.
335 * @return Number of characters (excluding null terminator)
336 */
337 [[nodiscard]] constexpr size_type Length() const noexcept { return size_; }
338
339 /**
340 * @brief Accesses character at specified position with bounds checking.
341 * @warning Triggers assertion if `pos >= Size()`.
342 * @param pos Position of the character
343 * @return Reference to the character
344 */
345 [[nodiscard]] constexpr reference At(size_type pos) noexcept;
346
347 /**
348 * @brief Accesses character at specified position with bounds checking
349 * (const).
350 * @warning Triggers assertion if `pos >= Size()`.
351 * @param pos Position of the character
352 * @return Const reference to the character
353 *
354 */
355 [[nodiscard]] constexpr const_reference At(size_type pos) const noexcept;
356
357 /**
358 * @brief Accesses the first character.
359 * @warning Triggers assertion if string is empty.
360 * @return Reference to the first character
361 */
362 [[nodiscard]] constexpr reference Front() noexcept;
363
364 /**
365 * @brief Accesses the first character (const).
366 * @warning Triggers assertion if string is empty.
367 * @return Const reference to the first character
368 */
369 [[nodiscard]] constexpr const_reference Front() const noexcept;
370
371 /**
372 * @brief Accesses the last character.
373 * @warning Triggers assertion if string is empty.
374 * @return Reference to the last character
375 */
376 [[nodiscard]] constexpr reference Back() noexcept;
377
378 /**
379 * @brief Accesses the last character (const).
380 * @warning Triggers assertion if string is empty.
381 * @return Const reference to the last character
382 */
383 [[nodiscard]] constexpr const_reference Back() const noexcept;
384
385 /**
386 * @brief Returns pointer to the underlying character array.
387 * @return Pointer to the character array
388 */
389 [[nodiscard]] constexpr pointer Data() noexcept { return data_; }
390
391 /**
392 * @brief Returns pointer to the underlying character array (const).
393 * @return Const pointer to the character array
394 */
395 [[nodiscard]] constexpr const_pointer Data() const noexcept { return data_; }
396
397 /**
398 * @brief Returns null-terminated C string.
399 * @return Null-terminated character array
400 */
401 [[nodiscard]] constexpr const_pointer CStr() const noexcept { return data_; }
402
403 /**
404 * @brief Returns a `std::basic_string_view` of the content.
405 * @return String view of the content
406 */
407 [[nodiscard]] constexpr std::basic_string_view<CharT, Traits> View()
408 const noexcept {
409 return std::basic_string_view<CharT, Traits>(data_, size_);
410 }
411
412 [[nodiscard]] constexpr iterator begin() noexcept { return data_; }
413 [[nodiscard]] constexpr const_iterator begin() const noexcept {
414 return data_;
415 }
416
417 [[nodiscard]] constexpr const_iterator cbegin() const noexcept {
418 return data_;
419 }
420
421 [[nodiscard]] constexpr iterator end() noexcept { return data_ + size_; }
422 [[nodiscard]] constexpr const_iterator end() const noexcept {
423 return data_ + size_;
424 }
425
426 [[nodiscard]] constexpr const_iterator cend() const noexcept {
427 return data_ + size_;
428 }
429
430 [[nodiscard]] constexpr reverse_iterator rbegin() noexcept {
431 return reverse_iterator(end());
432 }
433
434 [[nodiscard]] constexpr const_reverse_iterator rbegin() const noexcept {
435 return const_reverse_iterator(end());
436 }
437
438 [[nodiscard]] constexpr const_reverse_iterator crbegin() const noexcept {
439 return const_reverse_iterator(end());
440 }
441
442 [[nodiscard]] constexpr reverse_iterator rend() noexcept {
443 return reverse_iterator(begin());
444 }
445
446 [[nodiscard]] constexpr const_reverse_iterator rend() const noexcept {
448 }
449
450 [[nodiscard]] constexpr const_reverse_iterator crend() const noexcept {
452 }
453
454private:
455 size_t size_ = 0;
456 const CharT* data_ = nullptr;
457};
458
459template <typename CharT, typename Traits>
461 const std::basic_string<CharT, Traits>& string) noexcept
462 -> BasicCStringView& {
463 size_ = string.size();
464 data_ = string.data();
465 return *this;
466}
467
468template <typename CharT, typename Traits>
470 const CharT* str) noexcept -> BasicCStringView& {
471 size_ = std::char_traits<CharT>::length(str);
472 data_ = str;
473 return *this;
474}
475
476template <typename CharT, typename Traits>
478 CharT* dest, size_type count, size_type pos) const noexcept -> size_type {
479 HELIOS_ASSERT(pos < Size(), "pos out of bounds!");
480 const size_type copy_count = std::min(count, Size() - pos);
481 std::copy_n(data_ + pos, copy_count, dest);
482 return copy_count;
483}
484
485template <typename CharT, typename Traits>
487 BasicCStringView& other) noexcept {
488 std::swap(data_, other.data_);
489 std::swap(size_, other.size_);
490}
491
492template <typename CharT, typename Traits>
494 size_type pos) noexcept -> reference {
495 HELIOS_ASSERT(pos < Size(), "index out of bounds!");
496 return data_[pos];
497}
498
499template <typename CharT, typename Traits>
501 size_type pos) const noexcept -> const_reference {
502 HELIOS_ASSERT(pos < Size(), "index out of bounds!");
503 return data_[pos];
504}
505
506template <typename CharT, typename Traits>
508 const std::basic_string<CharT, Traits>& string) noexcept
509 -> BasicCStringView& {
510 Assign(string);
511 return *this;
512}
513
514template <typename CharT, typename Traits>
516 const CharT* str) noexcept -> BasicCStringView& {
517 Assign(str);
518 return *this;
519}
520
521template <typename CharT, typename Traits>
523 BasicCStringView<CharT, Traits> other) const noexcept
524 -> std::strong_ordering {
525 const auto result = Compare(other);
526 if (result < 0) {
527 return std::strong_ordering::less;
528 }
529 if (result > 0) {
530 return std::strong_ordering::greater;
531 }
532 return std::strong_ordering::equal;
533}
534
535template <typename CharT, typename Traits>
537 std::basic_string_view<CharT, Traits> other) const noexcept
538 -> std::strong_ordering {
539 const auto result = Compare(other);
540 if (result < 0) {
541 return std::strong_ordering::less;
542 }
543 if (result > 0) {
544 return std::strong_ordering::greater;
545 }
546 return std::strong_ordering::equal;
547}
548
549template <typename CharT, typename Traits>
551 -> reference {
552 HELIOS_ASSERT(pos < Size(), "pos out of bounds!");
553 return data_[pos];
554}
555
556template <typename CharT, typename Traits>
557constexpr auto BasicCStringView<CharT, Traits>::At(size_type pos) const noexcept
558 -> const_reference {
559 HELIOS_ASSERT(pos < Size(), "pos out of bounds!");
560 return data_[pos];
561}
562
563template <typename CharT, typename Traits>
565 HELIOS_ASSERT(!Empty(), "string is empty");
566 return data_[0];
567}
568
569template <typename CharT, typename Traits>
570constexpr auto BasicCStringView<CharT, Traits>::Front() const noexcept
571 -> const_reference {
572 HELIOS_ASSERT(!Empty(), "string is empty!");
573 return data_[0];
574}
575
576template <typename CharT, typename Traits>
578 HELIOS_ASSERT(!Empty(), "string is empty!");
579 return data_[Size() - 1];
580}
581
582template <typename CharT, typename Traits>
583constexpr auto BasicCStringView<CharT, Traits>::Back() const noexcept
584 -> const_reference {
585 HELIOS_ASSERT(!Empty(), "string is empty!");
586 return data_[Size() - 1];
587}
588
589/// @brief A view of a null-terminated C string.
591
592/// @brief A view of a null-terminated wide C string.
594
595/// @brief A view of a null-terminated UTF-8 C string.
597
598/// @brief A view of a null-terminated UTF-16 C string.
600
601/// @brief A view of a null-terminated UTF-32 C string.
603
604/**
605 * @brief Outputs a `BasicCStringView` to an output stream.
606 * @tparam CharT Character type
607 * @tparam Traits Character traits
608 * @param os Output stream
609 * @param str String to output
610 * @return Reference to the output stream
611 */
612template <typename CharT, typename Traits>
613inline auto operator<<(std::basic_ostream<CharT, Traits>& os,
615 -> std::basic_ostream<CharT, Traits>& {
616 return os << str.View();
617}
618
619} // namespace helios
620
621namespace std {
622
623/**
624 * @brief Hash support for `BasicCStringView`.
625 * @tparam CharT Character type
626 * @tparam Traits Character traits
627 */
628template <typename CharT, typename Traits>
629struct hash<helios::BasicCStringView<CharT, Traits>> {
630 [[nodiscard]] constexpr size_t operator()(
631 const helios::BasicCStringView<CharT, Traits>& str) const noexcept {
632 return hash<basic_string_view<CharT, Traits>>{}(str.View());
633 }
634};
635
636/**
637 * @brief `std::format` support for `BasicCStringView`.
638 * @details Enables formatting `BasicCStringView` using `std::format`
639 * by delegating to `std::basic_string_view` formatter.
640 * @tparam CharT Character type
641 * @tparam Traits Character traits
642 */
643template <typename CharT, typename Traits>
644struct formatter<helios::BasicCStringView<CharT, Traits>>
645 : formatter<basic_string_view<CharT, Traits>> {
646 /// @brief Format the `BasicCStringView` by delegating to
647 /// `std::basic_string_view` formatter.
649 format_context& ctx) const {
650 return formatter<basic_string_view<CharT, Traits>>::format(str.View(), ctx);
651 }
652};
653
654} // namespace std
#define HELIOS_ASSERT(condition,...)
Assertion macro that aborts execution in debug builds.
Definition assert.hpp:259
A view of a null-terminated C string.
constexpr size_type Copy(char *dest, size_type count, size_type pos=0) const noexcept
constexpr BasicCStringView(const std::basic_string< CharT, Traits > &string) noexcept
Constructs from a string.
constexpr BasicCStringView & operator=(const std::basic_string< CharT, Traits > &string) noexcept
Assigns a std::basic_string.
constexpr int Compare(BasicCStringView< CharT, Traits > other) const noexcept
Compares with another c string view.
constexpr size_type FindLastNotOf(std::basic_string_view< CharT, Traits > sv, size_type pos=npos) const noexcept
Finds last character not in sv.
constexpr BasicCStringView(const CharT *str) noexcept
Constructs from a null-terminated C string.
constexpr size_type Find(std::basic_string_view< CharT, Traits > sv, size_type pos=0) const noexcept
Finds first occurrence of substring.
static constexpr size_type npos
constexpr const_reverse_iterator rend() const noexcept
constexpr BasicCStringView(BasicCStringView &&) noexcept=default
constexpr bool Contains(CharT ch) const noexcept
Checks if string contains character.
constexpr bool StartsWith(std::basic_string_view< CharT, Traits > sv) const noexcept
Checks if string starts with prefix.
constexpr const_reference At(size_type pos) const noexcept
Accesses character at specified position with bounds checking (const).
constexpr reference At(size_type pos) noexcept
Accesses character at specified position with bounds checking.
constexpr bool Contains(std::basic_string_view< CharT, Traits > sv) const noexcept
Checks if string contains substring.
constexpr reference Front() noexcept
Accesses the first character.
const CharT & const_reference
constexpr size_type FindFirstNotOf(std::basic_string_view< CharT, Traits > sv, size_type pos=0) const noexcept
Finds first character not in sv.
constexpr bool EndsWith(CharT ch) const noexcept
Checks if string ends with character.
constexpr bool StartsWith(CharT ch) const noexcept
Checks if string starts with character.
constexpr const_iterator cend() const noexcept
std::reverse_iterator< const_iterator > const_reverse_iterator
constexpr const_iterator cbegin() const noexcept
constexpr reverse_iterator rbegin() noexcept
constexpr std::basic_string_view< CharT, Traits > View() const noexcept
Returns a std::basic_string_view of the content.
constexpr const_pointer CStr() const noexcept
Returns null-terminated C string.
BasicCStringView(std::nullptr_t)=delete
constexpr const_reference operator[](size_type pos) const noexcept
Accesses character at specified position (const).
constexpr iterator begin() noexcept
constexpr BasicCStringView(const BasicCStringView &) noexcept=default
constexpr bool EndsWith(std::basic_string_view< CharT, Traits > sv) const noexcept
Checks if string ends with suffix.
constexpr const_pointer Data() const noexcept
Returns pointer to the underlying character array (const).
constexpr const_iterator begin() const noexcept
constexpr reference Back() noexcept
Accesses the last character.
constexpr size_type FindFirstOf(std::basic_string_view< CharT, Traits > sv, size_type pos=0) const noexcept
Finds first occurrence of any character in sv.
constexpr iterator end() noexcept
constexpr size_type RFind(CharT ch, size_type pos=npos) const noexcept
Finds last occurrence of character.
constexpr void Swap(BasicCStringView &other) noexcept
constexpr bool Empty() const noexcept
Checks if the string is empty.
friend constexpr void swap(BasicCStringView &lhs, BasicCStringView &rhs) noexcept
constexpr size_type Size() const noexcept
Returns the number of characters.
constexpr reference operator[](size_type pos) noexcept
Accesses character at specified position.
constexpr const_reverse_iterator rbegin() const noexcept
constexpr int Compare(std::basic_string_view< CharT, Traits > other) const noexcept
Compares with another string.
constexpr size_type RFind(std::basic_string_view< CharT, Traits > sv, size_type pos=npos) const noexcept
Finds last occurrence of substring.
constexpr size_type Find(CharT ch, size_type pos=0) const noexcept
Finds first occurrence of character.
std::reverse_iterator< iterator > reverse_iterator
constexpr size_type Length() const noexcept
Returns the number of characters.
constexpr const_reverse_iterator crbegin() const noexcept
constexpr BasicCStringView & operator=(const CharT *str) noexcept
Assigns a null-terminated C string.
constexpr BasicCStringView & operator=(const BasicCStringView &) noexcept=default
constexpr reverse_iterator rend() noexcept
constexpr auto operator<=>(std::basic_string_view< CharT, Traits > other) const noexcept -> std::strong_ordering
constexpr const_reverse_iterator crend() const noexcept
constexpr const_iterator end() const noexcept
constexpr auto operator<=>(BasicCStringView< CharT, Traits > other) const noexcept -> std::strong_ordering
constexpr BasicCStringView & Assign(const std::basic_string< char, std::char_traits< char > > &string) noexcept
constexpr pointer Data() noexcept
constexpr size_type FindLastOf(std::basic_string_view< CharT, Traits > sv, size_type pos=npos) const noexcept
Finds last occurrence of any character in sv.
auto operator<<(std::basic_ostream< CharT, Traits > &os, const BasicCStringView< CharT, Traits > &str) -> std::basic_ostream< CharT, Traits > &
Outputs a BasicCStringView to an output stream.
BasicCStringView< wchar_t > WCStringView
A view of a null-terminated wide C string.
BasicCStringView< char > CStringView
A view of a null-terminated C string.
BasicCStringView< char16_t > U16CStringView
A view of a null-terminated UTF-16 C string.
BasicCStringView< char8_t > U8CStringView
A view of a null-terminated UTF-8 C string.
BasicCStringView< char32_t > U32CStringView
A view of a null-terminated UTF-32 C string.
STL namespace.
auto format(const helios::BasicCStringView< CharT, Traits > &str, format_context &ctx) const
Format the BasicCStringView by delegating to std::basic_string_view formatter.
constexpr size_t operator()(const helios::BasicCStringView< CharT, Traits > &str) const noexcept