std::chrono::year:: operator+, std::chrono::year:: operator-
From de.cppreference.net
|
constexpr
std::
chrono
::
year
operator
+
(
)
noexcept
;
|
(1) | (seit C++20) |
|
constexpr
std::
chrono
::
year
operator
-
(
)
noexcept
;
|
(2) | (seit C++20) |
Wendet die unären Operatoren auf den Jahreswert an.
1)
Gibt eine Kopie von
*
this
zurück.
2)
Gibt ein
year
zurück, dessen Jahreswert die Negation des Jahreswerts von
*
this
ist.
Rückgabewert
1)
*
this
2)
std::
chrono
::
year
(
-
int
(
*
this
)
)
Beispiel
Diesen Code ausführen
#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'; }
Ausgabe:
The year 2020 negated is -2020