Skip to content

Latest commit

 

History

History
80 lines (60 loc) · 2.31 KB

time_point.md

File metadata and controls

80 lines (60 loc) · 2.31 KB

#time_point

namespace std {
namespace chrono {
  template <class Clock, class Duration = typename Clock::duration>
  class time_point;
}}

###概要 time_pointは、時間軸上の一点を表現するクラスである。 エポックと呼ばれるUNIX誕生の日時からの経過時間によって現在の時間を表す。

###メンバ関数 ####構築/コピー/破棄

(constructor) コンストラクタ

####観測

time_since_epoch エポックからの経過時間を取得する

####算術演算

operator+= 時間を進める
operator-= 時間を戻す

####特別な値

min 最小値
max 最大値

###メンバ型

clock 時計型Clock
duration 経過時間の型 Duration
rep 経過時間の数値型 Duration::rep
period 経過時間の単位 Duration::period

###例

#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
  // 現在日時を取得
  system_clock::time_point p = system_clock::now();

  // 出力
  std::time_t t = system_clock::to_time_t(p);
  std::cout << std::ctime(&t);
}

###出力例

Tue Oct 16 16:37:13 2012

##バージョン ###言語

  • C++11

###処理系

##参照