std::chrono::duration::operators
时间::持续时间::操作员++,std::time::time::Operator---
| (1) | |
---|---|---|
duration& operator++( | (until C++17) | |
constexpr duration& operator++( | (since C++17) | |
| (2) | |
duration operator++(int | (until C++17) | |
constexpr duration operator++(int | (since C++17) | |
| (3) | |
duration& operator--( | (until C++17) | |
constexpr duration& operator--( | (since C++17) | |
| (4) | |
duration operator--(int | (until C++17) | |
constexpr duration operator--(int | (since C++17) |
在此期间增加或减少蜱数。
如果rep_
是一个成员变量,该变量保存持续时间对象中的滴答数,
1%29相当于++rep_; return *this;
2%29相当于return duration(rep_++)
3%29相当于--rep_; return *this;
4%29相当于return duration(rep_--
参数
%280%29
返回值
1,3%29修改后提及这一持续时间
2,4%29修改前所作期限的副本
例
二次
#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
二次
另见
operator+=operator-=operator*=operator/=operator%= | implements compound assignment between two durations (public member function) |
---|---|
operator+operator-operator*operator/operator% | implements arithmetic operations with durations as arguments (function template) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。