std::chrono..._weekday::ok(3)
πΈ NAME πΈ
okay so bestie, this is the std::chrono..._weekday::ok(3) page from the C++ Standard Libary (yes, βLibaryβ is literally how itβs spelled in the header β iconic typo behavior π
). The NAME section is out here saying std::chrono::year_month_weekday::ok and then saying std::chrono::year_month_weekday::ok again, so itβs giving βsay it twice so it sticks.β We love a consistent queen β¨.
π¦ Synopsis π¦
constexpr bool ok() const noexcept; (since C++20)
It checks if this year_month_weekday object represents a valid date. Thatβs the whole vibe check π«Ά.
π Return value π
Itβs true if this year_month_weekday object represents a valid date β and by that we mean this whole thing is true:
year().ok() && month().ok() && weekday_indexed().ok()
β¦AND there are at least index() weekday()s in the specified year and month. Otherwise? false, bestie. No cap π.
π Example π
The source says // Run this code, so go off:
#include <cassert>
#include <chrono>
int main()
{
auto ymwdi{std::chrono::Wednesday[1]/1/2021};
assert(ymwdi.ok());
ymwdi =
std::chrono::year(2021)/std::chrono::month(1)/std::chrono::Wednesday[42];
assert(!ymwdi.ok());
}
Signing off with the footer energy, fr fr: source/version/date is http://cppreference.com, 2024.06.10, and the page tag is std::chrono..._weekday::ok(3). Bye bestie β go check your dates ππ¦β¨
π¦ 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