Namespaces
Variants

std::chrono::year_month:: year, std::chrono::year_month:: month

From cppreference.net
constexpr std:: chrono :: year year ( ) const noexcept ;
(1) (seit C++20)
constexpr std:: chrono :: month month ( ) const noexcept ;
(2) (seit C++20)

Ruft die in diesem year_month -Objekt gespeicherten Jahr- und Monatswerte ab.

Rückgabewert

1) Gibt den gespeicherten std::chrono::year -Wert zurück.
2) Gibt den gespeicherten std::chrono::month -Wert zurück.

Beispiel

#include <chrono>
#include <iostream>
int main()
{
    std::cout << std::boolalpha;
    constexpr auto ym{std::chrono::year(2021)/std::chrono::July};  
    std::cout << (ym.year() == std::chrono::year(2021)) << ' ';
    std::cout << (ym.month() == std::chrono::month(7)) << '\n';
}

Ausgabe:

true true