std::chrono::month_day::ok(3)
π std::chrono::month_day::ok(3) π
okay bestie, welcome to the std::chrono::month_day::ok page from the C++ Standard Libary manual β yes, thatβs the manual name, and weβre keeping it exactly as-is π
πΈ NAME πΈ
std::chrono::month_day::ok β std::chrono::month_day::ok
β¨ Synopsis β¨
constexpr bool ok() const noexcept; (since C++20)
This one determines whether a month_day stores a valid month-day combination. Itβs literally the vibe check for your month + day pair π
The combination is valid if month() represents a valid month (month().ok() == true), unsigned{day()} >= 1, and unsigned{day()} <= D, where D is the number of days in the month represented by month(). The number of days in February is considered to be 29.
π«Ά Return value π«Ά
true if the month and day combination is valid, otherwise false.
π Example π
// Run this code
#include <chrono>
#include <iostream>
int main()
{
std::cout << std::boolalpha;
constexpr auto md1{std::chrono::July/15};
std::cout << (md1.ok()) << ' ';
constexpr std::chrono::month_day md2{std::chrono::month(14),
std::chrono::day(42)};
std::cout << (md2.ok()) << ' ';
constexpr auto md3{std::chrono::February/29};
std::cout << (md3.ok()) << '\n';
}
β Output β
true false true
and thatβs the whole page, bestie! the original footer said source/version http://cppreference.com, date 2024.06.10, and manual title std::chrono::month_day::ok(3) β periodt β¨π
π¦
π¦ 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