Skip to content


Subversion checkout URL

You can clone with
Download ZIP
[Deprecated] A simple C++ formatter that resembles SLF4J and Python format
Branch: master
Failed to load latest commit information.
include/formatting Some changes that improve overall performance
source Added missed benchmark
test Added filler for width modifier and vector specialization
.clang_complete Initial commit
.travis.yml One more fix for travis
CMakeLists.txt Some changes that improve overall performance
Makefile Update

This library is deprecated

Formatting is a simple header-only C++ library to format strings with automatic type inference. It resembles (with some simplifications though) the SLF4J Java library and Python's format method. The library is distributed with almost no restrictions due to BSD 2-clause license.

The simplest example of the library usage is:

std::string formatted = formatting::format("{} + {} is {} and that's {}", 2, 2, 2+2, true);

This makes the formatted string contain 2 + 2 is 4 and that's true. Some other examples include:

std::vector<int> v;
std::cout << formatting::format("v={}", v); 
// outputs `v=[100, 200]`

for (int i=0; i<5; i++)
    std::cout << formatting::format("{} ", width[3](i, '0'));
// outputs `000 001 002 003 004`

double pi = 3.14159265;
double e = 2.718281828;
std::cout << formatting::format("{} {}", precision[3](pi), precision[5](e));
// outputs `3.141 2.71828`

Self-explaining unit-tests can be found in the test/ folder of the repository.

In case of any troubles with the code please don't hesitate to fire an issue at github.

This project uses Travis CI.

Something went wrong with that request. Please try again.