<chrono> Operatoren

operator+

Additionsoperator für die folgenden Typen:

1) 
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
   operator+(
      const duration<Rep1, Period1>& Left,
      const duration<Rep2, Period2>& Right);

2)
template <class Clock, class Duration1, class Rep2, class Period2>
constexpr time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
   operator+(
      const time_point<Clock, Duration1>& Time,
      const duration<Rep2, Period2>& Dur);

3)
template <class Rep1, class Period1, class Clock, class Duration2>
time_point<Clock, constexpr typename common_type<duration<Rep1, Period1>, Duration2>::type>
   operator+(
      const duration<Rep1, Period1>& Dur,
      const time_point<Clock, Duration2>& Time);

4)
constexpr day operator+(const day& d, const days& ds) noexcept; // C++20
constexpr day operator+(const days& ds, const day&  d) noexcept; // C++20

5)
constexpr month operator+(const month& m, const months& ms) noexcept; // C++20
constexpr month operator+(const months& ms, const month& m) noexcept; // C++20

6)
constexpr weekday operator+(const weekday& wd, const days& wds) noexcept // C++20
constexpr weekday operator+(const days& ds, const weekday& wd) noexcept; // C++20

7)
constexpr year operator+(const year& y, const years& ys) noexcept; // C++20
constexpr year operator+(const years& ys, const year& y) noexcept; // C++20

8)
constexpr year_month operator+(const year_month& ym, const months& dm) noexcept; // C++20
constexpr year_month operator+(const months& dm, const year_month& ym) noexcept; // C++20
constexpr year_month operator+(const year_month& ym, const years& dy) noexcept; // C++20
constexpr year_month operator+(const years& dy, const year_month& ym) noexcept; // C++20

9)
constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept; // C++20
constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept; // C++20
constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept; // C++20
constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept; // C++20

10)
constexpr year_month_day_last operator+(const year_month_day_last& ymdl, const months& dm) noexcept; // C++20

11)
constexpr year_month_day_last operator+(const months& dm, const year_month_day_last& ymdl) noexcept; // C++20

12)
constexpr year_month_day_last operator+(const year_month_day_last& ymdl, const years& dy) noexcept; // C++20
constexpr year_month_day_last operator+(const years& dy, const year_month_day_last& ymdl) noexcept; // C++20

13)
constexpr year_month_weekday operator+(const year_month_weekday& ymwd, const months& dm) noexcept; // C++20
constexpr year_month_weekday operator+(const months& dm, const year_month_weekday& ymwd) noexcept; // C++20

14)
constexpr year_month_weekday operator+(const year_month_weekday& ymwd, const years& dy) noexcept; // C++20

15)
constexpr year_month_weekday operator+(const years& dy, const year_month_weekday& ymwd) noexcept; // C++20

16)
constexpr year_month_weekday_last operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept; // C++20
constexpr year_month_weekday_last operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept; // C++20

17)
constexpr year_month_weekday_last operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept; // C++20
constexpr year_month_weekday_last operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept; // C++20

Rückgabewert

1) Gibt nach dem Konvertieren Left und Right in ihren gemeinsamen Typ eine duration Teilstrichanzahl zurück, die der Summe der konvertierten Teilstrichanzahl entspricht.

2-3) Gibt ein time_point Objekt zurück, das einen Punkt darstellt, der durch das Intervall Dur von dem Zeitpunkt Timeverschoben wird.

4) Gibt das Ergebnis von d+ds.count(). Wenn das Ergebnis außerhalb des Bereichs [0, 255] liegt, ist das Ergebnis nicht angegeben.

5) Gibt das Ergebnis von m+ms.count(). Wenn sich das Ergebnis außerhalb des Bereichs [1, 12] befindet, ist es reduziert modulo 12 und dann +1.

6) Gibt das Ergebnis des Addierens der Anzahl von Tagen und Wochentagen zurück.weekday Das Ergebnis ist Modulo 7, also immer im Bereich [0,6]

7) Gibt das Ergebnis des Hinzufügens des Jahres zur angegebenen Anzahl von Jahren zurück.

8) Gibt das Ergebnis zurück, das die Anzahl der Monate und Jahre zum angegebenen Monat und Jahr hinzufügt.

9) Gibt das Ergebnis des Hinzufügens von Monaten oder Jahren zu einem year_month_day. Wenn ymd.month() sich Februaryymd.day() der Bereich [1d, 28d] nicht befindet, ok() kann für das Ergebnis der Addition zurückgegeben false werden.

10) Gibt zurück (ymdl.year() / ymdl.month() + dm) / last. Hinweis: Die / hier verwendete Verwendung ist kein Abteilungsoperator. Es ist der Datumsoperator.

11) Gibt zurück ymdl + dm.

12) Gibt zurück. {ymdl.year()+dy, ymdl.month_day_last()}

13) Gibt zurück ymwd + dm.count().

14-15) Gibt zurück {ymwd.year()+dy, ymwd.month(), ymwd.weekday_indexed()}.

16) Gibt zurück (ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last(). Hinweis: Die / hier verwendete Datei ist kein Abteilungsoperator, sondern der Datumsoperator.

17) Gibt Folgendes zurück: ymwdl + dy

Beispiel: operator+

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
    // day
    day d{1};
    std::cout << d + days(2) << '\n'; // 03

    // month
    month m{11};
    std::cout << m + months(3)<< '\n'; // Feb

    // weekday
    weekday wd = Thursday;
    std::cout << wd + days(1) << '\n'; // Fri

    // year_month_day_last
    year_month_day_last ymdl{June / last / 2021};
    std::cout << ymdl + years{1} + months{1} << '\n'; // 2022/Jul/last

    // year_month_weekday
    year_month_weekday ymw{ year(1997) / January / Wednesday[1] };
    std::cout << ymw + months{1} << '\n'; // 1997/Feb/Wed[1]
    std::cout << ymw + years{1} << '\n'; // 1998/Jan/Wed[1] 

    // year_month_weekday_last
    year_month_weekday_last ymwl{ year(1997) / January / Wednesday[last] };
    std::cout << ymwl + months{ 1 } << '\n'; // 1997/Feb/Wed[last]
    std::cout << ymwl + years{ 1 } << '\n'; // 1998/Jan/Wed[last] 

    return 0;
}
03
Feb
Fri
2022/Jul/last
1997/Feb/Wed[1]
1998/Jan/Wed[1]
1997/Feb/Wed[last]
1998/Jan/Wed[last]

Unäre operator+

Wenden Sie unäre Pluszeichen auf die folgenden Typen an:

// duration
constexpr common_type_t<duration> operator+() const // C++20

Rückgabewert

Gibt *this zurück.

operator-

Subtraktionsoperator für die folgenden Typen:

1)
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
   operator-(
       const duration<Rep1, Period1>& Left,
       const duration<Rep2, Period2>& Right);
2)
template <class Clock, class Duration1, class Rep2, class Period2>
constexpr time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type
   operator-(
       const time_point<Clock, Duration1>& Time,
       const duration<Rep2, Period2>& Dur);
3)
template <class Clock, class Duration1, class Duration2>
constexpr typename common_type<Duration1, Duration2>::type
   operator-(
       const time_point<Clock, Duration1>& Left,
       const time_point<Clock, Duration2>& Right);
4)
constexpr day operator-(const day& d,  days& ds) noexcept; // C++20
constexpr day operator-(const day& d, const day& d) noexcept; // C++20

5)
constexpr month operator-(const month& m, const months& ms) noexcept; // C++20
constexpr month operator-(const month& m, const month& ms) noexcept; // C++20

6)
constexpr months operator-(const year_month& Left, const year_month& Right) noexcept; // C++20

7)
constexpr weekday operator-(const weekday& Left, const days& Right) noexcept; // C++20

8)
constexpr days operator-(const weekday& Left, const weekday& Right) noexcept; // C++20

9)
constexpr year operator-(const year& y, const years& ys) noexcept; // C++20

10)
constexpr years operator-(const year& y, const year& y2) noexcept; // C++20

11)
constexpr year_month operator-(const year_month& ym, const months& dm) noexcept; // C++20
constexpr year_month operator-(const year_month& ym, const years& dy) noexcept; // C++20

12)
constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept; // C++20
constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept; // C++20

13)
constexpr year_month_day_last operator-(const year_month_day_last& ymdl, const months& dm) noexcept;  // C++20

14)
constexpr year_month_day_last operator-(const year_month_day_last& ymdl, const years& dy) noexcept;  // C++20

15)
constexpr year_month_weekday operator-(const year_month_weekday& ymwd, const months& dm) noexcept; // C++20

16)
constexpr year_month_weekday operator-(const year_month_weekday& ymwd, const years& dy) noexcept; // C++20

17)
constexpr year_month_weekday_last operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept; // C++20

18)
constexpr year_month_weekday_last operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept; // C++20

Rückgabewert

1) Nach dem Konvertieren der Dauer, die in ihren gemeinsamen Typ subtrahiert wird, wird eine duration Teilstrichanzahl zurückgegeben, die der Anzahl der Teilstriche Right entspricht, die von der Anzahl der Teilstriche Leftsubtrahiert werden.

2) Gibt einen time_point Wert zurück, der einen Punkt darstellt, der durch die Negation des zeitintervalls verschoben wird, das durch Dur, von dem Punkt in der angegebenen Zeit dargestellt Timewird.

3) Gibt ein duration Objekt zurück, das das Zeitintervall zwischen Left und Right.

4) Gibt das Ergebnis von d-ds.count(). Wenn das Ergebnis außerhalb des Bereichs [0, 255] liegt, ist das Ergebnis nicht angegeben.

5) Wenn m.ok() == true und ms.ok() == true, gibt das Ergebnis der Subtrahierung der zwei Monatswerte zurück oder subtrahiert die Anzahl der Monate. Das Ergebnis befindet sich im Bereich [1, 12]. Wenn das Ergebnis negativ ist, wird es umbrochen. Subtrahieren sie z. B. einen Monat vom Januar (month m1{1} - months{1}; ergibt 12 (Dezember).

6) Gibt die Differenz in Monaten zwischen Left und Right

7) Wenn Left.ok() == true und Right.ok() == true, gibt einen weekday im Bereich [days{0}, days{6}].

8) Gibt die Anzahl der Tage zwischen zwei Wochentagen zurück.

9) Gibt zurück. year(int(y)-ys.count)())

10) Gibt zurück years(int(y) - int(y2)). Das Subtrahieren von zwei year Werten führt zu einer std::chrono::years, die den Unterschied in Jahren zwischen y und y2. Beispielsweise erzeugt 2021y-2000y den Wert years(21).

11) Gibt das Ergebnis des Subtrahierens von Monaten oder Jahren von einem year_month Wert zurück.

12) Gibt das Ergebnis der Subtrahierung von Monaten von einem year_month_day Wert zurück.

13) Gibt das Ergebnis des Subtrahierens der Anzahl von Monaten vom Wert zurück year_month_day_last . Im Wesentlichen: ymdl-dm.

14) Gibt das Ergebnis des Subtrahierens der Anzahl von Jahren vom Wert zurück year_month_day_last . Im Wesentlichen: ymdl-dy.

15) Gibt das Ergebnis des Subtrahierens der Anzahl von Monaten vom Wert zurück year_month_weekday . Im Wesentlichen: ymwd-dm.

16) Gibt das Ergebnis der Subtrahierung der Anzahl von Jahren vom Wert zurück year_month_weekday . Im Wesentlichen: ymwd-dy.

17) Gibt das Ergebnis des Subtrahierens der Anzahl von Monaten vom Wert zurück year_month_weekday_last . Im Wesentlichen: ymwdl-dm.

18) Gibt das Ergebnis des Subtrahierens der Anzahl von Jahren vom Wert zurück year_month_weekday_last . Im Wesentlichen: ymwdl-dy.

Beispiel: operator-

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
    // day
    day d{10};
    d = d - days(5);  
    std::cout << d << '\n'; // 05

    // month 
    month m{2};
    m = m - months{1};
    std::cout << m << '\n'; // Jan
    m = m - months{1};
    std::cout << m << '\n'; // Dec

    // year
    auto diff1 = 2021y-2000y;
    auto diff2 = 2021y-years{1};
    std::cout << diff1.count() << '\n'; // 21
    std::cout << diff2 << '\n'; // 2020

    // year_month
    const year theYear{ 2021 };
    year_month ym1{theYear, June};
    year_month ym2 = ym1 - months{2};
    std::cout << ym2 << '\n'; // 2021/Apr
    year_month ym3 = ym1 - years{2};
    std::cout << ym3 << '\n'; // 2019/Jun

    // year_month_day_last
    year_month_day_last ymdl = June / last / 2021;
    std::cout << ymdl - years{1} - months{1} << '\n'; // 2022/Jul/last

    // year_month_weekday
    year_month_weekday ymw{ year(1997) / January / Wednesday[1] };
    std::cout << ymw - months{1} << '\n'; // 1996/Dec/Wed[1]
    std::cout << ymw - years{1} << '\n'; // 1996/Jan/Wed[1] 

    // year_month_weekday_last
    year_month_weekday_last ymwl{ year(1997) / January / Wednesday[last] };
    std::cout << ymwl - months{ 1 } << '\n'; // 1996/Dec/Wed[last]
    std::cout << ymwl - years{ 1 } << '\n'; // 1996/Jan/Wed[last]
    
    return 0;
}
05
Jan
Dec
21
2020
2021/Apr
2019/Jun
2020/May/last
1996/Dec/Wed[1]
1996/Jan/Wed[1]
1996/Dec/Wed[last]
1996/Jan/Wed[last]

Unäre operator-

Negatet ein duration.

constexpr common_type_t<duration> operator-() const;

Rückgabewert

Gibt eine negierte Kopie von *this

Beispiel: unär operator-

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
   duration<int, std::milli> milliseconds(120);
   std::cout << -milliseconds << '\n';
   return 0;
}
-120ms

operator!=

Bestimmt, ob:

1) Zwei duration Objekte stellen nicht dieselbe Anzahl von Teilstrichen dar.
2) Zwei time_point Objekte stellen nicht denselben Zeitpunkt dar.

1)
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr bool operator!=(
    const duration<Rep1, Period1>& Left,
    const duration<Rep2, Period2>& Right);

2)
template <class Clock, class Duration1, class Duration2>
constexpr bool operator!=(
    const time_point<Clock, Duration1>& Left,
    const time_point<Clock, Duration2>& Right);

Parameter

Left
Das linke duration oder time_point-Objekt.

Right
Das rechte duration oder time_point-Objekt.

Rückgabewert

1) Gibt zurück true , wenn die Anzahl der Teilstriche für den Gemeinsamen LeftRight Typ und nicht gleich sind. Andernfalls wird falsezurückgegeben.
2) Gibt zurück true , wenn die beiden time_point Objekte nicht denselben Zeitpunkt darstellen. Andernfalls wird falsezurückgegeben.

operator*

Multiplikationsoperator für duration-Objekte. Nach dem Konvertieren der durationmultiplizierten Striche in ihren gemeinsamen Typ wird eine duration Teilstrichanzahl zurückgegeben, die der Multiplikation der konvertierten Teilstrichanzahl entspricht.

1)
template <class Rep1, class Period1, class Rep2>
constexpr duration<typename common_type<Rep1, Rep2>::type, Period1>
   operator*(
      const duration<Rep1, Period1>& Dur,
      const Rep2& Mult);

2)
template <class Rep1, class Rep2, class Period2>
constexpr duration<typename common_type<Rep1, Rep2>::type, Period2>
   operator*(
       const Rep1& Mult,
       const duration<Rep2,
       Period2>& Dur);

Parameter

Dur
Ein duration-Objekt.

Mult
Ein Integralwert.

Rückgabewert

Gibt ein duration Objekt zurück, dessen Intervalllänge mit der Länge multipliziert DurwirdMult.

1) Sofern keine is_convertible<Rep2, common_type<Rep1, Rep2>>Haltebereiche vorhanden truesind, nimmt diese Funktion nicht an der Überladungsauflösung teil. Weitere Informationen finden Sie unter <type_traits>.

2) Sofern nicht is_convertible<Rep1, common_type<Rep1, Rep2>>, ist truediese Funktion nicht an der Überladungsauflösung beteiligt. Weitere Informationen finden Sie unter <type_traits>.

operator<

1) Nach dem Konvertieren der Daten, die durationmit ihrem gemeinsamen Typ verglichen werden, wird ermittelt, ob die Anzahl der Teilstriche Left kleiner als für Rightist.

2) Bestimmt, ob der Zeitpunkt seit der Epoche des Lefttime_point Ins kleiner als die Zeit seit der Epoche des time_point In Rightist.

1)
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr bool operator<(
    const duration<Rep1, Period1>& Left,
    const duration<Rep2, Period2>& Right);

2)
template <class Clock, class Duration1, class Duration2>
constexpr bool operator<(
    const time_point<Clock, Duration1>& Left,
    const time_point<Clock, Duration2>& Right);

Parameter

Left
Das linke duration oder time_point-Objekt.

Right
Das rechte duration oder time_point-Objekt.

Rückgabewert

1) Gibt zurück true , wenn die Anzahl der Teilstriche Left kleiner als die Anzahl der Teilstriche ist Right. Andernfalls wird von der Funktion false zurückgegeben.

2) Gibt zurück true , wenn Left vorangestellt Right. Andernfalls wird falsezurückgegeben.

operator<=

1) Nach dem Konvertieren der durationZeichen im Vergleich zu ihrem gemeinsamen Typ bestimmt, ob die Anzahl der Teilstriche Left weniger oder gleich ist wie Right.

2) Bestimmt, ob der Zeitpunkt seit der Epoche des Lefttime_point Ins kleiner oder gleich der Zeit seit der Epoche des time_point Ins Rightist.

1)
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr bool operator<=(
    const duration<Rep1, Period1>& Left,
    const duration<Rep2, Period2>& Right);

2)
template <class Clock, class Duration1, class Duration2>
constexpr bool operator<=(
    const time_point<Clock, Duration1>& Left,
    const time_point<Clock, Duration2>& Right);

Parameter

Left
Das linke duration oder time_point-Objekt.

Right
Das rechte duration oder time_point-Objekt.

Rückgabewert

1) Gibt zurück true , wenn die Anzahl der Teilstriche Left kleiner oder gleich der Anzahl der Teilstriche Rightist. Andernfalls wird von der Funktion false zurückgegeben.

2) Gibt zurücktrue, wenn Left vorangestellt oder gleich ist. Right Andernfalls wird falsezurückgegeben.

operator==

Bestimmt, ob:

1) duration Objekte stellen Zeitintervalle dar, die dieselbe Länge aufweisen.
2) time_point Objekte stellen denselben Zeitpunkt dar.
3) day Objekte stellen denselben Tag dar.
4) month Objekte stellen denselben Monat dar.
5) month_day Objekte stellen den gleichen Monat und Tag dar.
6) month_day_last Objekte stellen denselben Monat dar.
7) month_weekday Objekte stellen denselben Monat und n. Wochentag dar.
8) month_weekday_last Objekte stellen denselben Monat und letzten Wochentag dar.
9) weekday Objekte stellen denselben Wochentag dar.
10) weekday_last Objekte stellen den gleichen letzten Wochentag des Monats dar.
11) weekday_indexed stellen denselben Wochentagsindex dar.
12) year stellen dasselbe Jahr dar.
13) year_month steht für dasselbe Jahr und denselben Monat.
14) year_month_day stellt dasselbe Jahr, denselben Monat und den gleichen Tag dar.
15) year_month_day_last denselben letzten Tag des Jahres und Monats darstellen.
16) year_month_weekday steht für denselben Wochentag, dasselbe Jahr und denselben Monat.
17) year_month_weekday_last stellen den gleichen letzten Wochentag des Monats, Jahres und Monats dar.
18) time_zone_link haben das gleiche name. Der target Name wird nicht berücksichtigt.
19) zoned_time die gleiche Uhrzeit und Zeitzone darstellen.

// 1) duration<Rep, Period>
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr bool operator==(
    const duration<Rep1, Period1>& Left,
    const duration<Rep2, Period2>& Right);

// 2) time_point
template <class Clock, class Duration1, class Duration2>
constexpr bool operator==(
    const time_point<Clock, Duration1>& Left,
    const time_point<Clock, Duration2>& Right);

// 3) day
constexpr bool operator==(const day& Left, const day& Right) noexcept; // C++20

// 4) month
constexpr bool operator==(const month& Left, const month& Right) noexcept; // C++20

// 5) month_day
constexpr bool operator==(const month_day& Left, const month_day& Right) noexcept; // C++20

// 6) month_day_last
constexpr bool operator==(const month_day_last& Left, const month_day_last& Right) noexcept; // C++20

// 7) month_weekday
constexpr bool operator==(const month_weekday& Left, const month_weekday& Right) noexcept; // C++20

// 8) month_weekday_last
constexpr bool operator==(const month_weekday_last& Left, const month_weekday_last& Right) noexcept; // C++20

// 9) weekday
constexpr bool operator==(const weekday& Left, const weekday& Right) noexcept; // C++20

// 10) weekday_last
constexpr bool operator==(const weekday_last& Left, const weekday_last& Right) noexcept; // C++20

// 11) weekday_indexed
constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept; // C++20

// 12) year
constexpr bool operator==(const year& Left, const year& y ) noexcept; // C++20

// 13) year_month
constexpr bool operator==(const year_month& Left, const year_month& Right) noexcept; // C++20

// 14) year_month_day
constexpr bool operator==(const year_month_day& Left, const year_month_day& Right) noexcept; // C++20

// 15) year_month_day_last
constexpr bool operator==(const year_month_day_last& Left, const year_month_day_last& Right) noexcept; // C++20

// 16) year_month_weekday
constexpr bool operator==(const year_month_weekday& Left, const year_month_weekday& Right) noexcept; // C++20

// 17)  year_month_weekday_last
constexpr bool operator==(const year_month_weekday_last& Left, const year_month_weekday_last& Right) noexcept; // C++20

// 18) time_zone_link
bool operator==(const time_zone_link& Left, const time_zone_link& Right) noexcept; // C++20

// 19) zoned_time
template <class Duration1, class Duration2, class TimeZonePtr>
bool operator==(const zoned_time<Duration1, TimeZonePtr>& Left, const zoned_time<Duration2, TimeZonePtr>& Right); // C++20

Parameter

Left
Das linke Objekt, das verglichen werden soll, z. B. Left == Right

Right
Das rechte zu vergleichende Objekt.

Rückgabewert

1) Gibt zurück true , wenn die Anzahl der Teilstriche für den Typ gleich Left ist und Right gleich ist. Andernfalls wird falsezurückgegeben.
2) Gibt zurück true , ob Left und Right stellt denselben Zeitpunkt dar. Andernfalls wird falsezurückgegeben.
3-17) Gibt zurück true , wenn Left und Right denselben Wert aufweisen. Andernfalls wird falsezurückgegeben.
18) Gibt zurück true , wenn Left.name() == Right.name(). Andernfalls wird *false*zurückgegeben.
19) Gibt zurück true , wenn Left.get_time_zone() == _Right.get_time_zone() && Left.get_sys_time() == Right.get_sys_time();

operator>

1) Nach dem Konvertieren der Daten, die durationmit ihrem gemeinsamen Typ verglichen werden, wird ermittelt, ob die Anzahl der Teilstriche Left größer ist als für Right.

2) Bestimmt, ob der Zeitpunkt seit der Epoche des Ins Lefttime_point größer als die Zeit seit der Epoche des time_point Ins Rightist.

1) 
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr bool operator>(
    const duration<Rep1, Period1>& Left,
    const duration<Rep2, Period2>& Right);

2)
template <class Clock, class Duration1, class Duration2>
constexpr bool operator>(
    const time_point<Clock, Duration1>& Left,
    const time_point<Clock, Duration2>& Right);

Parameter

Left
Das linke duration oder time_point-Objekt.

Right
Das rechte duration oder time_point-Objekt.

Rückgabewert

1) Gibt zurück true , wenn die Anzahl der Teilstriche Left größer als die Anzahl der Teilstriche ist Right. Andernfalls wird von der Funktion false zurückgegeben.

2) Gibt zurück true , wenn es Left folgt Right. Andernfalls wird falsezurückgegeben.

operator>=

1) Nach dem Konvertieren der Daten, die durationmit ihrem gemeinsamen Typ verglichen werden, wird ermittelt, ob die Anzahl der Teilstriche Left größer oder gleich Rightist.

2) Bestimmt, ob der Zeitpunkt seit der Epoche des Ins Lefttime_point größer oder gleich der Zeit seit der Epoche des time_point Ins Rightist.

1)
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr bool operator>=(
    const duration<Rep1, Period1>& Left,
    const duration<Rep2, Period2>& Right);

2)
template <class Clock, class Duration1, class Duration2>
constexpr bool operator>=(
    const time_point<Clock, Duration1>& Left,
    const time_point<Clock, Duration2>& Right);

Parameter

Left
Das linke duration oder time_point-Objekt.

Right
Das rechte duration oder time_point-Objekt.

Rückgabewert

1) Gibt zurück true , wenn die Anzahl der Teilstriche Left größer oder gleich der Anzahl der Teilstriche Rightist. Andernfalls wird von der Funktion false zurückgegeben.

2) Gibt zurück true , wenn es Left nach oder gleich ist, Right. Andernfalls wird falsezurückgegeben.

operator<=>

Der Raumschiffsoperator mit operator==, synthetisiert Operatoren für <, <=, , >>=und != für die folgenden Typen:

1)
constexpr bool operator<=>(const day& Left, const day& Right) noexcept; // C++20

constexpr std::strong_ordering operator<=>(const month& Left, const month& Right) noexcept; // C++20

constexpr strong_ordering operator<=>(const month_day& Left, const month_day& Right) noexcept; // C++20

constexpr std::strong_ordering operator<=>(const year& Left, const year& Right ) noexcept; // C++20

constexpr strong_ordering operator<=>(const year_month& Left, const year_month& Right) noexcept; // C++20

template<class Clock, class Duration1, three_­way_­comparable_­with<Duration1> Duration2>
    constexpr auto operator<=>(const time_point<Clock, Duration1>& Left, const time_point<Clock, Duration2>& Right); // C++20

template<class Rep1, class Period1, class Rep2, class Period2>
  requires three_­way_­comparable<typename CT::rep>
    constexpr auto operator<=>(const duration<Rep1, Period1>& Left, const duration<Rep2, Period2>& Right);

2)
constexpr strong_ordering operator<=>(const month_day_last& Left, const month_day_last& Right) noexcept;

3)
constexpr strong_ordering operator<=>(const year_month_day_last& Left, const year_month_day_last& Right) noexcept;

4)
strong_ordering operator<=>(const time_zone_link& Left, const time_zone_link& Right) noexcept;

Parameter

Left, Right
The day, duration, , , month_daymonth, time_pointmonth_day_last, time_zone_linkyear, , , year_month, , year_month_dayto year_month_day_last compare.

Rückgabewert

1)
0 Wenn Left == Right
< 0 Wenn Left < Right
> 0 Wenn Left > Right

2)
Entspricht: Left.month() <=> Right.month()

3)
Entspricht:

if (auto c = Left.year() <=> Right.year(); c != 0) return c;
return Left.month_day_last() <=> Right.month_day_last();

4)
Entspricht:

Left.name() <=> Right.name()

Beispiel: operator<=>

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono; // for day and 'd' literals

int main()
{
    day d1{3};
    day d2{2};

    if ((d1 <=> d2) == 0)
    {
        std::cout << "equal\n";
    }
    else if ((d1 <=> d2) < 0)
    {
        std::cout << "d1 < d2\n";
    }
    else if ((d1 <=> d2) > 0)
    {
        std::cout << "d1 > d2\n";
    }

    std::cout << std::boolalpha << (1d <= 1d) << ' ' << (1d != 2d) << ' ' << (2d > 3d);

    return 0;
}
d1 < d2
true true false 

operator<<

Geben Sie die folgenden Typen in einen Datenstrom aus:

// 1) day
template <class CharT, class Traits>
std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& os, const day& d); // C++20

// 2) hh_mm_ss
template<class CharT, class traits, class Duration>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const hh_mm_ss<Duration>& hms); // C++20

// 3) month
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const month& m); // C++20

// 4) month_day
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const month_day& md); // C++20

// 5) month_day_last
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const month_day_last& mdl); // C++20

// 6) month_weekday
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const month_weekday& mwd); // C++20

// 7) month_weekday_last
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const month_weekday_last& mwdl); // C++20

// 8) weekday
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const weekday& wd); // C++20

// 9) weekday_indexed
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const weekday_indexed& wdi); // C++20

// 10) weekday_last
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const weekday_last& wdl); // C++20

// 11) year
template <class CharT, class Traits>
std::basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const year& y); // C++20

// 12) year_month
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const year_month& ym); // C++20

// 13) year_month_day
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const year_month_day& ymd); // C++20

// 14) year_month_day_last
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const year_month_day_last& ymdl); // C++20

// 15) year_month_weekday
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const year_month_weekday& ymwd); // C++20

// 16) year_month_weekday_last
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const year_month_weekday_last& ymwdl); // C++20

// 17) tai_time
template<class CharT, class Traits, class Duration>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const tai_time<Duration>& t); // C++20

// 18) utc_time
template<class CharT, class Traits, class Duration>
basic_ostream<CharT, traits>&
operator<<(basic_ostream<CharT, Traits>& os, const utc_time<Duration>& t); // C++20

// 19) gps_time
template<class CharT, class Traits, class Duration>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const gps_time<Duration>& t); // C++20

// 20) local_time
template<class CharT, class Traits, class Duration>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const local_time<Duration>& t); // C++20

// 21) sys_info
template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const sys_info& si);

// 22) local_info
template<class CharT, class Traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<CharT, Traits>& os, const local_info& li);

// 23) zoned_time
template<class CharT, class Traits, class Duration, class TimeZonePtr>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& os, const zoned_time<Duration, TimeZonePtr>& zt);

Parameter

CharT
Der Datentyp eines einzelnen Zeichens, das aus dem Datenstrom gelesen und in der Zeichenfolge gespeichert werden soll. Die C++-Standardbibliothek bietet Spezialisierungen dieser Klassenvorlage mit den Typdefinitionen string für Elemente vom Typ char, wstringfür , u16string für wchar_t, für char16_tund u32string für char32_t.

Traits
CharT Beschreibt Attribute für die basic_string und basic_istream Spezialisierung.

os
Der Ausgabedatenstrom, in den der day Wert ausgegeben werden soll.

d
Die day Ausgabe.

hms
Die hh_mm_ss Ausgabe.

li
Die local_info Ausgabe.

m
Die month Ausgabe.

md
Die month_day Ausgabe.

mdl
Die month_day_last Ausgabe.

mwd
Die month_weekday Ausgabe.

mwdl
Die month_weekday_last Ausgabe.

si
Die sys_info Ausgabe.

t
The local_time, gps_time, , tai_time, or utc_time to output.

TimeZonePtr
Ein Zeiger auf die in der zoned_timeDatei gespeicherte time_zone .

wd
Die weekday Ausgabe.

wdi
Die weekday_indexed Ausgabe.

wdl
Die weekday_last Ausgabe.

y
Die year Ausgabe.

ym
Die year_month Ausgabe.

ymd
Die year_month_day Ausgabe.

ymdl
Die year_month_day_last Ausgabe.

ymwd
Die year_month_weekday Ausgabe.

ymwdl
Die year_month_weekday_last Ausgabe.

zt
Die zoned_time Ausgabe.

Rückgabewert

Der von Ihnen übergebene Ausgabedatenstrom, os

Hinweise

1) Der day Wert wird als Dezimalzahl ausgegeben, mit einer führenden Null, wenn das Ergebnis eine einzelne Ziffer sein würde. Wenn !d.ok()" kein gültiger Tag" an die Ausgabe angefügt wird.

2) Der hh_mm_ss Wert wird als Stunden:Minuten:Sekunden:Tausendstel Sekunden ausgegeben. Beispiel: "00:00:05.721"

3) Der abgekürzte Monatsname, wobei das gebietsschema verwendet wird, das osdem zugeordnet ist, wird ausgegeben. Beispiel: Jan. If !m.ok(), then " is not a valid month" is appended to the output.

4) Der abgekürzte Monatsname, wobei das gebietsschema verwendet wird, das dem Datum zugeordnet osist, gefolgt vom Datum, mit einer führenden Null, wenn das Ergebnis eine einzelne Ziffer sein würde, wird ausgegeben. Beispiel: Jan/05. Wenn !md.ok(), kann an " is not a valid month" die Ausgabe des Monats angefügt werden und "is not a valid day" kann an die Ausgabe des Tages angefügt werden. Beispiel: 204 is not a valid month/204 is not a valid day.

5) Der abgekürzte Monatsname, wobei das gebietsschema verwendet wird, das mit os, gefolgt von /last. Beispiel: Jan/last.

6) Der abgekürzte Wochentagsname, wobei das Gebietsschema verwendet wird, das mit dem zugeordneten Gebietsschema verknüpft osist, gefolgt vom n. Wochentag im Monat, den er in Klammern darstellt. Beispiel: Mon[1].

7) Der abgekürzte Wochentagsname, wobei das Gebietsschema verwendet wird, das mit dem gebietsschema verknüpft osist, gefolgt vom letzten Wochentag im Monat, den er in eckigen Klammern darstellt. Beispiel: Jan/Mon[last].

8) Der abgekürzte Wochentagsname unter Verwendung des Gebietsschemas, das dem zugeordnet osist, wird ausgegeben. If !wd.ok(), then " is not a valid weekday" is appended to the output.

9) Der abgekürzte Wochentagsname unter Verwendung des gebietsschemas, das zugeordnet osist, wird ausgegeben, gefolgt vom Wochentag des Monats in Klammern. Beispiel: Mon[3]. Wenn !wd.ok(), kann " is not a valid weekday" an den Tag der Wochenausgabe angefügt werden und "is not a valid index" kann an die Indexausgabe des Wochentags angefügt werden.

10) Der letzte Wochentag eines Monats unter Verwendung des gebietsschemas, dem zugeordnet osist, wird ausgegeben, gefolgt von [last]dem Datum. Beispiel: Tue[last] 2019-10-29. Wenn !wd.ok(), kann " is not a valid weekday" an den Tag der Wochenausgabe angefügt werden und "is not a valid index" kann an die Indexausgabe des Wochentags angefügt werden.

11) Das Jahr wird mit 0 (Null) bis vier Ziffern aufgefüllt, wenn das Ergebnis kleiner wäre als das. If !y.ok(), then " is not a valid year" is appended to the output.

12) Die year_month Ausgabe ist in der Form jjjj-mm-tt. Wenn ym.ok der Wert zurückgegeben falsewird, wird der " is not a valid date" Wert angefügt.

13) Die year_month_day Ausgabe ist in der Form jjjj-mm-tt. Wenn ymd.ok der Wert zurückgegeben falsewird, wird der " is not a valid date" Wert angefügt.

14) Die year_month_day_last Ausgabe im Format jjjj/monat/last. Beispiel: 2020/May/last.

15) Die year_month_weekday Ausgabe im Format JJJJ/Monat/Wochentag[Index]. Beispiel: 1996/Jan/Wed[1]

16) Die year_month_weekday_last Ausgabe im Format JJJJ/Monat/Wochentag[letzte]. Beispiel: 1996/Jan/Wed[last]

17) Die tai_time Ausgabe ist in der Form jjjj-mm-dd hh:mm:sss. Beispiel: 2021-08-13 23:23:08.4358666

18) Die utc_time Ausgabe ist in der Form jjjj-mm-dd hh:mm:ssss. Beispiel: 2021-08-13 23:23:08.4358666

19) Die gps_time Ausgabe ist in der Form jjjj-mm-dd hh:mm:sss. Beispiel: 2021-08-13 23:23:08.4358666

20) Die local_time Ausgabe ist die Anzahl der Sekunden seit der Epoche der Uhr. Es wird wie von os << std::chrono::sys_time<Duration>(some_local_time.time_since_epoch());. Wenn es sich beispielsweise some_local_time um den 18. August 2021 um 13:13 Uhr handelt, lautet 1597792380die Ausgabe .

21) In der Implementierung von Microsoft wird eine sys_info Ausgabe als seine begin, end, , offset, saveund abbrev Felder ausgegeben. Beispiel: begin: 2021-03-14 10:00:00, end: 2021-11-07 09:00:00, offset: -25200s, save: 60min, abbrev: PDT

22) Bei der Implementierung von Microsoft wird eine local_info Ausgabe als jjjj-mm-dd hh:mm::sssss ausgegeben. Beispiel: 2021-09-17 13:55:59.6590120

23) Die Ortszeit in der zoned_time (abgerufen als zt.get_local_time()) wird mit dem Format jjjj-mm-dd hh:mm:ss zeitzone ausgegeben. Beispiel: 2021-09-15 10:45:00 GMT-6

Beispiel: operator<<

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
    std::cout << utc_clock::now() << '\n';

    year_month ym{ 2021y / April };
    std::cout << ym;
    return 0;
}
2021-08-16 20:47:05.6299822
2021/Apr

operator modulo

Operator für Modulo-Vorgänge auf duration.

1)
template <class Rep1, class Period1, class Rep2>
constexpr duration<Rep1, Period1, Rep2>::type
   operator%(
      const duration<Rep1, Period1>& Dur,
      const Rep2& Div);

2)
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr typename common_type<duration<Rep1, _Period1>, duration<Rep2, Period2>>::type
   operator%(
     const duration<Rep1, Period1>& Left,
     const duration<Rep2, Period2>& Right);

Parameter

Dur
Ein duration-Objekt.

Div
Ein Integralwert.

Left
Der Dividend. Das Modulo ist der re Standard der, nachdem die Dividende durch den Divisor geteilt wurde.

Right
Das rechte duration Objekt, der Divisor.

Rückgabewert

1) Gibt ein duration Objekt zurück, dessen Intervalllänge modulo DivistDur.

2) Gibt einen Wert zurück, der Modulo RightdarstelltLeft.

operator/ für duration

Divisionsoperator für duration-Objekte.

1)
template <class Rep1, class Period1, class Rep2>
constexpr duration<typename common_type<Rep1, Rep2>::type, Period1>
   operator/(
     const duration<Rep1, Period1>& Dur,
     const Rep2& Div);

2)
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr typename common_type<Rep1, Rep2>::type
   operator/(
     const duration<Rep1, Period1>& Left,
     const duration<Rep2, Period2>& Right);

Parameter

Dur
Ein duration-Objekt.

Div
Ein Integralwert.

Left\w Das linke duration Objekt.

Right
Das rechte duration-Objekt.

Rückgabewert

1) Ein Dauerobjekt, dessen Intervalllänge die Länge des Dividierens Dur durch den Wert Divist.

2) Das Verhältnis der Intervalllängen von Left und Right.

Sofern is_convertible<Rep2, common_type<Rep1, Rep2>>sie nicht wahr ist und Rep2 keine Instanziierung ist duration, nimmt der erste Operator nicht an der Überladungsauflösung teil. Weitere Informationen finden Sie unter <type_traits>.

operator/ für Kalenderdaten

Stellt eine Syntax zum Erstellen von Kalenderdaten in den folgenden Formularen bereit:

Monat/Tag/Jahr
Tag/Monat/Jahr
Jahr/Monat/Tag

Sie können den Tag durch Folgendes ersetzen:

last
weekday[n] für den n. Tag des Monats
weekday[last] für den letzten weekday Monat.

Teiltermine können wie folgt gebildet werden:

year_month ym = 2015y/April;
month_day md1 = April/4;
month_day md2 = 4d/April;

Ganze Zahlen können verwendet werden, solange die Interpretation nicht mehrdeutig ist.

/////////  returns year_month

// 1
constexpr year_month
operator/(const year& y, const month& m) noexcept; // C++20

// 2
constexpr year_month
operator/(const year& y, int m) noexcept; // C++20
 
/////////  returns month_day

// 3
constexpr month_day
operator/(const month& m, const day& d) noexcept; // C++20

// 4
constexpr month_day
operator/(const month& m, int d) noexcept; // C++20

// 5
constexpr month_day
operator/(int m, const day& d) noexcept; // C++20

// 6
constexpr month_day
operator/(const day& d, const month& m) noexcept; // C++20

// 7
constexpr month_day
operator/(const day& d, int m) noexcept; // C++20

/////////  returns month_day_last

// 8
constexpr month_day_last
operator/(const month& m, last_spec) noexcept; // C++20

// 9
constexpr month_day_last
operator/(int m, last_spec) noexcept; // C++20

// 10
constexpr month_day_last
operator/(last_spec, const month& m) noexcept; // C++20

// 11
constexpr month_day_last
operator/(last_spec, int m) noexcept; // C++20

/////////  returns month_weekday

// 12
constexpr month_weekday
operator/(const month& m, const weekday_indexed& wdi) noexcept; // C++20

// 13
constexpr month_weekday
operator/(int m, const weekday_indexed& wdi) noexcept; // C++20

// 14
constexpr month_weekday
operator/(const weekday_indexed& wdi, const month& m) noexcept; // C++20

// 15
constexpr month_weekday
operator/(const weekday_indexed& wdi, int m) noexcept; // C++20

/////////  returns month_weekday_last

// 16
constexpr month_weekday_last
operator/(const month& m, const weekday_last& wdl) noexcept; // C++20

// 17
constexpr month_weekday_last
operator/(int m, const weekday_last& wdl) noexcept; // C++20

// 18
constexpr month_weekday_last
operator/(const weekday_last& wdl, const month& m) noexcept; // C++20

// 19
constexpr month_weekday_last
operator/(const weekday_last& wdl, int m) noexcept; // C++20

/////////  returns year_month_day

// 20
constexpr year_month_day
operator/(const year_month& ym, const day& d) noexcept; // C++20

// 21
constexpr year_month_day
operator/(const year_month& ym, int d) noexcept; // C++20

// 22
constexpr year_month_day
operator/(const year& y, const month_day& md) noexcept; // C++20

// 23
constexpr year_month_day
operator/(int y, const month_day& md) noexcept; // C++20

// 24
constexpr year_month_day
operator/(const month_day& md, const year& y) noexcept; // C++20

// 25
constexpr year_month_day
operator/(const month_day& md, int y) noexcept; // C++20

/////////  returns year_month_day_last

// 26
constexpr year_month_day_last
operator/(const year_month& ym, last_spec) noexcept; // C++20

// 27
constexpr year_month_day_last
operator/(const year& y, const month_day_last& mdl) noexcept; // C++20

// 28
constexpr year_month_day_last
operator/(int y, const month_day_last& mdl) noexcept; // C++20

// 29
constexpr year_month_day_last
operator/(const month_day_last& mdl, const year& y) noexcept; // C++20

// 30
constexpr year_month_day_last
operator/(const month_day_last& mdl, int y) noexcept; // C++20

/////////  returns year_month_weekday

// 31
constexpr year_month_weekday
operator/(const year_month& ym, const weekday_indexed& wdi) noexcept; // C++20

// 32
constexpr year_month_weekday
operator/(const year& y, const month_weekday& mwd) noexcept; // C++20

// 33
constexpr year_month_weekday
operator/(int y, const month_weekday& mwd) noexcept; // C++20

// 34
constexpr year_month_weekday
operator/(const month_weekday& mwd, const year& y) noexcept; // C++20

// 35
constexpr year_month_weekday
operator/(const month_weekday& mwd, int y) noexcept; // C++20

/////////  returns year_month_weekday_last

// 36
constexpr year_month_weekday_last
operator/(const year_month& ym, const weekday_last& wdl) noexcept; // C++20

// 37
constexpr year_month_weekday_last
operator/(const year& y, const month_weekday_last& mwdl) noexcept; // C++20

// 38
constexpr year_month_weekday_last
operator/(int y, const month_weekday_last& mwdl) noexcept; // C++20

// 39
constexpr year_month_weekday_last
operator/(const month_weekday_last& mwdl, const year& y) noexcept; // C++20

// 40
constexpr year_month_weekday_last
operator/(const month_weekday_last& mwdl, int y) noexcept; // C++20

Parameter

d
Der Tag. Wird entweder als ganze Zahl im Bereich [1,31] oder als Eine daybereitgestellt.

lastspec
Ein leerer Tagtyp, der das letzte Element in der Sequenz angibt. Beispielsweise 2021y/May/last ist der letzte Tag vom Mai 2021.

m
Der Monat. Wird entweder als ganze Zahl im Bereich [1,12] oder als Eine monthbereitgestellt.

md
Der Monat und der Tag.

mdl
Der letzte Tag des angegebenen Monats.

mwd
Der n-th Wochentag des angegebenen Monats.

mwdl
Der letzte Wochentag des angegebenen Monats.

wdi
Ein Wochentagsindex (weekday_indexed). Beispielsweise weekday_indexed(Monday, 1) ist der erste Montag eines Monats.

wdl
Der letzte Wochentag eines Monats. Beispielsweise Monday[last] ist der letzte Montag eines Monats.

y
Das Jahr. Wird entweder als ganze Zahl oder als eine yearganze Zahl bereitgestellt.

ym
Das Jahr und der Monat.

Rückgabewert

1) year_month(y, m)
2) year_month(y, month(m))
3) month_day(m, d)
4) month_day(m, day(d))
5) month_day(month(m), d)
6) month_day(m, d)
7) month_day(month(m), d)
8) month_day_last(m)
9) month_day_last(month(m))
10) month_day_last(m)
11) month_day_last(month(m))
12) month_weekday(m, wdi)
13) month_weekday(month(m), wdi)
14) month_weekday(m, wdi)
15) month_weekday(month(m), wdi)
16) month_weekday_last(m, wdl)
17) month_weekday_last(month(m), wdl)
18) month_weekday_last(m, wdl)
19) month_weekday_last(month(m), wdl)
20) year_month_day(ym.year(), ym.month(), d)
21) year_month_day(ym.year(), ym.month(), day(d))
22) year_month_day(y, md.month(), md.day())
23) year_month_day(year(y), md.month(), md.day())
24) year_month_day(y, md.month(), md.day())
25) year_month_day(year(y), md.month(), md.day())
26) year_month_day_last(ym.year(), month_day_last(ym.month()))
27) year_month_day_last(y, mdl)
28) year_month_day_last(year(y), mdl)
29) year_month_day_last(y, mdl)
30) year_month_day_last(year(y), mdl)
31) year_month_weekday(ym.year(), ym.month(), wdi)
32) year_month_weekday(y, mwd.month(), mwd.weekday_indexed())
33) year_month_weekday(year(y), mwd.month(), mwd.weekday_indexed())
34) year_month_weekday(y, mwd.month(), mwd.weekday_indexed())
35) year_month_weekday(year(y), mwd.month(), mwd.weekday_indexed())
36) year_month_weekday_last(ym.year(), ym.month(), wdl)
37) year_month_weekday_last(y, mwdl.month(), mwdl.weekday_last())
38) year_month_weekday_last(year(y), mwdl.month(), mwdl.weekday_last())
39) year_month_weekday_last(y, mwdl.month(), mwdl.weekday_last())
40) year_month_weekday_last(year(y), mwdl.month(), mwdl.weekday_last())

Beispiel: operator/ für Kalenderdaten

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
    month m{ July }; // Jul
    month_day md{ April / 4 }; // Apr/04
    month_day md2{ 4d / April }; // Apr/04
    month_day_last mdl{ January / last }; // Jan/last
    month_weekday mw{ 11 / Monday[1] }; // Nov/Mon[1]
    month_weekday_last mwl{ January / Monday[last] }; // Jan/Mon[last]
    weekday wd{ Monday }; // Mon
    weekday_indexed wdi{ Monday, 1 }; // Mon[1]
    year_month ym{ 2021y / April }; // 2021/Apr
    year_month_day ymd{ January / 1d / 2021y }; // 2021-01-01
    year_month_day ymd2{ 2021y / 5 / 7 }; // 2021-05-07
    year_month_day_last ymdl{ April / last / 1975 }; // 1975/Apr/last
    year_month_weekday ymw{ 1997y / January / Wednesday[1] }; // 1997/Jan/Wed[1]
    year_month_weekday_last ymwl{ 1997y / January / Wednesday[last] }; // 1997/Jan/Wed[last]
    int yearValue{ 2021 / 4 / 4 }; // 126

    std::cout << m << '\n' << md << '\n' << md2 << '\n' << mdl << '\n' << mw
        << '\n' << mwl << '\n' << wd << '\n' << wdi << '\n'
        << ym << '\n' << ymd << '\n' << ymd2 << '\n' << ymdl
        << '\n' << ymw << '\n' << ymwl << '\n' << yearValue;

    return 0;
}
Jul
Apr/04
Apr/04
Jan/last
Nov/Mon[1]
Jan/Mon[last]
Mon
Mon[1]
2021/Apr
2021-01-01
2021-05-07
1975/Apr/last
1997/Jan/Wed[1]
1997/Jan/Wed[last]
126