• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <chrono>

    std::chrono::month::operator++

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

    概要

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

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

    効果

    • (1) : *this += months{1}
    • (2) : ++(*this)

    戻り値

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

    例外

    投げない

    #include <cassert>
    #include <chrono>
    
    namespace chrono = std::chrono;
    
    int main()
    {
      // 前置インクリメント
      {
        chrono::month m = chrono::January;
    
        assert(++m == chrono::February);
        assert(m == chrono::February);
      }
    
      // 後置インクリメント
      {
        chrono::month m = chrono::January;
    
        assert(m++ == chrono::January);
        assert(m == chrono::February);
      }
    }
    

    出力

    バージョン

    言語

    • C++20

    処理系