Delen via


operators voor <chrono>

operator+

Toevoegingsoperator voor de volgende 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

Retourwaarde

1) Na het Left converteren en Right naar hun gemeenschappelijke type, wordt een duration met een maatstreepgetal geretourneerd dat gelijk is aan de som van de geconverteerde maatstreepjes.

2-3) Retourneert een time_point object dat een tijdstip vertegenwoordigt dat wordt verplaatst door het interval Dur vanaf het tijdstip Time.

4) Geeft als resultaat het resultaat van d+ds.count(). Als het resultaat buiten het bereik [0, 255] valt, wordt het resultaat niet opgegeven.

5) Geeft als resultaat het resultaat van m+ms.count(). Als het resultaat buiten het bereik [1, 12] valt, is het gereduceerde modulo 12 en vervolgens +1.

6) Geeft als resultaat het resultaat van het toevoegen van het aantal dagen en weekdagen aan de weekday. Het resultaat is modulo 7, dus altijd in het bereik [0,6]

7) Geeft als resultaat het resultaat van het toevoegen van het jaar aan het opgegeven aantal jaren.

8) Geeft als resultaat het resultaat van het optellen van het aantal maanden en jaren aan de opgegeven maand en het opgegeven jaar.

9) Geeft als resultaat het resultaat van het toevoegen van maanden of jaren aan een year_month_day. Als ymd.month() dit het Februaryymd.day() bereik [1d, 28d] is en zich niet in het bereik bevindt, ok() kan het resultaat van de toevoeging worden geretourneerdfalse.

10) Retourneert (ymdl.year() / ymdl.month() + dm) / last. Opmerking: De / hier gebruikte operator is geen divisieoperator. Het is de datumoperator.

11) Retourneert ymdl + dm.

12) Retourneert {ymdl.year()+dy, ymdl.month_day_last()}

13) Retourneert ymwd + dm.count().

14-15) Retourneert {ymwd.year()+dy, ymwd.month(), ymwd.weekday_indexed()}.

16) Retourneert (ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last(). Opmerking: De / hier gebruikte operator is geen operator voor delen, maar de datumoperator.

17) Retourneert: ymwdl + dy

Voorbeeld: 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]

Unaire operator+

Pas unaire plus toe op de volgende typen:

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

Retourwaarde

Retourneert *this

operator-

Operator voor aftrekken voor de volgende 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

Retourwaarde

1) Na het converteren van de duur die wordt afgetrokken naar hun gemeenschappelijke type, wordt een duration met een maatstreepgetal geretourneerd dat gelijk is aan het aantal tikken dat Right afgetrokken is van het aantal tikken in Left.

2) Geeft als resultaat een time_point punt in tijd dat wordt verplaatst door de negatie van het tijdsinterval dat wordt vertegenwoordigd door Dur, vanaf het tijdstip dat is opgegeven door Time.

3) Retourneert een duration object dat het tijdsinterval tussen Left en Right.

4) Geeft als resultaat het resultaat van d-ds.count(). Als het resultaat buiten het bereik [0, 255] valt, wordt het resultaat niet opgegeven.

5) Als m.ok() == true en ms.ok() == true, retourneert het resultaat van het aftrekken van de twee maandwaarden of het aftrekken van het aantal maanden. Het resultaat wordt weergegeven in het bereik [1, 12]. Als het resultaat negatief is, loopt het rond. Als u bijvoorbeeld één maand aftrekken van januari (month m1{1} - months{1}; resulteert in 12 (december).

6) Geeft als resultaat het verschil in maanden tussen Left en Right

7) Als Left.ok() == true en Right.ok() == true, retourneert een weekday in het bereik [days{0}, days{6}].

8) Geeft als resultaat het aantal dagen tussen twee weekdagen.

9) Retourneert year(int(y)-ys.count())

10) Retourneert years(int(y) - int(y2)). Als u twee year waarden aftrekken, resulteert dit in een std::chrono::years, wat het verschil in jaren tussen y en y2. Produceert 2021y-2000ybijvoorbeeld years(21) .

11) Geeft als resultaat het resultaat van het aftrekken van maanden of jaren van een year_month waarde.

12) Geeft als resultaat het resultaat van het aftrekken van maanden jaren van een year_month_day waarde.

13) Geeft als resultaat het resultaat van het aftrekken van het aantal maanden van de year_month_day_last waarde. In wezen: ymdl-dm.

14) Geeft als resultaat het resultaat van het aftrekken van het aantal jaren van de year_month_day_last waarde. In wezen: ymdl-dy.

15) Retourneert het resultaat van het aftrekken van het aantal maanden van de year_month_weekday waarde. In wezen: ymwd-dm.

16) Geeft als resultaat het resultaat van het aftrekken van het aantal jaren van de year_month_weekday waarde. In wezen: ymwd-dy.

17) Geeft als resultaat het resultaat van het aftrekken van het aantal maanden van de year_month_weekday_last waarde. In wezen: ymwdl-dm.

18) Geeft als resultaat het resultaat van het aftrekken van het aantal jaren van de year_month_weekday_last waarde. In wezen: ymwdl-dy.

Voorbeeld: 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'; // 2020/May/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]

Unaire operator-

Onderhandelt een duration.

constexpr common_type_t<duration> operator-() const;

Retourwaarde

Retourneert een ontkende kopie van *this

Voorbeeld: unary 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!=

Bepaalt of:

1) Twee duration objecten vertegenwoordigen niet hetzelfde aantal tikken.
2) Twee time_point objecten vertegenwoordigen niet hetzelfde tijdstip.

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);

Parameterwaarden

Left
De linkerkant duration of time_point het object.

Right
De rechter duration of time_point het object.

Retourwaarde

1) Geeft als resultaat true als het aantal tikken voor het type Left gebruikelijk is en Right niet gelijk is. Anders wordt geretourneerd false.
2) Retourneert als de twee true objecten niet hetzelfde tijdstip vertegenwoordigentime_point. Anders wordt geretourneerd false.

operator*

Vermenigvuldigingsoperator voor duration objecten. Na het converteren van de durations die worden vermenigvuldigd met hun gemeenschappelijke type, wordt een duration met een maatstreepgetal geretourneerd dat gelijk is aan de vermenigvuldiging van de geconverteerde maatstreepjes.

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);

Parameterwaarden

Dur
Een duration-object.

Mult
Een integrale waarde.

Retourwaarde

Retourneert een duration object waarvan de intervallengte wordt Mult vermenigvuldigd met de lengte van Dur.

1) Tenzij is_convertible<Rep2, common_type<Rep1, Rep2>>deze functie wordt bewaard true, neemt deze functie niet deel aan overbelastingsresolutie. Zie <type_traits> voor meer informatie.

2) Tenzij is_convertible<Rep1, common_type<Rep1, Rep2>>deze functie wordt bewaard true, neemt deze functie niet deel aan overbelastingsresolutie. Zie <type_traits> voor meer informatie.

operator<

1) Na het converteren van de durations die worden vergeleken met hun gemeenschappelijke type, bepaalt u of het aantal tikken Left kleiner is dan voor Right.

2) Bepaalt of het tijdstip sinds het tijdvak van de Lefttime_point tijd minder is dan de tijd sinds het tijdvak van de time_point in Right.

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);

Parameterwaarden

Left
De linkerkant duration of time_point het object.

Right
De rechter duration of time_point het object.

Retourwaarde

1) Geeft als resultaat true als het aantal tikken Left kleiner is dan het aantal tikken voor Right. Anders retourneert falsede functie .

2) Geeft als true resultaat als Left dat voorafgaat Right. Anders wordt geretourneerd false.

operator<=

1) Na het converteren van de durations die worden vergeleken met hun gemeenschappelijke type, bepaalt u of het aantal tikken Left kleiner of hetzelfde is als Right.

2) Bepaalt of het tijdstip sinds het tijdvak van de Lefttime_point tijd kleiner is dan of gelijk is aan de tijd sinds het tijdvak van de time_point in Right.

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);

Parameterwaarden

Left
De linkerkant duration of time_point het object.

Right
De rechter duration of time_point het object.

Retourwaarde

1) Geeft als resultaat true als het aantal tikken Left kleiner is dan of gelijk is aan het aantal tikken voor Right. Anders retourneert falsede functie .

2) Geeft als resultaat true of Left gelijk is aan, Right. Anders wordt geretourneerd false.

operator==

Bepaalt of:

1) duration objecten vertegenwoordigen tijdsintervallen met dezelfde lengte.
2) time_point objecten vertegenwoordigen hetzelfde tijdstip.
3) day objecten vertegenwoordigen dezelfde dag.
4) month objecten vertegenwoordigen dezelfde maand.
5) month_day objecten vertegenwoordigen dezelfde maand en dag.
6) month_day_last objecten vertegenwoordigen dezelfde maand.
7) month_weekday objecten vertegenwoordigen dezelfde maand en nde weekdag.
8) month_weekday_last objecten vertegenwoordigen dezelfde maand en laatste weekdag.
9) weekday objecten vertegenwoordigen dezelfde weekdag.
10) weekday_last objecten vertegenwoordigen dezelfde laatste weekdag van de maand.
11) weekday_indexed vertegenwoordigt dezelfde weekdagindex.
12) year vertegenwoordigen hetzelfde jaar.
13) year_month vertegenwoordigt hetzelfde jaar en dezelfde maand.
14) year_month_day vertegenwoordigt hetzelfde jaar, de maand en de dag.
15) year_month_day_last vertegenwoordigt dezelfde laatste dag van het jaar en de maand.
16) year_month_weekday vertegenwoordigt dezelfde weekdag, hetzelfde jaar en dezelfde maand.
17) year_month_weekday_last vertegenwoordigt dezelfde laatste weekdag van de maand, het jaar en de maand.
18) time_zone_link hebben hetzelfde name. De target naam wordt niet meegenomen.
19) zoned_time vertegenwoordigen dezelfde tijd en tijdzone.

// 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

Parameterwaarden

Left
Het linkerobject dat moet worden vergeleken, bijvoorbeeld Left == Right

Right
Het juiste object om te vergelijken.

Retourwaarde

1) Geeft als resultaat true als het aantal tikken voor het type gelijk is Left en Right gelijk is. Anders wordt geretourneerd false.
2) Retourneert true of Left en Right vertegenwoordigt hetzelfde tijdstip. Anders wordt geretourneerd false.
3-17) Geeft als resultaat true of Left en Right dezelfde waarde hebben. Anders wordt geretourneerd false.
18) Geeft als resultaattrue.Left.name() == Right.name() Anders wordt geretourneerd false.
19) Geeft als resultaat true als Left.get_time_zone() == Right.get_time_zone() && Left.get_sys_time() == Right.get_sys_time();

operator>

1) Na het converteren van de durations die worden vergeleken met hun gemeenschappelijke type, bepaalt u of het aantal tikken Left groter is dan voor Right.

2) Bepaalt of het tijdstip sinds het tijdvak van de tijd Lefttime_point groter is dan de tijd sinds het tijdvak van de time_point in Right.

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);

Parameterwaarden

Left
De linkerkant duration of time_point het object.

Right
De rechter duration of time_point het object.

Retourwaarde

1) Geeft als resultaat true als het aantal tikken Left groter is dan het aantal tikken voor Right. Anders retourneert falsede functie .

2) Retourneert true als Left het nakomt Right. Anders wordt geretourneerd false.

operator>=

1) Na het converteren van de durations die worden vergeleken met hun gemeenschappelijke type, bepaalt u of het aantal tikken Left groter dan of gelijk aan Rightis.

2) Bepaalt of het tijdstip sinds het tijdvak van de Lefttime_point tijd groter is dan of gelijk is aan de tijd sinds het tijdvak van de time_point in Right.

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);

Parameterwaarden

Left
De linkerkant duration of time_point het object.

Right
De rechter duration of time_point het object.

Retourwaarde

1) Geeft als resultaat true als het aantal tikken Left groter is dan of gelijk is aan het aantal tikken voor Right. Anders retourneert falsede functie .

2) Retourneert true of Left komt na, of gelijk is aan, Right. Anders wordt geretourneerd false.

operator<=>

De spaceship-operator, metoperator==, synthetiseert operators voor <, <=, >, en >=!= voor de volgende 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;

Parameterwaarden

Left, Right
De day, , duration, monthmonth_day, , month_day_last, time_point, time_zone_link, , year, year_month, year_month_dayom year_month_day_last te vergelijken.

Retourwaarde

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

2)
Gelijk aan: Left.month() <=> Right.month()

3)
Gelijk aan:

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

4)
Gelijk aan:

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

Voorbeeld: 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<<

Voer de volgende typen uit naar een stream:

// 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);

Parameterwaarden

CharT
Het gegevenstype van één teken dat moet worden gelezen uit de stroom en moet worden opgeslagen in de tekenreeks. De C++ Standaardbibliotheek biedt specialisaties van deze klassesjabloon, met de typedefinities string voor elementen van het type char, wstring, voor wchar_t, u16string voor char16_ten u32string voor char32_t.

Traits
Beschrijft CharT kenmerken voor de basic_string en basic_istream specialisatie.

os
De uitvoerstroom waar de day waarde naar wordt verzonden.

d
De day uitvoer.

hms
De hh_mm_ss uitvoer.

li
De local_info uitvoer.

m
De month uitvoer.

md
De month_day uitvoer.

mdl
De month_day_last uitvoer.

mwd
De month_weekday uitvoer.

mwdl
De month_weekday_last uitvoer.

si
De sys_info uitvoer.

t
De local_time, gps_timeof tai_timeutc_time de uitvoer.

TimeZonePtr
Een aanwijzer naar de time_zone opgeslagen in de zoned_time.

wd
De weekday uitvoer.

wdi
De weekday_indexed uitvoer.

wdl
De weekday_last uitvoer.

y
De year uitvoer.

ym
De year_month uitvoer.

ymd
De year_month_day uitvoer.

ymdl
De year_month_day_last uitvoer.

ymwd
De year_month_weekday uitvoer.

ymwdl
De year_month_weekday_last uitvoer.

zt
De zoned_time uitvoer.

Retourwaarde

De uitvoerstroom die u hebt doorgegeven, os

Opmerkingen

1) De day waarde wordt uitgevoerd als een decimaal getal, met een voorloopnul als het resultaat één cijfer zou zijn. Als !d.ok()' is geen geldige dag' wordt toegevoegd aan de uitvoer.

2) De hh_mm_ss waarde wordt uitgevoerd als uren:minuten:seconden:duizendden van seconden. Bijvoorbeeld: "00:00:05.721"

3) De verkorte maandnaam, met behulp van de landinstelling die is gekoppeld osaan, is uitvoer. Bijvoorbeeld: Jan. Als !m.ok(), dan " is not a valid month" wordt toegevoegd aan de uitvoer.

4) De verkorte maandnaam, met behulp van de landinstelling die is gekoppeld aan os, gevolgd door de datum, met een voorloopnul als het resultaat één cijfer zou zijn, is uitvoer. Bijvoorbeeld: Jan/05. Als !md.ok(), " is not a valid month" kan worden toegevoegd aan de uitvoer van de maand en "is not a valid day" kan worden toegevoegd aan de uitvoer van de dag. Bijvoorbeeld: 204 is not a valid month/204 is not a valid day.

5) De verkorte maandnaam, met behulp van de landinstelling die is osgekoppeld aan , gevolgd door /last. Bijvoorbeeld: Jan/last.

6) De verkorte weekdagnaam, met behulp van de landinstelling die is osgekoppeld aan, gevolgd door de nde weekdag in de maand die deze vertegenwoordigt tussen vierkante haken. Bijvoorbeeld: Mon[1].

7) De verkorte weekdagnaam, met behulp van de landinstelling die is osgekoppeld aan, gevolgd door de laatste weekdag in de maand die deze vertegenwoordigt tussen vierkante haken. Bijvoorbeeld: Jan/Mon[last].

8) De verkorte weekdagnaam, met behulp van de landinstelling die is gekoppeld osaan, is uitvoer. Als !wd.ok(), dan " is not a valid weekday" wordt toegevoegd aan de uitvoer.

9) De verkorte naam van de weekdag, met de landinstelling die is osgekoppeld aan, is uitvoer, gevolgd door de weekdag van de maand tussen vierkante haken. Bijvoorbeeld: Mon[3]. Als !wd.ok(), " is not a valid weekday" kan worden toegevoegd aan de dag van de week-uitvoer en "is not a valid index" kan worden toegevoegd aan de uitvoer van de weekdagindex.

10) De laatste weekdag van een maand, met behulp van de landinstelling die is gekoppeld osaan, is uitvoer, gevolgd door [last], gevolgd door de datum. Bijvoorbeeld: Tue[last] 2019-10-29. Als !wd.ok(), " is not a valid weekday" kan worden toegevoegd aan de dag van de week-uitvoer en "is not a valid index" kan worden toegevoegd aan de uitvoer van de weekdagindex.

11) Het jaar wordt links opgevuld met 0 (nul) tot vier cijfers als het resultaat kleiner is dan dat. Als !y.ok(), dan " is not a valid year" wordt toegevoegd aan de uitvoer.

12) De year_month uitvoer wordt uitgevoerd in de vorm jjjj-mm-dd. Als ym.ok het resultaat falsewordt geretourneerd, wordt deze " is not a valid date" toegevoegd.

13) De year_month_day uitvoer wordt uitgevoerd in de vorm jjjj-mm-dd. Als ymd.ok het resultaat falsewordt geretourneerd, wordt deze " is not a valid date" toegevoegd.

14) De year_month_day_last uitvoer wordt uitgevoerd in de vorm jjjj/maand/laatste. Bijvoorbeeld: 2020/May/last.

15) De year_month_weekday uitvoer wordt uitgevoerd in de vorm jjjj/maand/weekdag[index]. Bijvoorbeeld 1996/Jan/Wed[1]

16) De year_month_weekday_last uitvoer wordt uitgevoerd in de vorm jjjj/maand/weekdag[laatste]. Bijvoorbeeld 1996/Jan/Wed[last]

17) De tai_time uitvoer wordt uitgevoerd in de vorm jjjj-mm-dd uu:mm:ss.sss. Bijvoorbeeld 2021-08-13 23:23:08.4358666

18) De utc_time uitvoer wordt uitgevoerd in de vorm jjjj-mm-dd uu:mm:ss.sss. Bijvoorbeeld 2021-08-13 23:23:08.4358666

19) De gps_time uitvoer wordt uitgevoerd in de vorm jjjj-mm-dd uu:mm:ss.sss. Bijvoorbeeld 2021-08-13 23:23:08.4358666

20) De local_time uitvoer is als het aantal seconden sinds de tijdsduur van de klok. Het is uitvoer alsof.os << std::chrono::sys_time<Duration>(some_local_time.time_since_epoch()); Als some_local_time bijvoorbeeld 18 augustus 2021 13:13 uur is, is 1597792380de uitvoer .

21) In de implementatie van Microsoft wordt een sys_info uitvoer uitgevoerd als de beginvelden , en endoffsetsaveabbrev velden. Bijvoorbeeld: begin: 2021-03-14 10:00:00, end: 2021-11-07 09:00:00, offset: -25200s, save: 60min, abbrev: PDT

22) In de implementatie van Microsoft wordt een local_info uitvoer uitgevoerd als jjjj-mm-dd uu:mm:ss.sssss. Bijvoorbeeld 2021-09-17 13:55:59.6590120

23) De lokale tijd in de zoned_time (verkregen als zt.get_local_time()) is uitvoer met de notatie jjjj-mm-dd uu:mm:ss tijdzone. Bijvoorbeeld 2021-09-15 10:45:00 GMT-6

Voorbeeld: 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 voor modulo-bewerkingen op 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);

Parameterwaarden

Dur
Een duration-object.

Div
Een integrale waarde.

Left
Het dividend. De modulo is de rest na het delen van het dividend door de deler.

Right
Het juiste duration object, de deler.

Retourwaarde

1) Retourneert een duration object waarvan de intervallengte modulo DurisDiv.

2) Geeft als resultaat een waarde die modulo LeftvertegenwoordigtRight.

operator/ voor duration

Delingsoperator voor duration objecten.

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);

Parameterwaarden

Dur
Een duration-object.

Div
Een integrale waarde.

Left
Het linkerobject duration .

Right
Het juiste duration object.

Retourwaarde

1) Een duurobject waarvan de intervallengte de lengte is van Dur gedeeld door de waarde Div.

2) De verhouding van de intervallengten van Left en Right.

is_convertible<Rep2, common_type<Rep1, Rep2>> Tenzij waar is en Rep2 geen instantiëring durationis, neemt de eerste operator niet deel aan overbelastingsresolutie. Zie <type_traits> voor meer informatie.

operator/ voor kalenderdatums

Biedt syntaxis voor het maken van kalenderdatums in de volgende formulieren:

maand/dag/jaar
dag/maand/jaar
jaar/maand/dag

U kunt de dag vervangen door:

last
weekday[n] voor de ne dag van de maand
weekday[last] voor de laatste weekday van de maand.

Gedeeltelijke datums kunnen als volgt worden gevormd:

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

Gehele getallen kunnen worden gebruikt zolang de interpretatie niet dubbelzinnig is.

/////////  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

Parameterwaarden

d
De dag. Opgegeven als een geheel getal in het bereik [1,31], of als een day.

lastspec
Een leeg tagtype dat het laatste item in een reeks aangeeft. Is bijvoorbeeld 2021y/May/last de laatste dag van mei 2021.

m
De maand. Opgegeven als een geheel getal in het bereik [1,12], of als een month.

md
De maand en dag.

mdl
De laatste dag van de opgegeven maand.

mwd
De n-th weekdag van de opgegeven maand.

mwdl
De laatste weekdag van de opgegeven maand.

wdi
Een weekdagindex (weekday_indexed). Is bijvoorbeeld weekday_indexed(Monday, 1) de eerste maandag van een maand.

wdl
De laatste weekdag van een maand. Is bijvoorbeeld Monday[last] de laatste maandag van een maand.

y
Het jaar. Opgegeven als een geheel getal of als een year.

ym
Het jaar en de maand.

Retourwaarde

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())

Voorbeeld: operator/ voor kalenderdatums

// 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