• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <chrono>

    std::chrono::month::operator-=

    constexpr month& operator-=(const months& m) noexcept; // (1) C++20
    

    概要

    monthの値に対して減算の複合代入を行う。

    パラメータの型が、本クラスであるmonthではなく、月単位の時間間隔を表すmonthsであることに注意。

    効果

    • (1) : *this = *this - m

    戻り値

    • (1) : *this

    例外

    投げない

    #include <cassert>
    #include <chrono>
    
    namespace chrono = std::chrono;
    
    int main()
    {
      chrono::month m = chrono::December;
    
      m -= chrono::months{2};
      assert(m == chrono::October);
    }
    

    出力

    バージョン

    言語

    • C++20

    処理系