C++20 String Formatting Library: An Overview and Use with Custom Types
summary
C++20 introduces std::format and the std::formatter customization point for formatting text. The talk covers how to specialize std::formatter to print custom types and parse custom key/value format options, shows error reporting for bad specifiers, demonstrates locale-aware number formatting and a center-alignment option not available in iostreams, and notes the implementation is based on the fmt library. Microbenchmarks are presented showing std::format is much faster than iostreams (hundreds of thousands of formats/sec) and performs similarly to fmt, while customization is straightforward.
AI-written summary · about
chapters (15)
- 0:00Introduction to C++20 string formatting
- 1:12Why a new formatting library
- 3:42Advantages of C++20 formatting
- 4:49Placeholders and format specifiers
- 7:19Field width and alignment
- 9:49Number formatting options
- 11:59Custom format specifiers
- 15:29Floating-point formatting
- 18:01Hexadecimal and binary output
- 20:04Performance comparison
- 21:49Support for custom types
- 24:17Key-value pair formatting
- 26:23Localization and advantages
- 27:30Comparison with existing libraries
- 28:15Summary and Q&A
related talks
01h 01m“A modern formatting library for C++”
59mThe Best Parts of C++
01mTalk Preview: Building on clang-tidy: move from printf-style to std::print-style logging
57mIntroduction to C++ Template Metaprogramming
38mWhat's New In C++23
01h 00mConcepts in C++20: Revolution or Evolution
01h 27mC++20 Templates - the Next Level: Concepts and More
58mC++17 in Practice - The good and the ugly
