C++20 Formatting library — Part1: Setup and Basics

Gajendra Gulgulia
4 min readMar 8, 2023

Formatting library or string formatting library is another big feature available since C++20 which as other features has arived rather late into C++ standard.

In this part of the series on I’ll explain how to setup the formatting library on your local system and the basics of how to use string formatting library. In the second part of the series, I’ll explain why do we need another formatting library when the stadard iostream was already there for us.

1. Prolouge

At the time of writing this series, the header format is not yet integrated into latest gcc or clang compiler. According to reference the only two compilers that have so far implemented the standard text formatting libraries are clang-14* and msvc 19.29. Due to limitations in my personal computer, I’ll therefore be using the fmt library on which the standard string formatting library is based. When the compiler support is released, the token fmt::format can be replaced with std::format and the examples in the series should work as it is.

In the next section of this article, I’ll show how to download the fmt project with cmake into the current build tree in a test application so that readers are not limited by compilers to learn and experiment with the formatting library

2. Cmake based build…

--

--