std::chrono::month_weekday_last:: month, std::chrono::month_weekday_last:: weekday_last
From cppreference.net
<
cpp
|
chrono
|
month weekday last
C++
Date and time library
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::chrono::month_weekday_last
| Member functions | ||||
|
month_weekday_last::month
month_weekday_last::weekday_last
|
||||
| Nonmember functions | ||||
| Helper classes | ||||
|
constexpr
std::
chrono
::
month
month
(
)
const
noexcept
;
|
(1) | (自 C++20 起) |
|
constexpr
std::
chrono
::
weekday_last
weekday_last
(
)
const
noexcept
;
|
(2) | (自 C++20 起) |
获取存储在 * this 中的 month 和 weekday_last 对象的副本。
返回值
1)
存储在
*
this
中的
std::chrono::month
对象的副本。
2)
存储在
*
this
中的
std::chrono::weekday_last
对象的副本。
示例
运行此代码
#include <chrono> #include <iostream> using namespace std::chrono; int main() { std::cout << std::boolalpha; auto mwdl{March/Friday[last]}; // 三月的最后一个星期五 auto ywdl{year(2024)/mwdl}; std::cout << (year_month_day{ywdl} == year_month_day{March/29/2024}) << ' '; // 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'; }
输出:
true true