std::chrono::weekday::ok
Min standard notice:
Checks if the weekday value stored in *this is in the valid range, i.e., [0,6].
# Declarations
constexpr bool ok() const noexcept;
(since C++20)
# Return value
true if the weekday value stored in *this is in the range [0,6]. Otherwise false.
# Example
#include <chrono>
#include <iomanip>
#include <iostream>
#include <locale>
#include <string>
struct weekday_ok : std::numpunct<char>
{
std::string do_truename() const override { return " (is valid weekday)"; }
std::string do_falsename() const override { return " (is not valid weekday)"; }
};
int main()
{
std::cout.imbue(std::locale(std::cout.getloc(), new weekday_ok));
std::cout << std::boolalpha;
for (const unsigned u : {0 /* Sun */, 1 /* Mon */, 6, 7 /* Sun */, 8, 9})
{
const std::chrono::weekday wd{u};
std::cout << "u: " << u << "; wd: " << wd.c_encoding() << wd.ok() << '\n';
}
}