• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <chrono>

    std::chrono::operator/

    namespace std::chrono {
      constexpr year_month_day
        operator/(const year_month& ym, const day& d) noexcept; // (1) C++20
      constexpr year_month_day
        operator/(const year_month& ym, int d) noexcept;        // (2) C++20
    
      constexpr year_month_day_last
        operator/(const year_month& ym, last_spec) noexcept;    // (3) C++20
    
      constexpr year_month_weekday
        operator/(const year_month& ym,
                  const weekday_indexed& wdi) noexcept;         // (4) C++20
    
      constexpr year_month_weekday_last
        operator/(const year_month& ym,
                  const weekday_last& wdl) noexcept;            // (5) C++20
    }
    

    概要

    カレンダー要素同士をつなぎ合わせる。

    • (1) : year_month型とday型をつなぎ、年月日の情報をもつ型にまとめる
    • (2) : year_month型とint型での年の値をつなぎ、年月日の情報をもつ型にまとめる
    • (3) : year_month型と最終日をつなぎ、年、月、その月の最終日の情報をもつ型にまとめる
    • (4) : year_month型と指定したN回目の曜日をつなぎ、年、月、その月のN回目の指定した曜日の情報をもつ型にまとめる
    • (4) : year_month型と指定した最終回目の曜日をつなぎ、年、月、その月の最終回目の指定した曜日の情報をもつ型にまとめる

    戻り値

    例外

    投げない

    #include <cassert>
    #include <chrono>
    
    using namespace std::chrono;
    
    int main()
    {
      // (1), (2)
      assert((2020y/3)/1d == (year_month_day{2020y, March, 1d}));
      assert((2020y/3)/1 == (year_month_day{2020y, March, 1d}));
    
      // (3)
      assert((2020y/3)/last == (year_month_day_last{2020y, month_day_last{March}}));
    
      // (4)
      assert((2020y/3)/Sunday[1] == (year_month_weekday{2020y, March, Sunday[1]}));
    
      // (5)
      assert((2020y/3)/Sunday[last] == (year_month_weekday_last{2020y, March, Sunday[last]}));
    }
    

    出力

    バージョン

    言語

    • C++20

    処理系