-
Book Overview & Buying
-
Table Of Contents
C++ STL Cookbook - Second Edition
By :
While cout has had its place since the beginning of the STL, it has been outdated for many years. The advent of type-safe variadic templates and parameter packs with C++11 made it possible to replace cout with a more succinct and efficient alternative, like printf() but with type safety.
New for C++23, the print() and println() functions leverage the format library to provide efficient string formatting and printing for both console and file streams. This was originally proposed for C++20 but was not ready in time for ratification.
Because the print() functions bypass the cumbersome iostream library, these functions are far more efficient than using format with cout. Performance and code size are comparable to printf() but with the type-safety benefits of the format library.
The print() and println() functions are defined in the <print> header.
The print() and println() functions are simple and powerful...