-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
Description
Currently, MSVC STL only performs basic checks in std::chrono::is_clock(_v) as required by [time.traits.is.clock]/1.
Lines 62 to 70 in 1118f37
| _EXPORT_STD template <class _Clock> | |
| _NO_SPECIALIZATIONS_OF_VARIABLE_TEMPLATES constexpr bool is_clock_v = requires { | |
| typename _Clock::rep; | |
| typename _Clock::period; | |
| typename _Clock::duration; | |
| typename _Clock::time_point; | |
| _Clock::is_steady; | |
| _Clock::now(); | |
| }; |
Some other implementations, like libstdc++, perform stricter checks. It might be better for MSVC STL to do so. Note that all requirements in the "Return type" column of [tab:time.clock], except for "a class emulating an arithmetic type" (see also #1909), seem statically checkable.
We may also want to perform equivalent checks (for multi-threading components) in old modes, although this requires rewriting in legacy SFINAE, which is still implementable.
Lines 77 to 84 in 1118f37
| template <class _Clock, class = void> | |
| constexpr bool _Is_clock_v = false; | |
| template <class _Clock> | |
| constexpr bool | |
| _Is_clock_v<_Clock, void_t<typename _Clock::rep, typename _Clock::period, typename _Clock::duration, | |
| typename _Clock::time_point, decltype(_Clock::is_steady), decltype(_Clock::now())>> = | |
| true; |