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

履歴 編集

function
<chrono>

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

constexpr year& operator++() noexcept;   // (1) C++20
constexpr year operator++(int) noexcept; // (2) C++20

概要

yearの値をインクリメントする

  • (1) : 前置インクリメント
  • (2) : 後置インクリメント

効果

メンバ変数として保持しているint型の年を表す値yがあるとして、

  • (1) : ++y
  • (2) : ++(*this)

戻り値

  • (1) : *this
  • (2) : この関数が呼ばれる前の*thisのコピーを返す

例外

投げない

#include <cassert>
#include <chrono>

namespace chrono = std::chrono;

int main()
{
  // 前置インクリメント
  {
    chrono::year y{2019};

    assert(static_cast<int>(++y) == 2020);
    assert(static_cast<int>(y) == 2020);
  }

  // 後置インクリメント
  {
    chrono::year y{2019};

    assert(static_cast<int>(y++) == 2019);
    assert(static_cast<int>(y) == 2020);
  }
}

出力

バージョン

言語

  • C++20

処理系

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