std::chrono::duration<Rep,Period>::operator++, std::chrono::duration<Rep,Period>::operator--
duration& operator++();
|
(1) | (C++11 起) (C++17 起为 constexpr ) |
duration operator++( int );
|
(2) | (C++11 起) (C++17 起为 constexpr ) |
duration& operator--();
|
(3) | (C++11 起) (C++17 起为 constexpr ) |
duration operator--( int );
|
(4) | (C++11 起) (C++17 起为 constexpr ) |
自增或自减此 duration 的计次数。
若 rep_
是 duration 对象中保有计次数的成员变量,则
1) 等价于 ++rep_; return *this;。
2) 等价于 return duration(rep_++)。
3) 等价于 --rep_; return *this;。
4) 等价于 return duration(rep_--);。
参数
(无)
返回值
1,3) 修改后的此 duration 的引用。
2,4) 修改前的 duration 副本。
示例
#include <chrono> #include <iostream> int main() { std::chrono::hours h(1); std::chrono::minutes m = ++h; m--; std::cout << m.count() << " 分\n"; }
输出:
119 分
参阅
实现两个时长间的复合赋值 (公开成员函数) |
|
实现以时长为实参的算术运算 (函数模板) |