std::chrono::duration<Rep,Period>::operator++, std::chrono::duration<Rep,Period>::operator--
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Date and time library
(C++11)
(C++20)
(C++20)
(C++11)
(C++11)
(C++11)
(C++20)
(C++20)
(C++20)
(C++11)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
std::chrono::duration
Member functions
duration::operator++duration::operator--
Non-member functions
(until C++20)(C++20)
(C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++20)
Helper classes
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)
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
[edit] Parameters
(none)
[edit] Return value
1,3) A reference to this duration after modification.
2,4) A copy of the duration made before modification.
[edit] Example
Run this code
#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