Namespaces
Variants
Views
Actions

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

From cppreference.com
< cpp‎ | chrono‎ | duration
Revision as of 16:25, 2 November 2012 by P12bot (Talk | contribs)

 
 
 
 
 

Template:ddcl list begin <tr class="t-dcl ">

<td >
duration& operator++();
</td>

<td > (1) </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">

<td >
duration operator++(int);
</td>

<td > (2) </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">

<td >
duration& operator--();
</td>

<td > (3) </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">

<td >
duration operator--(int);
</td>

<td > (4) </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

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_--);

Contents

Parameters

(none)

Return value

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

Example

#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

See also

Template:cpp/chrono/duration/dcl list operator arith3Template:cpp/chrono/duration/dcl list operator arith4