Namespaces
Variants

std::chrono::month_day_last:: month

From cppreference.net
constexpr std:: chrono :: month month ( ) const noexcept ;
(C++20以降)

格納されている std::chrono::month オブジェクトのコピーを取得します * this から。

戻り値

std::chrono::month オブジェクトのコピーが * this に格納されています。

#include <chrono>
#include <iostream>
using namespace std::chrono;
int main()
{
    std::cout << std::boolalpha;
    auto mdl{February/last}; // 2月の最終日
    auto ymdl{year(2020) / mdl};
    std::cout << (year_month_day{ymdl} == year_month_day{February/29/2020}) << ' ';
    mdl = (mdl.month() + months(1)) / last; // 2020年の翌月の最終日
    ymdl = year(2020) / mdl;
    std::cout << (year_month_day{ymdl} == year_month_day{March/31/2020}) << '\n';
}

出力:

true true