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

履歴 編集

function
<chrono>

std::chrono::operator-(C++20)

namespace std::chrono {
  constexpr month operator-(const month& x, const months& y) noexcept; // (1) C++20
  constexpr months operator-(const month& x, const month& y) noexcept; // (2) C++20
}

概要

monthの減算を行う。

  • (1) : monthから時間間隔を減算する
  • (2) : month同士の差を求める

戻り値

  • (1) : return x + -y;
  • (2) : x.ok() == trueかつy.ok() == trueである場合、範囲[months{0}, months{11}]に収まるようxyの月の差を求めて返す。そうでなければ、未規定の値が返る

例外

投げない

#include <cassert>
#include <chrono>

namespace chrono = std::chrono;

int main()
{
  assert(chrono::March - chrono::months{2} == chrono::January);
  assert(chrono::March - chrono::February == chrono::months{1});

  assert(chrono::January - chrono::February == chrono::months{11});
}

出力

バージョン

言語

  • C++20

処理系

  • Clang: 8.0
  • GCC: (9.2時点で実装なし)
  • Visual C++: (2019 Update 3時点で実装なし)