std::chrono...ar_month::ok(3)
π NAME π
Bestie, welcome to the C++ Standard Libary page for the std::chrono...ar_month::ok(3) manpage π
β¨. The star of the show is std::chrono::year_month::ok - std::chrono::year_month::ok, and yes, thatβs the whole name. Iconic behavior only. π«Ά
πΈ Synopsis πΈ
constexpr bool ok() const noexcept;
since C++20 β¨
This is the check that asks: are the year and month values stored in this object valid? Thatβs the entire assignment, no cap. π¦
β Return value β
year().ok() && month().ok()
Itβs literally that expression β both parts gotta pass, or itβs a no from me ππ.
π Example π
// Run this code
#include <chrono>
using namespace std::chrono_literals;
int main()
{
constexpr std::chrono::year_month ym1{3030y, std::chrono::July};
static_assert(ym1.ok());
constexpr std::chrono::year_month ym2{std::chrono::year(2020)/16};
static_assert(!ym2.ok());
}
ym1 is valid, so static_assert(ym1.ok()); is slaying β¨. ym2 is built with std::chrono::year(2020)/16 and is not valid, so static_assert(!ym2.ok()); also holds. Periodt. π
Final sign-off, bestie π«Ά: source/version/date β http://cppreference.com Β· 2024.06.10 Β· std::chrono...ar_month::ok(3) ππ¦
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms