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-=duration::operator*=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
 
 (1)
 
duration& operator+=( const duration& d );
 
 (since C++11) (constexpr since C++17)
 
 (2)
 
duration& operator-=( const duration& d );
 
 (since C++11) (constexpr since C++17)
 
 (3)
 
duration& operator*=( const rep& rhs );
 
 (since C++11) (constexpr since C++17)
 
 (4)
 
duration& operator/=( const rep& rhs );
 
 (since C++11) (constexpr since C++17)
 
 (5)
 
duration& operator%=( const rep& rhs );
 
 (since C++11) (constexpr since C++17)
 
 (6)
 
duration& operator%=( const duration& rhs );
 
 (since C++11) (constexpr since C++17)
Performs compound assignments between two durations with the same period or between a duration and a tick count value.
If rep_ is the member variable holding the number of ticks in this duration object,
1) Equivalent to rep_ += d.count(); return *this;.
2) Equivalent to rep_ -= d.count(); return *this;.
3) Equivalent to rep_ *= rhs; return *this;.
4) Equivalent to rep_ /= rhs; return *this;.
5) Equivalent to rep_ %= rhs; return *this;.
6) Equivalent to rep_ %= d.count(); return *this;.
Contents
[edit] Parameters
 d
 -
 duration on the right-hand side of the operator
 rhs
 -
 number of ticks on the right-hand side of the operator
[edit] Return value
A reference to this duration after modification.
[edit] Example
Run this code
#include <chrono> #include <iostream> int main() { std::chrono::minutes m(11); m *= 2; m += std::chrono::hours (10); // hours implicitly convert to minutes std::cout << m.count() << " minutes equals " << std::chrono::duration_cast <std::chrono::hours >(m).count() << " hours and "; m %= std::chrono::hours (1); std::cout << m.count() << " minutes\n"; }
Output:
622 minutes equals 10 hours and 22 minutes