std::chrono:: operator+, std::chrono:: operator- (std::chrono::year_month_day)
|
Definiert in Header
<chrono>
|
||
|
constexpr
std::
chrono
::
year_month_day
operator
+
(
const
std::
chrono
::
year_month_day
&
ymd,
const
std::
chrono
::
months
&
dm
|
(seit C++20) | |
|
constexpr
std::
chrono
::
year_month_day
operator
+
(
const
std::
chrono
::
months
&
dm,
const
std::
chrono
::
year_month_day
&
ymd
|
(seit C++20) | |
|
constexpr
std::
chrono
::
year_month_day
operator
+
(
const
std::
chrono
::
year_month_day
&
ymd,
const
std::
chrono
::
years
&
dy
|
(seit C++20) | |
|
constexpr
std::
chrono
::
year_month_day
operator
+
(
const
std::
chrono
::
years
&
dy,
const
std::
chrono
::
year_month_day
&
ymd
|
(seit C++20) | |
|
constexpr
std::
chrono
::
year_month_day
operator
-
(
const
std::
chrono
::
year_month_day
&
ymd,
const
std::
chrono
::
months
&
dm
|
(seit C++20) | |
|
constexpr
std::
chrono
::
year_month_day
operator
-
(
const
std::
chrono
::
year_month_day
&
ymd,
const
std::
chrono
::
years
&
dy
|
(seit C++20) | |
Für Dauern, die sowohl in
std::chrono::years
als auch in
std::chrono::months
konvertierbar sind, werden die
years
Überladungen
(3,4,6)
bevorzugt, falls der Aufruf andernfalls mehrdeutig wäre.
Hinweise
Selbst wenn
ymd.
ok
(
)
den Wert
true
hat, könnte das resultierende
year_month_day
kein gültiges Datum repräsentieren, falls
ymd.
day
(
)
29, 30 oder 31 beträgt.
Beispiel
#include <chrono> #include <iostream> int main() { std::cout << std::boolalpha; auto ymd{std::chrono::day(1)/std::chrono::July/2021}; ymd = ymd + std::chrono::months(4); std::cout << (ymd.month() == std::chrono::November) << ' ' << (ymd.year() == std::chrono::year(2021)) << ' '; ymd = ymd - std::chrono::years(10); std::cout << (ymd.month() == std::chrono::month(11)) << ' ' << (ymd.year() == std::chrono::year(2011)) << '\n'; }
Ausgabe:
true true true true