CppDS.com

C++ 98 11 14 17 20 手册

std::chrono::year_month::operator+=, std::chrono::year_month::operator-=

来自cppreference.com
< cpp‎ | chrono‎ | year month

 
 
工具库
通用工具
日期和时间
函数对象
格式化库 (C++20)
(C++11)
关系运算符 (C++20 中弃用)
整数比较函数
(C++20)
swap 与类型运算
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
常用词汇类型
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

初等字符串转换
(C++17)
(C++17)
 
日期和时间工具
(C++11)
(C++11)
当天时刻
(C++20)



(C++20)(C++20)(C++20)(C++20)
时钟
(C++20)
                                             
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
日历
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
时区
(C++20)
(C++20)
(C++20)
(C++20)
C 风格日期和时间
 
 
constexpr std::chrono::year_month& operator+=(const std::chrono::years& dy) const noexcept;
(1) (C++20 起)
constexpr std::chrono::year_month& operator+=(const std::chrono::months& dm) const noexcept;
(2) (C++20 起)
constexpr std::chrono::year_month& operator-=(const std::chrono::years& dy) const noexcept;
(3) (C++20 起)
constexpr std::chrono::year_month& operator-=(const std::chrono::months& dm) const noexcept;
(4) (C++20 起)

以时长 dydm 为程度修改时间点 *this

1) 等价于 *this = *this + dy;
2) 等价于 *this = *this + dm;
3) 等价于 *this = *this - dy;
4) 等价于 *this = *this - dm;

对于能转换到 std::chrono::yearsstd::chrono::months 两者的时长,若调用有歧义,则偏好 years 重载 (1,3)

参阅

进行 year_month 上的算术
(函数)
关闭