Is it possible to align multiple fields together?
E.g.,
std::format("{:{}:<12} text", file, line)
to align as
main.cpp:1 text
and not as
main.cpp: 1 text
>Solution :
For the desired output, you could do:
std::cout << std::format("{0}:{1:<12} text", file, line) << '\n';
where:
-
{0}refers to the first argument (i.e.file) -
{1:<12}is a nested field specifier for the second argument (i.e.line). The1refers to the second argument, and
:<12means left-align and pad to12characters