std::chrono...day_last::ok(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 NAME 🌸

std::chrono::month_day_last::ok β€” okay so this is the ok() member of std::chrono::month_day_last, and the page header is literally std::chrono...day_last::ok(3) from the C++ Standard Libary manual. Yes bestie, that's the whole vibe. πŸ’–

✨ Synopsis ✨

Here's the exact signature, no cap:

constexpr bool ok() const noexcept;  (since C++20)

It's constexpr, it's noexcept, and it's been around since C++20. Slay. ✨

This function checks if the month object stored in *this is valid. That's the entire mission. 🎯

🌈 Return value 🌈

It returns month().ok(). That's it. That's the return value. πŸ’…

πŸŽ€ Example πŸŽ€

// Run this code

#include <cassert>
#include <chrono>

int main()
{
    auto mdl{std::chrono::February/std::chrono::last};
    assert(mdl.ok());
    mdl = {std::chrono::month(42)/std::chrono::last};
    assert(!mdl.ok());
}

The asserts are doing the vibe check: February/last passes, and month(42)/last does not. 🫢


Source/version: http://cppreference.com, dated 2024.06.10 β€” mwah, bye bestie πŸ’…πŸ’–

πŸ“¦ where this page comes from