Skip to content

Latest commit

 

History

History
57 lines (40 loc) · 1009 Bytes

File metadata and controls

57 lines (40 loc) · 1009 Bytes

operator-=

  • chrono[meta header]
  • std::chrono[meta namespace]
  • year[meta class]
  • function[meta id-type]
  • cpp20[meta cpp]
constexpr year& operator-=(const years& y) noexcept; // (1) C++20

概要

yearの値に対して減算の複合代入を行う。

パラメータの型が、本クラスであるyearではなく、年単位の時間間隔を表すyearsであることに注意。

効果

  • (1) : *this = *this - y

戻り値

  • (1) : *this

例外

投げない

#include <cassert>
#include <chrono>

namespace chrono = std::chrono;

int main()
{
  chrono::year y{2020};

  y -= chrono::years{3};
  assert(static_cast<int>(y) == 2017);
}

出力

バージョン

言語

  • C++20

処理系

  • Clang: 8.0 [mark verified]
  • GCC: 9.2 [mark noimpl]
  • Visual C++: 2019 Update 3 [mark noimpl]