次の方法で共有


weekday_indexed クラス

グレゴリオ暦の曜日を表す曜日を、その月における (第 1、第 2、第 3 などの) 曜日を示す [1, 5] の範囲のインデックスと組み合わせます。

構文

class weekday_indexed; // C++20

解説

weekday_indexed は、普通のコピー可能な、標準レイアウト クラス型です。

メンバー

名前 説明
コンストラクター 指定した曜日と値を使用して weekday_indexed を構成します。
ok 曜日の値が有効かどうかを確認します。
weekday 曜日の値を取得します。

非メンバー

名前 説明
operator== 2 つの weekday_indexed インスタンスが等しいかどうかを判断します。
operator<< 指定のストリームに weekday_indexed を出力します。

要件

ヘッダー:<chrono> C++20 以降

名前空間std::chrono:

コンパイラ オプション:/std:c++latest

Constructor

weekday 値とインデックスで初期化された weekday_indexed を構築します。

constexpr weekday_indexed(const chrono::weekday& wd, unsigned index) noexcept; // C++20

パラメーター

wd
作成した weekday_indexed クラスの曜日値。

index
その曜日のその月における曜日。 範囲は [1, 5] です。 たとえば、2 は、その曜日がその月の第 2 週になることを示します。

例: weekday_indexed を作成する

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
   constexpr auto wdi = weekday_indexed{Monday, 1};
   constexpr auto wdi2 = Monday[1];

    std::cout << wdi << ", " << wdi2;
    return 0;
}
Mon[1], Mon[1]

ok

この weekday_indexed に格納された値の範囲が有効であるかを確認します。

constexpr bool ok() const noexcept;

戻り値

週の曜日値が有効な範囲にある場合は true。 それ以外の場合は false

weekday

曜日の値を取得します。

constexpr chrono::weekday weekday() const noexcept;

戻り値

曜日の値。

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

int main()
{
    constexpr auto wdi = weekday_indexed{ Monday, 1 };
	std::cout << wdi << "\n";

    return 0;
}
Mon[1]

関連項目

weekday クラス
weekday_last クラス
<chrono>
ヘッダー ファイル リファレンス