See Jens' reply (one of the first in the thread).

 

It probably went too frictionless.

 

OTOH How much is allowed under as-if rules?

 - if the parameters are fully known, the implementation could shift around the evaluation in both directions?


 

-----Ursprüngliche Nachricht-----
Von: Mital Ashok via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Mo 25.05.2026 09:40
Betreff: Re: [std-proposals] Perfect forwarding for prvalues / expression templates
An: std-proposals@lists.isocpp.org;
CC: Mital Ashok <mital@mitalashok.co.uk>;
On Mon, 25 May 2026 at 08:14, Sebastian Wittmeier via Std-Proposals
<std-proposals@lists.isocpp.org> wrote:
>
> The syntax of std::lazy makes it hard to recognize, which parts of the program are lazily evaluated.
>
> Is there a mixture of std::lazy and lambda syntax possible?

The whole point is that it would be as frictionless as possible at the
call site. The exact same issue appears currently with
assert/debug/log macros, where we expect the macro writer to have
sensible semantics about whether/how many times a macro argument is
actually evaluated.

This is currently extremely possible by just wrapping everything in a
lambda, but no one is doing it because it isn't a known/standardized
pattern and it is extremely verbose:

   logger.log(log_level::info, [&]{ return std::format("f() called
with argument {}", i); });
   // Which leads people to use a macro
   LOG_MACRO(logger, log_level::info, "f() called with argument {}", i);
   // vs with std::lazy
   logger.log(log_level::info, "f() called with argument {}", i);
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals