On Mar 7, 2025, at 7:58 PM, Jeremy Rifkin via Std-Proposals <std-proposals@lists.isocpp.org> wrote:

Would the proposal here be to make constexpr std::chrono give the invocation time or some fixed now time for the whole compilation?

I'm just imagining:

consteval void who_needs_fast_compilation_anyway() {
    auto start = std::chrono::system_clock::now();
    while(std::chrono::system_clock::now() < start + std::chrono::minutes(1)) {}
}

Cheers,
Jeremy


Fwiw, I have this proposal crudely prototyped on __DATE__ and __TIME__.  I ran your example through it and got:


test.cpp:135:5: error: call to consteval function 'who_needs_fast_compilation_anyway' is not a constant expression

  135 |     who_needs_fast_compilation_anyway();

      |     ^

test.cpp:52:9: note: constexpr evaluation hit maximum step limit; possible infinite loop?

   52 |         {

      |         ^


which seems like a reasonable result to me.  Garbage in / garbage out sort of thing...


Howard