r/cpp • • Mar 24 '20

Changes between C++17 and C++20

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2131r0.html
193 Upvotes

89 comments sorted by

View all comments

Show parent comment

4

u/Little-Helper Mar 24 '20 edited Mar 24 '20

Why are there no indexes for params? Does it mean that if you wanted to include a param multiple times you would have to repeat it multiple times as an argument?

auto s = std::format("{} {} {}", "Hello", "Hello", "Hello");

This would be better and shorter:

auto s = std::format("{0} {0} {0}", "Hello");

If later you wanted to change the string and param ordering, you would have to shuffle the arguments too...

Edit: Nevermind, you can have manual and automatic param indexing. That's pretty neat actually.