• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <chrono>

    std::chrono::weekday::operator++

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

    概要

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

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

    効果

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

    戻り値

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

    例外

    投げない

    #include <cassert>
    #include <chrono>
    
    namespace chrono = std::chrono;
    
    int main()
    {
      // 前置インクリメント
      {
        chrono::weekday w = chrono::Sunday;
    
        assert(++w == chrono::Monday);
        assert(w == chrono::Monday);
      }
    
      // 後置インクリメント
      {
        chrono::weekday w = chrono::Sunday;
    
        assert(w++ == chrono::Sunday);
        assert(w == chrono::Monday);
      }
    }
    

    出力

    バージョン

    言語

    • C++20

    処理系