名前空間
変種
操作

std::chrono::year_month_weekday_last::ok

From cppreference.com
 
 
 
 
constexpr bool ok() const noexcept;
(C++20以降)

このオブジェクトが有効な日付を表しているかを確認します。year_month_weekday_last は、特定月の最終平日を表すため、年、月、曜日が有効であれば有効です。

[編集] 戻り値

year().ok() && month().ok() && weekday().ok()

[編集]

#include <cassert>
#include <chrono>
using namespace std::chrono;
 
int main()
{
    auto ymwdl{Tuesday[last]/11/2020};
    assert(ymwdl.ok());
    ymwdl = Tuesday[last]/-2/2021;
    assert(!ymwdl.ok());
    ymwdl += months(0); // Normalize month
    assert(ymwdl.ok());
}
English 日本語 中文(简体) 中文(繁體)