Owning and non-owning text types, plus the trait layer they're built on. Mirrors cppreference's strings library.
| Page | Header | Since | What |
|---|---|---|---|
std::string / basic_string |
<string> |
C++98 | Owning, growable character sequence |
std::string_view |
<string_view> |
C++17 | Non-owning read-only view of characters |
char_traits |
<string> |
C++98 | The character-operations policy both build on |
Formatting (
std::format/std::print),to_string/from_chars, and regular expressions live in the Text processing area.
- Own and mutate text →
std::string. - Just read/parse text you don't own (function parameters especially) →
std::string_view— no allocation, no copy. - Different character type or comparison rules → a
basic_string<CharT, Traits>instantiation; customize viachar_traits.