Chapter 7: Strings, Streams, and Formatting

The STL string class is a powerful, full-featured tool for storing, manipulating, and displaying character-based data. It has much of the convenience you would find in a high-level scripting language, yet remains as quick and agile as you would expect from C++.

The string class is based on basic_string, a contiguous container class that may be instantiated with any character type. Its class signature looks like this:

template<

    typename CharT,

    typename Traits = std::char_traits<CharT>,

    typename Allocator = std::allocator<CharT>

> class basic_string;

The Traits and Allocator template parameters are usually left to their default values.

The underlying storage of basic_string is a contiguous ...

Get C++20 STL Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.