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

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

πŸ¦‹ std::chrono...weekday::ok(3) πŸ¦‹

okay so bestie, this page comes from the C++ Standard Libary manual, and the title is std::chrono...weekday::ok(3). The NAME section is out here calling it std::chrono::month_weekday::ok, so keep both names in mind β€” iykyk πŸ’….


✨ NAME ✨

std::chrono::month_weekday::ok - std::chrono::month_weekday::ok


🌸 Synopsis 🌸

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

This little icon checks whether the contained month and weekday_indexed objects are valid. It’s giving vibe check for both of them, periodt ✨.


πŸŽ€ Return value πŸŽ€

It returns exactly this:

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

No cap, that’s the whole return value πŸ’–.


πŸ’– Example πŸ’–

Here’s the example, bestie β€” go run it and let the asserts do their thing 🫢:

// Run this code

#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());
}

Source: http://cppreference.com Β· version/date: 2024.06.10 Β· bye bestie, go flex that valid month_weekday energy πŸ’…βœ¨

πŸ“¦ where this page comes from