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

履歴 編集

function
<chrono>

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

namespace std::chrono {
  constexpr year_month_weekday_last
    operator-(const year_month_weekday_last& ymwdl,
              const months& dm) noexcept;           // (1) C++20
  constexpr year_month_weekday_last
    operator-(const year_month_weekday_last& ymwdl,
              const years& dy) noexcept;            // (2) C++20
}

概要

year_month_weekday_lastの減算を行う。

  • (1) : year_month_weekday_lastから月の時間間隔を減算する
  • (2) : year_month_weekday_lastから年の時間間隔を減算する

テンプレートパラメータ制約

  • (1) : monthsパラメータに指定した引数がyearsに変換可能である場合、yearsへの暗黙変換は、monthsへの暗黙変換よりも劣る

戻り値

  • (1) : return ymwdl + (-dm);
  • (2) : return ymwdl + (-dy);

例外

投げない

#include <cassert>
#include <chrono>

using namespace std::chrono;

int main()
{
  assert(2020y/4/Sunday[last] - months{1} == 2020y/3/Sunday[last]);
  assert(2021y/3/Sunday[last] - years{1} == 2020y/3/Sunday[last]);
}

出力

バージョン

言語

  • C++20

処理系

参照