C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Format output-streamable types?

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Sat, 14 Dec 2024 15:58:50 +0000
On Sat, 14 Dec 2024, 15:33 Victor Zverovich via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

> Note that std::print already supports printing to an ostream so you don't
> need lazy_format or print_to_sink:
> https://en.cppreference.com/w/cpp/io/basic_ostream/print
>


Yeah the only advantage of lazy_format is being able to do a single
statement:

out << x << lazy_format(...) << y;

Rather than:
out << x;
print(out, ...);
out << y;

But it's a minor difference. If that matters you could do:

print(out << x, ...) << y;

Received on 2024-12-14 16:00:11