Multiple {} for one object?
println( "{}{}{}", 1, 2, 3 ); // valid
println( "{}", std::tuple(1, 'b', 1.0/3.0) ); // valid
println( "{.2f}", std::tuple(1, 'b', 1.0/3.0) ); // error
// what I'd like and what an average user would expect to work
println( "{} {} {.2f}", std::tuple(1, 'b', 1.0/3.0) );
Question 1: can I let my own tuple-like type consume multiple {}s Question 2: why is std::tuple only taking one {}
I'm familiar writing formatters for my types, but I fail to see how I could consume more than one {}. Maybe impossible by design. Maybe I just need a hint.
Tuples are not destructured automatically but you could write your own tuple wrapper and provide a formatter that extracts individual elements, something like:
auto t = std::tuple(1, 'b');
fmt::print("{0:[0]} {0:[1]}", mytuple(t));
I still wonder why the design choice was single {} for one tuple rather than n {}s
{fmt} is modeled after Python's format which made this design choice. But even putting Python aside, autodestructuring would be extremely confusing with multiple arguments.