|
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
year::operator+year::operator- | ||||
| Nonmember functions | ||||
| Helper classes | ||||
(C++26) |
constexprstd::chrono::year operator+()noexcept; | (1) | (since C++20) |
constexprstd::chrono::year operator-()noexcept; | (2) | (since C++20) |
Applies the unary operators to the year value.
year whose year value is the negation of that of*this.#include <chrono>#include <iostream> int main(){constexprstd::chrono::year y{2020};constexprauto ny=-y;std::cout<<"The year "<<(int)y<<" negated is "<<(int)ny<<'\n';}
Output:
The year 2020 negated is -2020