std::chrono::year_month_weekday_last::operator+=, std::chrono::year_month_weekday_last::operator-=
来自 cppreference.cn
< cpp | chrono | year month weekday last
constexpr std::chrono::year_month_weekday_last& operator+=( const std::chrono::years& dy ) const noexcept; |
(1) | (since C++20) |
constexpr std::chrono::year_month_weekday_last& operator+=( const std::chrono::months& dm ) const noexcept; |
(2) | (since C++20) |
constexpr std::chrono::year_month_weekday_last& operator-=( const std::chrono::years& dy ) const noexcept; |
(3) | (since C++20) |
constexpr std::chrono::year_month_weekday_last& operator-=( const std::chrono::months& dm ) const noexcept; |
(4) | (since C++20) |
修改此 *this 表示的时间点,通过时长 dy 或 dm。
1) 等价于 *this = *this + dy;。
2) 等价于 *this = *this + dm;。
3) 等价于 *this = *this - dy;。
4) 等价于 *this = *this - dm;。
对于可以转换为 std::chrono::years 和 std::chrono::months 的时长,如果调用会产生歧义,则优先选择 years
重载 (1,3)。
[edit] 示例
运行此代码
输出
2022-08-26 2022-10-28 2021-10-29
[edit] 参见
(C++20) |
添加或减去 year_month_weekday_last 和一些年或月(函数) |