• 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::Saturday);
        assert(w == chrono::Saturday);
      }
    
      // 後置デクリメント
      {
        chrono::weekday w = chrono::Sunday;
    
        assert(w-- == chrono::Sunday);
        assert(w == chrono::Saturday);
      }
    }
    

    出力

    バージョン

    言語

    • C++20

    処理系