Skip to content

Latest commit

 

History

History
77 lines (59 loc) · 1.92 KB

File metadata and controls

77 lines (59 loc) · 1.92 KB

ceil

  • chrono[meta header]
  • std::chrono[meta namespace]
  • function[meta id-type]
  • cpp17[meta cpp]
namespace std::chrono {
  template <class ToDuration, class Clock, class Duration>
  constexpr time_point<Clock, ToDuration>
    ceil(const time_point<Clock, Duration>& tp);
}

概要

分解能が低いtime_pointに変換する際に、天井関数 (正の無限大方向への丸め、切り上げ) による丸めを行う。

戻り値

return time_point<Clock, ToDuration>{ceil<ToDuration>(tp.time_since_epoch())};
  • ceil[link /reference/chrono/duration/ceil.md]
  • tp.time_since_epoch()[link time_since_epoch.md]

#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
  using MTimePoint = time_point<system_clock, milliseconds>;
  using STimePoint = time_point<system_clock, seconds>;

  MTimePoint mp{milliseconds(1500)};
  STimePoint sp = ceil<seconds>(mp);

  std::cout << sp.time_since_epoch().count() << std::endl;
}
  • ceil[color ff0000]
  • milliseconds[link /reference/chrono/milliseconds.md]
  • seconds[link /reference/chrono/seconds.md]
  • system_clock[link /reference/chrono/system_clock.md]
  • sp.time_since_epoch()[link time_since_epoch.md]
  • count()[link /reference/chrono/duration/count.md]

出力

2

バージョン

言語

  • C++17

処理系

関連項目

名前 説明
time_point_cast ゼロ方向への丸め
floor 負の無限大方向への丸め
round 偶数方向への丸め

参照