hide:

  • navigation
  • toc

A modern formatting library

fmt::format("{:d}", "I am not a number");

will give a compile-time error because d is not a valid format specifier for strings. APIs like fmt::format prevent buffer overflow errors via automatic memory management.

fmt::print("{}", std::vector{1, 2, 3});

prints the vector in a JSON-like format:

[1, 2, 3]

You can make your own types formattable and even make compile-time checks work for them.

The library minimizes dynamic memory allocations and can optionally compile format strings to optimal code.

fmt::print("Слава Україні!");

will be printed correctly on Linux, macOS, and even Windows console, irrespective of the codepages.