Date: Thu, 06 Mar 2025 14:00:34 -0800
On Thursday, 6 March 2025 13:43:47 Pacific Standard Time Nikolaos D. Bougalis
via Std-Proposals wrote:
> In looking, it seems to me that making std::chrono::system_clock usable in
> constexpr contexts is pretty simple and invokes marking one function as
> constexpr: now.
Please don't. Your software should not depend on the time it was compiled at
and should not change depending on that.
std::chrono::system_clock::time_point now = {};
if (!std::is_constant_evaluated()))
now = std::chrono::system_clock::now();
> Less exotic use cases include the ability to generate time-based UUIDs at
> compile time, to seed random number generators at compile time, potentially
> warn when old code is compiled (not that there's anything wrong with that!)
Please make your software reproducible: it should be bitwise exactly identical
if it is compiled by the same compiler.
via Std-Proposals wrote:
> In looking, it seems to me that making std::chrono::system_clock usable in
> constexpr contexts is pretty simple and invokes marking one function as
> constexpr: now.
Please don't. Your software should not depend on the time it was compiled at
and should not change depending on that.
std::chrono::system_clock::time_point now = {};
if (!std::is_constant_evaluated()))
now = std::chrono::system_clock::now();
> Less exotic use cases include the ability to generate time-based UUIDs at
> compile time, to seed random number generators at compile time, potentially
> warn when old code is compiled (not that there's anything wrong with that!)
Please make your software reproducible: it should be bitwise exactly identical
if it is compiled by the same compiler.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel DCAI Platform & System Engineering
Received on 2025-03-06 22:00:39