(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) |
Increments or decrements the number of ticks for this duration.
If rep_
is a member variable holding the number of ticks in a duration object,
++rep_; return *this;
return duration(rep_++)
--rep_; return *this;
return duration(rep_--);
(none).
#include <chrono> #include <iostream> int main() { std::chrono::hours h(1); std::chrono::minutes m = ++h; m--; std::cout << m.count() << " minutes\n"; }
Output:
119 minutes
implements compound assignment between two durations (public member function) |
|
implements arithmetic operations with durations as arguments (function template) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/chrono/duration/operator_arith2