Namespaces
Variants

std::chrono::year:: year

From cppreference.net
year ( ) = default ;
(1) (seit C++20)
constexpr explicit year ( int y ) noexcept ;
(2) (seit C++20)

Konstruiert ein year -Objekt.

1) Standardkonstruktor lässt den Jahreswert uninitialisiert.
2) Falls y im Bereich [ - 32767 , 32767 ] liegt, konstruiert ein year -Objekt mit dem Jahreswert y . Andernfalls ist der gehaltene Wert nicht spezifiziert.

Beispiel

#include <chrono>
#include <iostream>
int main()
{
    using namespace std::chrono;
    constexpr int leap_years = []
    {
        int count{};
        for (int i{year::min()}; i <= int{year::max()}; ++i)
            if (year{i}.is_leap()) // verwendet Konstruktor (2)
                ++count;
        return count;
    } ();
    static_assert(15891 == leap_years);
    std::cout << "Es gibt " << leap_years << " Schaltjahre im Bereich ["
              << int(year::min()) << ", " << int(year::max()) << "].\n";
}

Ausgabe:

Es gibt 15891 Schaltjahre im Bereich [-32767, 32767].