C++ Logo

std-proposals

Advanced search

Re: [std-proposals] constexpr support for std::chrono::system_clock

From: Howard Hinnant <howard.hinnant_at_[hidden]>
Date: Mon, 10 Mar 2025 23:11:34 -0400
On Mar 10, 2025, at 6:52 PM, Tom Honermann via Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> If it also adds constexprto the declarations of the time_point related functions


Nik’s proposal does *not* add constexpr to the declarations of the time_point releated functions. … That would be redundant:

https://eel.is/c++draft/time.point

One can already do plenty of time_point and calendrical compuations at compile time in C++20:

    #include <chrono>

    int
    main()
    {
        using namespace std::chrono;
        auto constexpr my_epoch = sys_days{January/1/2000} + 0h + 0min + 0s;
        static_assert(my_epoch - sys_days{1970y/1/1} == 946684800s);
    }

Howard

Received on 2025-03-11 03:12:08