std::chrono::duration::operator++, std::chrono::duration::operator--

< cpp‎ | chrono‎ | duration
duration& operator++();
duration operator++(int);
duration& operator--();
duration operator--(int);

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,

1) Equivalent to ++rep_; return *this;
2) Equivalent to return duration(rep_++)
3) Equivalent to --rep_; return *this;
4) Equivalent to return duration(rep_--);


[edit] Parameters


[edit] Return value

1,3) a reference to this duration after modification
2,4) a copy of the duration made before modification

[edit] Example

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


119 minutes

[edit] See also

implements compound assignment between two durations
(public member function)
implements arithmetic operations with durations as arguments
(function template)