std::chrono::year_month::jahr, std::chrono::year_month::monat
Von cppreference.com
< cpp | chrono | year month
| constexpr std::chrono::year jahr() 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 Jahres- und Monatswerte ab.
[bearbeiten] Rückgabewert
1) Gibt den gespeicherten std::chrono::year-Wert zurück.
2) Gibt den gespeicherten std::chrono::month-Wert zurück.
[bearbeiten] Beispiel
Führen Sie diesen Code aus
#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