|
utf-42
|
A class that provides a lightweight, non-owning view of a string. More...
#include <utf42.h>
Public Types | |
| using | pointer = const char_t * |
| Pointer type to characters. | |
| using | reference = const char_t & |
| Reference type to characters. | |
| using | char_type = char_t |
| Character type. | |
| using | size_type = std::size_t |
| Type for sizes of the string. | |
Public Member Functions | |
| constexpr | basic_string_view () |
| Default constructor initializes to an empty string view. | |
| constexpr | basic_string_view (nullptr_t)=delete |
| Deleted constructor from nullptr to avoid unintended usage. | |
| template<std::size_t N> | |
| constexpr | basic_string_view (const char_t(&pStr)[N]) |
| Constructor from a C-style string. | |
| constexpr size_type | length () const noexcept |
| Get the length of the string. | |
| constexpr pointer | data () const noexcept |
| Get a pointer to the underlying character data. | |
| std::basic_string< char_t > | str () const |
| Convert to std::basic_string for further manipulation. | |
A class that provides a lightweight, non-owning view of a string.
This class allows for efficient string manipulation without ownership, making it particularly useful for passing around substring references or interfacing with C-style strings. It avoids unnecessary data copies and allocations, enhancing performance in string handling operations.
| char_t | The character type (e.g., char, wchar_t) that the view will operate on. |
|
inlineconstexpr |
Constructor from a C-style string.
Initializes the string view with a given null-terminated string and calculates its length.
| pStr | Pointer to the null-terminated string. |
|
inlineconstexprnoexcept |
Get a pointer to the underlying character data.
|
inlineconstexprnoexcept |
Get the length of the string.
|
inline |
Convert to std::basic_string for further manipulation.