chrono_time_point

chrono_time_point (시간점 타입)

std::chrono::time_point는 특정 시계의 시점을 나타내는 클래스 템플릿이에요. 시계의 에포크 이후의 기간으로 표현돼요.

출처: cppreference

본문

std::chrono::time_point<chrono> 헤더에 정의된 클래스 템플릿이에요. C++11부터 사용 가능해요.

template< class Clock, class Duration = typename Clock::duration >
class time_point;

시계 Clock의 시점을 나타내요. 시계의 에포크(시작점) 이후의 시간 간격 Duration으로 표현돼요.

주요 멤버 함수

  • time_since_epoch() — 에포크 이후의 기간을 반환
  • operator+= / operator-= — 기간 더하기/빼기
  • 생성자

편의 타입 (C++20)

sys_time<Duration> = time_point<system_clock, Duration>, utc_time, tai_time, gps_time, file_time, local_time 등이 있어요.

예제 (Example)

#include <chrono>
#include <iostream>

int main()
{
    using namespace std::chrono;
    system_clock::time_point tp = system_clock::now();
    std::cout << time_point_cast<seconds>(tp).time_since_epoch().count() << '\n';
}

더 알아보기 (Learn more)

cppreference