• 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::December;
    
        assert(--m == chrono::November);
        assert(m == chrono::November);
      }
    
      // 後置デクリメント
      {
        chrono::month m = chrono::December;
    
        assert(m-- == chrono::December);
        assert(m == chrono::November);
      }
    }
    

    出力

    バージョン

    言語

    • C++20

    処理系