std::chrono::operator+,std::chrono::operator-(std::chrono::month) (3) - Linux Manuals
std::chrono::operator+,std::chrono::operator-(std::chrono::month): std::chrono::operator+,std::chrono::operator-(std::chrono::month)
Command to display std::chrono::operator+,std::chrono::operator-(std::chrono::month)
manual in Linux: $ man 3 std::chrono::operator+,std::chrono::operator-(std::chrono::month)
NAME
std::chrono::operator+,std::chrono::operator-(std::chrono::month) - std::chrono::operator+,std::chrono::operator-(std::chrono::month)
Synopsis
constexpr std::chrono::month operator+(const std::chrono::month& m, (1) (since C++20)
const std::chrono::months& ms) noexcept;
constexpr std::chrono::month operator+(const std::chrono::months& ms, (2) (since C++20)
const std::chrono::month& m) noexcept;
constexpr std::chrono::month operator-(const std::chrono::month& m, (3) (since C++20)
const std::chrono::months& ms) noexcept;
constexpr std::chrono::months operator-(const std::chrono::month& m1, (4) (since C++20)
const std::chrono::month& m2) noexcept;
1-2) Adds ms.count() months to m. The month value held in the result is computed by first evaluating static_cast<long long>(unsigned(m)) + (ms.count() - 1), reducing it modulo 12 to an integer in the range [0, 11], and then adding 1.
3) Subtracts ms.count() months from m and returns the result. Equivalent to return m + -ms;
4) If m1.ok() and m2.ok() are both true, returns a std::chrono::months value m such that m.count() is in the range [0, 11] and m2 + m == m1. Otherwise the returned value is unspecified.
Return value
1-3) A std::chrono::month holding a month value calculated as described above.
4) A std::chrono::months representing the distance between m1 and m2.
Notes
As long as the computation doesn't overflow, (1-3) always return a valid month even if m.ok() is false.
The result of subtracting two month values is a duration of type std::chrono::months. That duration unit represents the length of the average Gregorian month, and the resulting duration bears no relationship to the number of days in the particular months represented by the operands. For example, std::chrono::seconds(std::chrono::April - std::chrono::March) is not the number of seconds in March (2678400s), but 2629746s (30.436875 days).
Example
This section is incomplete
Reason: no example
See also
operator++ increments or decrements the month
operator++(int) (public member function)
operator--
operator--(int)
adds or subtracts a number of months
operator+= (public member function)
operator-=
Pages related to std::chrono::operator+,std::chrono::operator-(std::chrono::month)
- std::chrono::operator+,std::chrono::operator-(std::chrono::day) (3) - std::chrono::operator+,std::chrono::operator-(std::chrono::day)
- std::chrono::operator+,std::chrono::operator-(std::chrono::weekday) (3) - std::chrono::operator+,std::chrono::operator-(std::chrono::weekday)
- std::chrono::operator+,std::chrono::operator-(std::chrono::year) (3) - std::chrono::operator+,std::chrono::operator-(std::chrono::year)
- std::chrono::operator+,std::chrono::operator-(std::chrono::year_month) (3) - std::chrono::operator+,std::chrono::operator-(std::chrono::year_month)
- std::chrono::operator+,std::chrono::operator-(std::chrono::year_month_day) (3) - std::chrono::operator+,std::chrono::operator-(std::chrono::year_month_day)
- std::chrono::operator+,std::chrono::operator-(std::chrono::year_month_day_last) (3) - std::chrono::operator+,std::chrono::operator-(std::chrono::year_month_day_last)
- std::chrono::operator+,std::chrono::operator-(std::chrono::year_month_weekday) (3) - std::chrono::operator+,std::chrono::operator-(std::chrono::year_month_weekday)
- std::chrono::operator+,std::chrono::operator-(std::chrono::year_month_weekday_last) (3) - std::chrono::operator+,std::chrono::operator-(std::chrono::year_month_weekday_last)
- std::chrono::operator<<(std::chrono::day) (3) - std::chrono::operator<<(std::chrono::day)
- std::chrono::operator<<(std::chrono::duration) (3) - std::chrono::operator<<(std::chrono::duration)
- std::chrono::operator<<(std::chrono::file_time) (3) - std::chrono::operator<<(std::chrono::file_time)
- std::chrono::operator<<(std::chrono::gps_time) (3) - std::chrono::operator<<(std::chrono::gps_time)
- std::chrono::operator<<(std::chrono::local_info) (3) - std::chrono::operator<<(std::chrono::local_info)
- std::chrono::operator<<(std::chrono::local_time) (3) - std::chrono::operator<<(std::chrono::local_time)
- std::chrono::operator<<(std::chrono::month) (3) - std::chrono::operator<<(std::chrono::month)
- std::chrono::operator<<(std::chrono::month_day) (3) - std::chrono::operator<<(std::chrono::month_day)
- std::chrono::operator<<(std::chrono::month_day_last) (3) - std::chrono::operator<<(std::chrono::month_day_last)
- std::chrono::operator<<(std::chrono::month_weekday) (3) - std::chrono::operator<<(std::chrono::month_weekday)
- std::chrono::operator<<(std::chrono::month_weekday_last) (3) - std::chrono::operator<<(std::chrono::month_weekday_last)
- std::chrono::operator<<(std::chrono::sys_info) (3) - std::chrono::operator<<(std::chrono::sys_info)
- std::chrono::operator<<(std::chrono::sys_time) (3) - std::chrono::operator<<(std::chrono::sys_time)
- std::chrono::operator<<(std::chrono::tai_time) (3) - std::chrono::operator<<(std::chrono::tai_time)
- std::chrono::operator<<(std::chrono::time_of_day) (3) - std::chrono::operator<<(std::chrono::time_of_day)
- std::chrono::operator<<(std::chrono::utc_time) (3) - std::chrono::operator<<(std::chrono::utc_time)
- std::chrono::operator<<(std::chrono::weekday) (3) - std::chrono::operator<<(std::chrono::weekday)