std::chrono::is_clock
|
在标头
<chrono> 定义 |
||
|
template< class T >
struct is_clock; |
(C++20 起) | |
若 T 满足时钟 (Clock) 要求,则提供等于 true 的成员常量 value ,对于任何其他类型, value 为 false 。
为此特性的目的,实现确定类型不能满足时钟 (Clock) 要求的外延是未指定的,除了至少 T 不应当具备时钟 (Clock) 的资格,除非它满足所有下列条件:
- qualified-id
T::rep、T::period、T::duration和T::time_point均合法并且每个都代表一个类型; - 表达式
T::is_steady和T::now()在当做不求值运算数时均为良构。
添加 std::is_clock 或 std::is_clock_v 的特化的程序行为未定义。
模板形参
| T | - | 要检查的类型 |
辅助变量模板
|
template< class T >
inline constexpr bool is_clock_v = is_clock<T>::value; |
(C++20 起) | |
继承自 std::integral_constant
成员常量
|
value
[静态]
|
如果 T 满足时钟 (Clock) 要求那么是 true,否则是 false(公开静态成员常量) |
成员函数
|
operator bool
|
将对象转换到 bool,返回 value (公开成员函数) |
|
operator()
(C++14)
|
返回 value (公开成员函数) |
成员类型
| 类型 | 定义 |
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; T::now(); } struct is_clock<T> : std::true_type {}; |