std::chrono::day::operator+=, std::chrono::day::operator-= - cppreference.com (original) (raw)
| Member functions |
|---|
| day::day |
| day::operator++day::operator-- |
| day::operator+=day::operator-= |
| day::operator unsigned |
| day::ok |
| Nonmember functions |
| operator==operator<=> |
| operator+operator- |
| operator<< |
| from_stream |
| [operator""d](../operator%2522%2522d.html "cpp/chrono/operator""d") |
| Helper classes |
| formatterstd::chrono::day |
| hashstd::chrono::day(C++26) |
| constexpr std::chrono::day& operator+=( const std::chrono::days& d ) noexcept; | (1) | (since C++20) |
|---|---|---|
| constexpr std::chrono::day& operator-=( const std::chrono::days& d ) noexcept; | (2) | (since C++20) |
Adds or subtracts d.count() days from the day value.
Equivalent to *this = *this + d;.
Equivalent to *this = *this - d;.
Contents
[edit] Return value
A reference to this day after modification.
[edit] Notes
If the result would be outside the range [0, 255], the actual stored value is unspecified.
[edit] Example
Run this code
#include #include int main() { std::chrono::day d{15}; d += std::chrono::days(2); assert(d == std::chrono::day(17)); d -= std::chrono::days{3}; assert(d == std::chrono::day(14)); }
[edit] See also
| operator++operator++(int)operator--operator--(int) | increments or decrements the day (public member function) [edit] |
|---|---|
| operator+operator-(C++20) | adds or subtracts a number of days and a day, or find the difference between two days (function) [edit] |