• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <chrono>

    std::chrono::operator-

    namespace std::chrono {
      constexpr weekday operator-(const weekday& x, const days& y) noexcept;    // (1) C++20
      constexpr days    operator-(const weekday& x, const weekday& y) noexcept; // (2) C++20
    }
    

    概要

    weekdayの減算を行う。

    • (1) : weekdayから日単位の時間間隔を引いた曜日を求める
    • (2) : 曜日間の差を日単位で求める

    戻り値

    • (1) : return x + -y;
    • (2) : x.ok() == trueかつy.ok() == trueである場合、範囲[days{0}, days{11}]に収まるようxyの曜日の差を日単位として求めて返す。そうでなければ、未規定の値が返る

    例外

    投げない

    #include <cassert>
    #include <chrono>
    
    namespace chrono = std::chrono;
    
    int main()
    {
      assert(chrono::Tuesday - chrono::days{3} == chrono::Saturday);
      assert(chrono::Tuesday - chrono::Saturday == chrono::days{3});
    }
    

    出力

    バージョン

    言語

    • C++20

    処理系