|
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Defined in header <chrono> | ||
template<class T> struct is_clock; | (since C++20) | |
IfT satisfies theClock requirements, provides the member constantvalue equaltrue. For any other type,value isfalse.
For the purpose of this trait, the extent to which an implementation determines that a type cannot meet theClock requirements is unspecified, except that a minimumT shall not qualify as aClock unless it meets all following conditions:
T::repT::periodT::durationT::time_pointT::is_steadyT::now()If the program adds specializations forstd::is_clock orstd::is_clock_v, the behavior is undefined.
Contents |
| T | - | a type to check |
template<class T> constexprbool is_clock_v= is_clock<T>::value; | (since C++20) | |
value [static] | true ifT satisfies theClock requirements,false otherwise(public static member constant) |
operator bool | converts the object tobool, returnsvalue (public member function) |
operator() (C++14) | returnsvalue (public member function) |
| Type | Definition |
value_type | bool |
type | std::integral_constant<bool, value> |
template<class>struct is_clock:std::false_type{}; template<class T> requires requires{typename T::rep;typename T::period;typename T::duration;typename T::time_point; T::is_steady;// type is not checked T::now();// return type is not checked}struct is_clock<T>:std::true_type{}; |
IfT otherwise meets theClock requirements, butT::is_steady is not of typeconstbool, orT::now() is not of typeT::time_point, the result ofis_clock_v<T> is unspecified.
#include <chrono>#include <ratio> static_assert( std::chrono::is_clock_v<std::chrono::utc_clock> and not std::chrono::is_clock_v<std::chrono::duration<int,std::exa>>); int main(){}