std::chrono::year_month_weekday_last::operator+=, std::chrono::year_month_weekday_last::operator-=
來自 cppreference.com
< cpp | chrono | year_month_weekday_last
constexpr std::chrono::year_month_weekday_last& operator+=( const std::chrono::years& dy ) const noexcept; |
(1) | (C++20 起) |
constexpr std::chrono::year_month_weekday_last& operator+=( const std::chrono::months& dm ) const noexcept; |
(2) | (C++20 起) |
constexpr std::chrono::year_month_weekday_last& operator-=( const std::chrono::years& dy ) const noexcept; |
(3) | (C++20 起) |
constexpr std::chrono::year_month_weekday_last& operator-=( const std::chrono::months& dm ) const noexcept; |
(4) | (C++20 起) |
透過時長 dy 或 dm 修改 *this 所表示的時間點。
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)。
[編輯] 示例
執行此程式碼
輸出
2022-08-26 2022-10-28 2021-10-29
[編輯] 參閱
(C++20) |
將 year_month_weekday_last 和一些年份或月份加減(函式) |