名前空間
変種
操作

std::chrono::weekday_indexed

From cppreference.com
< cpp‎ | chrono
 
 
 
 
ヘッダー <chrono> で定義
class weekday_indexed;
(C++20以降)

クラスweekday_indexedは、weekday推定グレゴリオ暦における曜日の日を表す)と、範囲[15]の小さなインデックスnを組み合わせています。これは、ある月の最初、2番目、3番目、4番目、または5番目の曜日を表します。

weekday_indexedは、TriviallyCopyableStandardLayoutTypeです。

目次

[編集] メンバ関数

weekday_indexedを構築します。
(public member function) [編集]
格納されているweekdayにアクセスします。
(public member function) [編集]
格納されているインデックスにアクセスします。
(public member function) [編集]
曜日とインデックスの両方が有効かどうかをチェックします。
(public member function) [編集]

[編集] 非メンバ関数

2つのweekday_indexed値を比較します。
(function) [編集]
weekday_indexedをストリームに出力します。
(function template) [編集]

[編集] ヘルパークラス

weekday_indexed の書式設定サポート
(クラス テンプレートの特殊化) [edit]
std::chrono::weekday_indexedのハッシュサポート。
(クラステンプレートの特殊化)

[編集]

#include <chrono>
#include <iostream>
 
int main()
{
    using namespace std::chrono;
 
    constexpr weekday_indexed wi = Friday[2];
 
    // Indexed weekday can be used at any place where chrono::day can be used:
    constexpr year_month_weekday ymwd = 2021y / August / wi;
    static_assert(ymwd == August / wi / 2021y &&
                  ymwd == wi / August / 2021y);
    std::cout << ymwd << '\n';
 
    constexpr year_month_day ymd{ymwd}; // a conversion
    static_assert(ymd == 2021y / 8 / 13);
    std::cout << ymd << '\n';
}

実行結果の例

2021/Aug/Fri[2]
2021-08-13
English 日本語 中文(简体) 中文(繁體)