Namespaces
Variants

std::chrono::duration<Rep,Period>:: operator++, std::chrono::duration<Rep,Period>:: operator--

From cppreference.net
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)

递增或递减此持续时间的刻度数。

如果 rep_ 是用于存储 duration 对象中 tick 数量的成员变量,

1) 等价于 ++ rep_ ; return * this ;
2) 等价于 return duration ( rep_ ++ )
3) 等价于 -- rep_ ; return * this ;
4) 等价于 return duration ( rep_ -- ) ;

目录

参数

(无)

返回值

1,3) 修改后对此持续时间的引用。
2,4) 修改前创建的时长对象副本。

示例

#include <chrono>
#include <iostream>
int main()
{
    std::chrono::hours h(1);
    std::chrono::minutes m = ++h;
    m--;
    std::cout << m.count() << " minutes\n";
}

输出:

119 minutes

参见

实现两个时长之间的复合赋值运算
(公开成员函数)
实现以时长作为参数的算术运算
(函数模板)