最終更新日時(UTC):
が更新

履歴 編集

function
<chrono>

std::chrono::hh_mm_ss::operator precision(C++20)

constexpr explicit operator precision() const noexcept; // (1) C++20

概要

時:分:秒、秒未満をもつdurationオブジェクトに明示的に変換する。

戻り値

return to_duration();

#include <cassert>
#include <chrono>

namespace chrono = std::chrono;
using namespace std::chrono_literals;

int main()
{
  chrono::hh_mm_ss time1{15h + 30min + 20s};
  assert(chrono::seconds{time1} == 15h + 30min + 20s);

  chrono::hh_mm_ss time2{-(15h + 30min + 20s)};
  assert(chrono::seconds{time2} == -(15h + 30min + 20s));

  chrono::hh_mm_ss time3{15h + 30min + 20s + 123ms};
  assert(chrono::milliseconds{time3} == 15h + 30min + 20s + 123ms);
}

出力

バージョン

言語

  • C++20

処理系