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

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

πŸ’– NAME πŸ’–

std::chrono::weekday_indexed::ok - std::chrono::weekday_indexed::ok β€” yep, that’s the NAME entry, and it’s iconic πŸ’…

okay so bestie, welcome to the std::chrono::weekday_indexed::ok page in the C++ Standard Libary manual ✨ this is the little function that vibe-checks whether the weekday and the index inside your std::chrono::weekday_indexed are both valid 🫢

✨ Synopsis ✨

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

It checks if the weekday object and the index stored in *this are both valid πŸ‘‘ no cap.

πŸ’– Return value πŸ’–

true if weekday().ok() == true and index() is in the range [1, 5]. Otherwise false πŸ’€

🧚 Example 🧚

// Run this code

#include <chrono>
#include <iostream>

int main()
{
    std::cout << std::boolalpha;

    std::chrono::weekday_indexed wdi{std::chrono::Tuesday[2]};
    std::cout << (wdi.ok()) << ' ';
    wdi = {std::chrono::weekday(42)[2]};
    std::cout << (wdi.ok()) << ' ';
    wdi = {std::chrono::Tuesday[-4]};
    std::cout << (wdi.ok()) << '\n';
}

🌈 Output: 🌈

true false false

made with love πŸ’– source: http://cppreference.com Β· version/date: 2024.06.10 Β· std::chrono...indexed::ok(3) πŸŽ€

πŸ“¦ where this page comes from