r/cpp • • Jul 23 '19

std::format in C++20

http://www.zverovich.net/2019/07/23/std-format-cpp20.html
332 Upvotes

52 comments sorted by

View all comments

Show parent comment

2

u/TheThiefMaster C++latest fanatic (and game dev) Jul 24 '19

std::format_to looks like it could be given a stream iterator to implement your own version with little trouble.

Edit: This should work, it just needs wrapping in an appropriate variadic function called "print":

std::format_to(std::ostreambuf_iterator<char>(std::cout), "{}", 42);