std::chrono...operator++,(3)
πΈ NAME πΈ
hey bestie, welcome to std::chrono...operator++,(3) from the C++ Standard Libary β yes, βLibary,β typo and all, weβre keeping the lore. The actual page name is literally:
std::chrono::duration::operator++, - std::chrono::duration::operator++,
that comma is not a typo from me, itβs just the name, periodt. π
β¨ Synopsis β¨
ok so this is the duration increment/decrement situation. Four overloads, all since C++11 and all constexpr since C++17:
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)
They increment or decrement the number of ticks for this duration.
If rep_ is a member variable holding the number of ticks in a duration object, then hereβs the tea:
- Equivalent to
++rep_; return *this;. - Equivalent to
return duration(rep_++). - Equivalent to
--rep_; return *this;. - Equivalent to
return duration(rep_--);.
π Parameters π
(none) β no parameters, bestie. zero. nada. slay. π«Ά
π Return value π
1,3)A reference to this duration after modification.2,4)A copy of the duration made before modification.
π¦ Example π¦
hereβs the whole little code moment, exactly as the page has it:
// 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
π See also π
the see-also list is giving linked-list energy, so here are all the entries and their little tags exactly:
operator+=operator-=β implements compound assignment between two durationsoperator*=β (public member function)operator/=operator%=operator+operator-operator*β implements arithmetic operations with durations as argumentsoperator/β (function template)operator%(C++11)β this tag is hanging out afteroperator%in the original list, iykyk
signing off with the footer tea: source http://cppreference.com, version/date 2024.06.10, page std::chrono...operator++,(3). mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms