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

floor

  • 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>
    floor(const time_point<Clock, Duration>& tp);
}

概要

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

戻り値

return time_point<Clock, ToDuration>{floor<ToDuration>(tp.time_since_epoch())};
  • floor[link /reference/chrono/duration/floor.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 = floor<seconds>(mp);

  std::cout << sp.time_since_epoch().count() << std::endl;
}
  • floor[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]

出力

1

バージョン

言語

  • C++17

処理系

関連項目

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

参照