The Wayback Machine - https://web.archive.org/web/20220601025610/https://en.cppreference.com/w/cpp/utility/format
Namespaces
Variants
Views
Actions

Formatting library (C++20)

From cppreference.com
< cpp‎ | utility
 
 
Utilities library
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)   
(C++20)
Swap and type operations
(C++14)
(C++11)

(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++23)
(C++11)
(C++17)

Elementary string conversions
(C++17)
(C++17)
 
Formatting library
Formatting functions
(C++20)
(C++20)
(C++20)
(C++20)
Formatter
(C++20)
Formatting arguments
Format error
 

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.

#include <format>
#include <cassert>
int main() {
    std::string message = std::format("The answer is {}.", 42);
    assert( message == "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 template) [edit]
class template 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]

[edit] Notes

Feature testing macro: __cpp_lib_format