Namespaces
Variants

std::chrono:: clock_time_conversion

From cppreference.net
헤더 파일에 정의됨 <chrono>
template < class Dest, class Source >
struct clock_time_conversion { } ;
(C++20부터)

std::chrono::clock_time_conversion std::chrono::time_point Source 클록을 Dest 클록으로 변환하는 방법을 지정하는 특성(trait)입니다. 이는 std:: chrono :: time_point < Source, Duration > 타입의 인수를 받아들이고 동일한 시간점을 나타내는 std:: chrono :: time_point < Dest, OtherDuration > 를 반환하는 const-callable operator() 를 제공함으로써 이를 수행합니다. 반환된 시간점의 지속 시간(duration)은 각 특수화에 따라 다양한 방식으로 소스 지속 시간에서 계산됩니다. clock_time_conversion 는 일반적으로 std::chrono::clock_cast 를 통해서만 간접적으로 사용됩니다.

프로그램은 템플릿 매개변수 중 적어도 하나가 사용자 정의 클록 타입인 경우 clock_time_conversion 를 특수화할 수 있습니다.

기본 템플릿은 빈 구조체입니다. 표준은 다음과 같은 특수화를 정의합니다:

template < class Clock >
struct clock_time_conversion < Clock, Clock > ;
(1) (C++20부터)
template <>
struct clock_time_conversion < std:: chrono :: system_clock , std:: chrono :: system_clock > ;
(2) (C++20부터)
template <>
struct clock_time_conversion < std:: chrono :: utc_clock , std:: chrono :: utc_clock > ;
(3) (C++20부터)
template <>
struct clock_time_conversion < std:: chrono :: system_clock , std:: chrono :: utc_clock > ;
(4) (C++20부터)
template <>
struct clock_time_conversion < std:: chrono :: utc_clock , std:: chrono :: system_clock > ;
(5) (C++20부터)
template < class Clock >
struct clock_time_conversion < Clock, std:: chrono :: system_clock > ;
(6) (C++20부터)
template < class Clock >
struct clock_time_conversion < std:: chrono :: system_clock , Clock > ;
(7) (C++20부터)
template < class Clock >
struct clock_time_conversion < Clock, std:: chrono :: utc_clock > ;
(8) (C++20부터)
template < class Clock >
struct clock_time_conversion < std:: chrono :: utc_clock , Clock > ;
(9) (C++20부터)
1-3) 항등 변환: operator() 는 인수의 복사본을 반환합니다.
4,5) std::chrono::sys_time std::chrono::utc_time 간의 변환: operator() 는 각각 std::chrono::utc_clock::to_sys std::chrono::utc_clock::from_sys 를 호출합니다.
6,7) Clock from_sys to_sys 를 지원할 때 std::chrono::sys_time 과의 상호 변환: operator() 는 각각 Clock :: to_sys Clock :: from_sys 를 호출합니다.
8,9) Clock from_utc to_utc 를 지원할 때 std::chrono::utc_time 와의 상호 변환: operator() 는 각각 Clock :: to_utc Clock :: from_utc 를 호출합니다.

목차

멤버 함수

각 특수화는 암시적으로 선언된 기본 생성자, 복사 생성자, 이동 생성자, 복사 할당 연산자, 이동 할당 연산자 및 소멸자를 가집니다.

std::chrono::clock_time_conversion:: operator()

template < class Duration >

std:: chrono :: time_point < Clock, Duration >

operator ( ) ( const std:: chrono :: time_point < Clock, Duration > & t ) const ;
(1) (전문화 멤버 (1) )
template < class Duration >

std:: chrono :: sys_time < Duration >

operator ( ) ( const std:: chrono :: sys_time < Duration > & t ) const ;
(2) (전문화 멤버 (2) )
template < class Duration >

std:: chrono :: utc_time < Duration >

operator ( ) ( const std:: chrono :: utc_time < Duration > & t ) const ;
(3) (전문화 멤버 (3) )
template < class Duration >

std:: chrono :: sys_time < Duration >

operator ( ) ( const std:: chrono :: utc_time < Duration > & t ) const ;
(4) (전문화 멤버 (4) )
template < class Duration >

std:: chrono :: utc_time < Duration >

operator ( ) ( const std:: chrono :: sys_time < Duration > & t ) const ;
(5) (전문화 멤버 (5) )
template < class Duration >

auto operator ( ) ( const std:: chrono :: sys_time < Duration > & t ) const

- > decltype ( Clock :: from_sys ( t ) ) ;
(6) (전문화 멤버 (6) )
template < class Duration >

auto operator ( ) ( const std:: chrono :: time_point < SourceClock, Duration > & t ) const

- > decltype ( Clock :: to_sys ( t ) ) ;
(7) (전문화 멤버 (7) )
template < class Duration >

auto operator ( ) ( const std:: chrono :: utc_time < Duration > & t ) const

- > decltype ( Clock :: from_utc ( t ) ) ;
(8) (전문화 멤버 (8) )
template < class Duration >

auto operator ( ) ( const std:: chrono :: time_point < Clock, Duration > & t ) const

- > decltype ( Clock :: to_utc ( t ) ) ;
(9) (전문화 멤버 (9) )

인수를 대상 클록으로 변환합니다. std::chrono::time_point

1-3) 항등 변환. t 를 변경 없이 반환합니다.
6) Clock :: from_sys ( t ) 를 반환합니다. 이 오버로드는 표현식 Clock :: from_sys ( t ) 이 올바르게 형성된 경우에만 오버로드 해결에 참여합니다. Clock :: from_sys ( t ) std:: chrono :: time_point < Clock, Duration > 를 반환하지 않으면 프로그램의 형식이 올바르지 않습니다. 여기서 Duration std::chrono::duration 의 유효한 특수화입니다.
7) Clock :: to_sys ( t ) 를 반환합니다. 이 오버로드는 표현식 Clock :: to_sys ( t ) 이 올바른 형식일 때만 오버로드 해결에 참여합니다. Clock :: to_sys ( t ) std:: chrono :: sys_time < Duration > 를 반환하지 않으면 프로그램은 형식이 올바르지 않습니다. 여기서 Duration std::chrono::duration 의 유효한 특수화입니다.
8) Clock :: from_utc ( t ) 를 반환합니다. 이 오버로드는 표현식 Clock :: from_utc ( t ) 이 올바른 형태일 때만 오버로드 해결에 참여합니다. Clock :: from_utc ( t ) std:: chrono :: time_point < Clock, Duration > 를 반환하지 않으면 프로그램은 형식이 잘못됩니다. 여기서 Duration std::chrono::duration 의 유효한 특수화 중 하나여야 합니다.
9) Clock :: to_utc ( t ) 를 반환합니다. 이 오버로드는 Clock :: to_utc ( t ) 표현식이 well-formed인 경우에만 오버로드 해결에 참여합니다. Clock :: to_utc ( t ) std:: chrono :: utc_time < Duration > 를 반환하지 않으면 프로그램은 ill-formed입니다. 여기서 Duration std::chrono::duration 의 유효한 특수화입니다.

매개변수

t - 변환할 시간 지점

반환값

위에서 설명한 변환의 결과:

1-3) t .
6) Clock :: from_sys ( t ) .
7) Clock :: to_sys ( t ) .
8) Clock :: from_utc ( t ) .
9) Clock :: to_utc ( t ) .

참고 항목

(C++20)
한 클록의 시간 포인트를 다른 클록으로 변환
(함수 템플릿)