std::chrono:: is_clock
|
헤더에 정의됨
<chrono>
|
||
|
template
<
class
T
>
struct is_clock ; |
(C++20부터) | |
만약
T
가
Clock
요구 사항을 충족한다면, 멤버 상수
value
를
true
와 동일하게 제공합니다. 다른 모든 타입에 대해서는
value
가
false
입니다.
이 특성의 목적상, 구현이 어떤 타입이
Clock
요구사항을 충족할 수 없다고 판단하는 범위는 명시되지 않습니다. 단, 최소한 다음 조건들을 모두 충족하지 않는
T
는
Clock
로 적격이 되지 않습니다:
- 다음 qualified identifiers 각각은 유효하며 타입을 나타냅니다:
-
-
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
>
constexpr bool is_clock_v = is_clock < T > :: value ; |
(C++20부터) | |
std:: integral_constant 에서 상속됨
멤버 상수
|
value
[static]
|
true
만약
T
가
Clock
요구사항을 만족하면,
false
그렇지 않으면
(public static member constant) |
멤버 함수
|
operator bool
|
객체를
bool
로 변환,
value
반환
(public member function) |
|
operator()
(C++14)
|
value
반환
(public member function) |
멤버 타입
| 타입 | 정의 |
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 {}; |
참고 사항
만약
T
가 다른 조건들은
Clock
요구사항을 충족하지만,
T::is_steady
가
const
bool
타입이 아니거나,
T::now()
가
T
::
time_point
타입이 아닌 경우,
is_clock_v<T>
의 결과는 지정되지 않습니다.
예제
#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() {}