Namespaces
Variants

std::chrono::year:: year

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

Construit un objet year .

1) Le constructeur par défaut laisse la valeur de l'année non initialisée.
2) Si y est dans l'intervalle [ - 32767 , 32767 ] , construit un objet year contenant la valeur d'année y . Sinon, la valeur contenue est non spécifiée.

Exemple

#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()) // utilise le constructeur (2)
                ++count;
        return count;
    } ();
    static_assert(15891 == leap_years);
    std::cout << "Il y a " << leap_years << " années bissextiles dans la plage ["
              << int(year::min()) << ", " << int(year::max()) << "].\n";
}

Sortie :

Il y a 15891 années bissextiles dans la plage [-32767, 32767].