Namespaces
Variants
Views
Actions

Formatting library (C++20)

From cppreference.com
< cpp‎ | utility
 
 
 
 

The text formatting library offers a safe and extensible alternative to the printf family of functions. It is intended to complement the existing C++ I/O streams library and reuse some of its infrastructure such as overloaded insertion operators for user-defined types.

Example:

std::string message = std::format("The answer is {}.", 42);


[edit] Formatting functions

(C++20)
stores formatted representation of the arguments in a new string
(function template) [edit]
(C++20)
writes out formatted representation of its arguments through an output iterator
(function template) [edit]
writes out formatted representation of its arguments through an output iterator, not exceeding specified size
(function template) [edit]
determines the number of characters necessary to store the formatted representation of its arguments
(function template) [edit]

[edit] Extensibility support and implementation detail

(C++20)
non-template variant of std::format using type-erased argument representation
(function) [edit]
non-template variant of std::format_to using type-erased argument representation
(function) [edit]
class that provides access to a formatting argument for user-defined formatters
(class template) [edit]
(C++20)
class template that defines formatting rules for a given type
(class template) [edit]
formatting string parser state
(class template) [edit]
formatting state, including all formatting arguments and the output iterator
(class template) [edit]
argument visitation interface for user-defined formatters
(function template) [edit]
creates a type-erased object referencing all formatting arguments, convertible to format_args
(function template) [edit]
class that provides access to all formatting arguments
(class template) [edit]
exception type thrown on formatting errors
(class) [edit]