std::chrono::month_weekday_last::month, std::chrono::month_weekday_last::weekday_last
Von cppreference.com
< cpp | chrono | month weekday last
| constexpr std::chrono::month month() const noexcept; |
(1) | (seit C++20) |
| constexpr std::chrono::weekday_last weekday_last() const noexcept; |
(2) | (seit C++20) |
Ruft eine Kopie der in *this gespeicherten Objekte month und weekday_last ab.
[bearbeiten] Rückgabewert
1) Eine Kopie des in *this gespeicherten Objekts std::chrono::month.
2) Eine Kopie des in *this gespeicherten Objekts std::chrono::weekday_last.
[bearbeiten] Beispiel
Führen Sie diesen Code aus
#include <chrono> #include <iostream> using namespace std::chrono; int main() { std::cout << std::boolalpha; auto mwdl{March/Friday[last]}; // Last Friday in a March auto ywdl{year(2024)/mwdl}; std::cout << (year_month_day{ywdl} == year_month_day{March/29/2024}) << ' '; // Last Friday of the next month, in 2024 mwdl = {(mwdl.month() + months(1))/mwdl.weekday_last()}; ywdl = {year(2024)/mwdl}; std::cout << (year_month_day{ywdl} == year_month_day{April/26/2024}) << '\n'; }
Ausgabe
true true