# **[](https://en.cppreference.com/w/cpp/header/format)** provides `std::format`, a type-safe, fast, printf-style formatting function introduced in C++20. It replaces most uses of `sprintf`, string streams, and `std::cout` manipulators. It supports compile-time format string checking (in some implementations) and is faster than stream-based formatting. ## Example This example demonstrates type-safe formatting with automatic type deduction, creating formatted output with precision control. ```cpp // compile: g++ -std=c++20 -o formatexample formatexample.cpp // run: ./formatexample // description: type-safe formatting with std::format #include #include int main() { int x = 42; double pi = 3.14159; std::string name = "Alice"; std::cout << std::format("hello {}, x={}, pi={:.2f}\n", name, x, pi); return 0; } ```