A modern formatting library for C++
open sourceMITfree
{fmt} is a C++ formatting library inspired by Python's format strings, a safe and fast replacement for printf and iostreams. Errors in format strings are reported at compile time, automatic memory management prevents buffer overflows, and it formats most standard types out of the box, containers, dates and times included, with your own types made formattable the same way. It's tens of percent to 20 to 30 times faster than iostreams and sprintf, especially for numbers, prints Unicode correctly on Linux, macOS and the Windows console, and compiles fast thanks to type erasure and a minimal fmt/base.h header. It also provides an implementation of C++20's std::format and C++23's std::print.
Problems it solves
- replace printf in C++ with something type-safe that catches format errors at compile time
- format strings in C++ the way Python's format does
- print a std::vector or a date in C++ without writing my own operator<<
- faster number formatting than sprintf or iostreams in C++
Features
- Python-style format string syntax
- compile-time checking of format strings
- formatting of standard containers, dates and times
- user-defined formatters for your own types
- portable Unicode output, including the Windows console
- optional compile-time format string compilation for speed
