Share via


year_month_weekday_last クラス

特定の年、月、月の最終曜日。

構文

class year_month_weekday_last; // C++20

解説

year_month_weekday_last では、年と月指向の算術演算がサポートされますが、日指向の算術演算はサポートされません。 日指向の算術演算の場合は、日指向の算術演算をサポートする sys_days 変換を使用して、sys_days に変換します。

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

メンバー

名前 説明
Constructor 指定した月と曜日を使用して year_month_weekday_last を構成します。
month 月の値を取得します。
ok year_month_weekday_last が有効かどうかを確認します。
operator+= 指定した月数または年数を加算します。
operator-= 指定した月数または年数を減算します。
operator local_days system_clock エポックからこの year_month_weekday_last への日数を local_days として取得します。
operator sys_days system_clock エポックからこの year_month_weekday_last への日数を sys_days として取得します。
weekday 曜日を取得します。
weekday_last この year_month_weekday_last に格納されている weekday_last を取得します。
year 年を取得します。

非メンバー

名前 説明
operator+ 月または年を加算します。
operator- 月または年を減算します。
operator== 2 つの year_month_weekday_last 値が等しいかどうかを判断します。
operator<< 指定したストリームに year_month_weekday_last を出力します。

要件

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

名前空間std::chrono:

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

Constructor

year_month_weekday_last を構築します。

constexpr year_month_weekday_last(const year& y, const month& m, const weekday_last& wdl) noexcept

パラメーター

m
month の値です。

wdl
weekday_last の値です。

y
year の値です。

日付の指定に使用される C++20 構文の詳細については、以下を参照してください。 operator/

例: year_month_weekday_last を作成する

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

using namespace std::chrono;

int main()
{
    year_month_weekday_last ymwl{ 1997y / January / Wednesday[last] };
    std::cout << ymwl << '\n';
    
    return 0;
}
1997/Jan/Wed[last]

month

月の値を取得します。

constexpr month month() const noexcept;

戻り値

month の値です。

ok

この year_month_weekday_last に格納されている値が有効かどうかを確認します。 この関数が true を返すには、この year_month_weekday_last に格納されている yearmonthweekday_last はすべて ok である必要があります。 それ以外の場合、false を返します。

constexpr bool ok() const noexcept;

戻り値

year_month_weekday_last 値が有効な場合は true。 それ以外の場合は false
year_month_weekday_last が有効なのは、monthweekday_indexed、および year がすべて有効な場合です。

operator+=

この year_month_weekday_last に月または年を追加します。

1) constexpr year_month_weekday_last& operator+=(const months& m) noexcept;
2) constexpr year_month_weekday_last& operator+=(const years& y) noexcept;

パラメーター

m
加算する月数。

y
加算する年数。

戻り値

加算の結果を反映する *this

例: operator+=

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

using namespace std::chrono;

int main()
{
    year_month_weekday_last ymwl{ year(1997) / January / Wednesday[last] };
    std::cout << ymwl << '\n';

    ymwl += months{ 1 };
    ymwl += years{ 1 };

    std::cout << ymwl << '\n';
    
    return 0;
}
1997/Jan/Wed[last]
1998/Feb/Wed[last]

operator-=

この year_month_weekday_last から月または年を減算します。

1) constexpr year_month_weekday_last& operator-=(const months& m) noexcept;
2) constexpr year_month_weekday_last& operator-=(const years& y) noexcept;

パラメーター

m
減算する月数。

y
減算する年数。

戻り値

減算の結果を反映する *this

例: operator-=

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

using namespace std::chrono;

int main()
{
    year_month_weekday_last ymwl{ year(1997) / January / Wednesday[last] };
    std::cout << ymwl << '\n';

    ymwl -= months{ 1 };
    ymwl -= years{ 1 };

    std::cout << ymwl << '\n';
    
    return 0;
}
1997/Jan/Wed[last]
1995/Dec/Wed[last]

operator local_days

system_clock エポック (1/1/1970) からこの year_month_weekday_last への日数を local_days として取得します

constexpr explicit operator local_days() const noexcept;

戻り値

ok() の場合、日数を local_days{sys_days{*this}.time_since_epoch()} として返します。 それ以外の場合、返される値は指定されません。

operator sys_days

system_clock エポック (1/1/1970) からこの year_month_day への日数を sys_days として取得します。

constexpr operator sys_days() const noexcept;

戻り値

ok() == true の場合、sys_days が返されます。これは、year() / month() の最後の weekday() を表します (注: / は、除算ではなく日付演算子です)。 それ以外の場合、返される値は指定されません。

weekday

weekday を取得します。

constexpr weekday weekday() const noexcept;

戻り値

weekday

weekday_last

この year_month_weekday_last に格納されている weekday_last を取得します。

constexpr weekday_indexed weekday_last() const noexcept;

戻り値

weekday_last

year

年の値を取得します。

constexpr year year() const noexcept;

戻り値

year の値です。

関連項目

<chrono>
year
year_month
year_month_day
year_month_day_last
year_month_weekday
operator/
ヘッダー ファイル リファレンス