std::chrono::year:: operator+, std::chrono::year:: operator-
From cppreference.net
C++
Date and time library
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::chrono::year
| Member functions | ||||
|
year::operator+
year::operator-
|
||||
| Nonmember functions | ||||
| Helper classes | ||||
|
(C++26)
|
|
constexpr
std::
chrono
::
year
operator
+
(
)
noexcept
;
|
(1) | (C++20以降) |
|
constexpr
std::
chrono
::
year
operator
-
(
)
noexcept
;
|
(2) | (C++20以降) |
年値に単項演算子を適用します。
1)
*
this
のコピーを返します。
2)
year
の年値が
*
this
の年値の符号を反転したものを返します。
戻り値
1)
*
this
2)
std::
chrono
::
year
(
-
int
(
*
this
)
)
例
このコードを実行
#include <chrono> #include <iostream> int main() { constexpr std::chrono::year y{2020}; constexpr auto ny = -y; std::cout << "The year " << (int)y << " negated is " << (int)ny << '\n'; }
出力:
The year 2020 negated is -2020