c_plus_plus_string

C++ Strings library

https://en.cppreference.com/w/cpp/string

The C++ strings library includes support for three general types of strings:

  • - a templated class designed to manipulate strings of any character type.

  • - a lightweight non-owning read-only view into a subsequence of a string.

  • Null-terminated strings - arrays of characters terminated by a special null character.

{{lc]] | [[std::basic_string}}

The templated class

generalizes how sequences of characters are manipulated and stored. String creation, manipulation, and destruction are all handled by a convenient set of class methods and related functions.

Several specializations of

are provided for commonly-used types:

]] | {{c | basic_string<char>}}}} {{dsc | {{lc | wstring}} | {{c | basic_string<wchar_t>}}}} {{dsc | {{lc | u8string}} {{mark since c++20}} | {{c | basic_string<char8_t>}}}} {{dsc | {{lc | u16string}} {{mark since c++11}} | {{c | basic_string<char16_t>}}}} {{dsc | {{lc | u32string}} {{mark since c++11}} | {{c | basic_string<char32_t>}}}} {{dsc end}} {{rrev | since=c++17 | === {{ltt | cpp/string/basic_string_view | basic_string_view}} === The templated class {{lc | basic_string_view}} provides a lightweight object that offers read-only access to a string or a part of a string using an interface similar to the interface of {{lc | basic_string}}. Several specializations of {{lc | {{dsc begin}} {{dsc header | string_view}} {{dsc hitem | Type | Definition}} {{dsc | {{lc | string_view}} {{mark since c++17}} | {{c | basic_string_view<char>}}}} {{dsc | {{lc | wstring_view}} {{mark since c++17}} | {{c | basic_string_view<wchar_t>}}}} {{dsc | {{lc | u8string_view}} {{mark since c++20}} | {{c | basic_string_view<char8_t>}}}} {{dsc | {{lc | u16string_view}} {{mark since c++17}} | {{c | basic_string_view<char16_t>}}}} {{dsc | {{lc | u32string_view}} {{mark since c++17}} | {{c | * {{rl | byte | null-terminated byte strings}} * {{rl | multibyte | null-terminated multibyte strings}} * {{rl | wide | null-terminated wide strings}} === Additional support === ===={{lc | char_traits}}==== The string library also provides class template {{lc | char_traits}} that defines types and functions for {{lc | basic_string}} {{rev inl | since=c++17 | and {{lc | {{dcl begin}} {{dcl header | string}} {{dcl | }} {{dcl | }} {{dcl | since=c++20 | }} {{dcl | since=c++11 | }} {{dcl | since=c++11 | }} {{dcl end}} ====Conversions and classification==== The [[cpp/locale | localizations library provides support for string conversions (e.g.

or

) as well as functions that classify characters (e.g.

or

).

See also

c_plus_plus_string.txt · Last modified: 2025/02/01 07:13 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki