Why is std :: chrono :: system_clock :: to_time_t () not constexpr?

The C ++ standard (github.com/cplusplus/draft) has time_t conversion functions ( std::chrono::system_clock::to_time_t and std::chrono::system_clock::from_time_t ) for those listed as static and noexcept , but not constexpr .

Given that essentially all operations on time_point and duration are equal to constexpr (including duration_cast and time_point_cast ), I cannot think of any reason to exclude them. A quick look at the sources of libstdC ++ on my local machine confirms that these functions are implemented as simple values โ€‹โ€‹of duration / time _point.

Is there a reason why these two functions should not be constexpr ? Is it just a case "because no one suggested they be"?

+6
source share
1 answer

Is it just a case "because no one suggested they be"?

Yes, I think that's for sure.

I'm curious: as soon as you get constexpr time_t , what are you going to do with it? None of the C functions taking time_t have a constexpr value.

+3
source

All Articles