Namespaces
Variants

std::chrono::day:: ok

From cppreference.net
< cpp ‎ | chrono ‎ | day
constexpr bool ok ( ) const noexcept ;
(seit C++20)

Überprüft, ob der in * this gespeicherte Tageswert im gültigen Bereich liegt, d.h. [ 1 , 31 ] .

Rückgabewert

true wenn der in * this gespeicherte Tageswert im Bereich [ 1 , 31 ] liegt. Andernfalls false .

Beispiel

#include <chrono>
using namespace std::chrono_literals;
constexpr std::chrono::day d0{00};
constexpr std::chrono::day d1{13};
constexpr std::chrono::day d2{42};
static_assert
(
    d0 == 0d && !d0.ok() &&
    d1 == 13d && d1.ok() &&
    d2 == 42d && !d2.ok()
);
int main() {}

Siehe auch

ruft den gespeicherten Tageswert ab
(öffentliche Elementfunktion)