命名空间
变体
操作

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

来自 cppreference.cn
< cpp‎ | chrono‎ | duration
 
 
 
 
duration& operator++();
(1) (since C++11)
(constexpr since C++17)
duration operator++( int );
(2) (since C++11)
(constexpr since C++17)
duration& operator--();
(3) (since C++11)
(constexpr since C++17)
duration operator--( int );
(4) (since C++11)
(constexpr since C++17)

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

如果 rep_ 是一个成员变量,用于保存持续时间对象中的刻度数,

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

[编辑] 参见

实现两个持续时间之间的复合赋值
(公共成员函数) [编辑]
实现以持续时间作为参数的算术运算
(函数模板) [编辑]