次の方法で共有


weekday_last クラス

月の最後の曜日を表します。

構文

class weekday_last; // C++20

解説

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

メンバー

コンストラクター

名前 説明
weekday_last 指定した曜日の値を使用して weekday_last を構成します。

関数

名前 説明
ok 曜日の値が有効かどうかを確認します。
weekday 曜日の値を取得します。

演算子

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

要件

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

名前空間std::chrono:

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

Constructor

weekday 値で初期化された weekday_last を構築します。

constexpr explicit weekday_last(const chrono::weekday& wd) noexcept; // C++20

パラメーター

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

解説

weekdayoperator[] を使用すると、weekday_last を簡単に構築できます。 次の例を見てください。

ok

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

constexpr bool ok() const noexcept;

戻り値

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

weekday

曜日の値を取得します。

constexpr chrono::weekday weekday() const noexcept;

戻り値

曜日の値。

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

using namespace std::chrono;

int main()
{
    constexpr auto wdl{ Monday[last] }; // wdl is the last Monday of an unspecified month
    std::cout << wdl.weekday() << "\n";

    return 0;
}
Mon

関連項目

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