Skip to content

Latest commit

 

History

History
108 lines (81 loc) · 2.76 KB

File metadata and controls

108 lines (81 loc) · 2.76 KB

operator+

  • chrono[meta header]
  • std::chrono[meta namespace]
  • function[meta id-type]
  • cpp20[meta cpp]
namespace std::chrono {
  constexpr year_month_weekday
    operator+(const year_month_weekday_last& ymwdl,
              const months& dm) noexcept;                     // (1) C++20
  constexpr year_month_weekday
    operator+(const months& dm,
              const year_month_weekday_last& ymwdl) noexcept; // (2) C++20

  constexpr year_month_weekday
    operator+(const year_month_weekday_last& ymwdl,
              const years& dy) noexcept;                      // (3) C++20
  constexpr year_month_weekday
    operator+(const years& dy,
              const year_month_weekday_last& ymwdl) noexcept; // (4) C++20
}

概要

year_month_weekday_lastの加算を行う。

  • (1) : year_month_weekday_lastに月の時間間隔を加算する
  • (2) : 月の時間間隔にyear_month_weekday_lastを加算する
  • (3) : year_month_weekday_lastに年の時間間隔を加算する
  • (4) : 年の時間間隔にyear_month_weekday_lastを加算する

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

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

戻り値

  • (1) :
return (ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last();
  • ymwdl.year()[link year.md]
  • ymwdl.month()[link month.md]
  • ymwdl.weekday_last()[link weekday_last.md]
  • (2) :
return ymwdl + dm;
  • (3) :
return (ymwdl.year() + dy) / ymwdl.month() / ymwdl.weekday_last();
  • ymwdl.year()[link year.md]
  • ymwdl.month()[link month.md]
  • ymwdl.weekday_last()[link weekday_last.md]
  • (4) :
return ymwdl + dy;

例外

投げない

#include <cassert>
#include <chrono>

using namespace std::chrono;

int main()
{
  assert(2020y/2/Sunday[last] + months{1} == 2020y/3/Sunday[last]);
  assert(2019y/3/Sunday[last] + years{1} == 2020y/3/Sunday[last]);
}
  • 2019y[link /reference/chrono/year/op_y.md]
  • 2020y[link /reference/chrono/year/op_y.md]
  • Sunday[link /reference/chrono/weekday_constants.md]
  • last[link /reference/chrono/last_spec.md]

出力

バージョン

言語

  • C++20

処理系

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

参照