名前空間
変種
操作

std::chrono::month_weekday::ok

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

格納されている month および weekday_indexed オブジェクトが有効かどうかを確認します。

[編集] 戻り値

month().ok() && weekday_indexed().ok()

[編集]

#include <cassert>
#include <chrono>
 
int main()
{
    auto mwdi{std::chrono::March/std::chrono::Friday[1]};
    assert(mwdi.ok());
 
    mwdi = {std::chrono::month(17)/std::chrono::Friday[1]}; 
    assert(not mwdi.ok());
 
    mwdi = {std::chrono::March/std::chrono::Friday[-4]}; 
    assert(not mwdi.ok());
}
English 日本語 中文(简体) 中文(繁體)