문제

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

Given that essentially all of the operations on time_point and duration are constexpr (including duration_cast and time_point_cast), I can't think of any reason to exclude them. A quick inspection of the libstdc++ sources on my local machine confirms that these functions are implemented as simple duration/time_point casts.

Is there any reason that these two functions should not be constexpr? Is this just a case of "because no one proposed they should be"?

도움이 되었습니까?

해결책

Is this just a case of "because no one proposed they should be"?

Yes, I think that is exactly right.

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top