std::chrono::operator/(calendar)
<chrono>
year_month
const std::chrono::month & m ) noexcept
-> std::chrono::year_month ;
month_day
const std::chrono::day & d ) noexcept
-> std::chrono::month_day ;
-> std::chrono::month_day ;
const std::chrono::month & m ) noexcept
-> std::chrono::month_day ;
month_day_last
std::chrono::last_spec ) noexcept
-> std::chrono::month_day_last ;
const std::chrono::month & m ) noexcept
-> std::chrono::month_day_last ;
month_weekday
const std::chrono::weekday_indexed & wdi ) noexcept
-> std::chrono::month_weekday ;
const std::chrono::month & m ) noexcept
-> std::chrono::month_weekday ;
month_weekday_last
const std::chrono::weekday_last & wdl ) noexcept
-> std::chrono::month_weekday_last ;
const std::chrono::month & m ) noexcept
-> std::chrono::month_weekday_last ;
year_month_day
const std::chrono::day & d ) noexcept
-> std::chrono::year_month_day ;
const std::chrono::month_day & md ) noexcept
-> std::chrono::year_month_day ;
const std::chrono::year & y ) noexcept
-> std::chrono::year_month_day ;
year_month_day_last
std::chrono::last_spec ) noexcept
const std::chrono::month_day_last & mdl ) noexcept
-> std::chrono::year_month_day_last ;
const std::chrono::year & y ) noexcept
-> std::chrono::year_month_day_last ;
year_month_weekday
const std::chrono::weekday_indexed & wdi ) noexcept
const std::chrono::month_weekday & mwd ) noexcept
-> std::chrono::year_month_weekday ;
const std::chrono::year & y ) noexcept
-> std::chrono::year_month_weekday ;
year_month_weekday_last
const std::chrono::weekday_last & wdl ) noexcept
const std::chrono::month_weekday_last & mwdl ) noexcept
-> std::chrono::year_month_weekday_last ;
const std::chrono::year & y ) noexcept
-> std::chrono::year_month_weekday_last ;
These operator/ overloads provide a conventional syntax for the creation of Proleptic Gregorian calendar dates.
For creation of a full date, any of the following three orders are accepted:
-
year/month/day
, -
month/day/year
, -
day/month/year
.
In each case day
can replaced with one of:
- std::chrono::last, for the last day of the month;
-
weekday[i]
, for thei
th weekday of the month; -
weekday[std::chrono::last]
, for the last weekday of the month.
A plain integer is accepted if its meaning is unambiguous from the types of other operands: 2005y/4/5 is allowed, but 5/April/2005 is not.
Partial-date types (year_month
, month_day
, etc.) can be created by not applying the second operator/ in any of the three orders.
[edit] Return value
[edit] Example
#include <chrono> using namespace std::chrono; constexpr auto ym{2021y/8}; static_assert(ym == year_month(year(2021), August)); constexpr auto md{9/15d}; static_assert(md == month_day(September, day(15))); constexpr auto mdl{October/last}; static_assert(mdl == month_day_last(month(10))); constexpr auto mw{11/Monday[3]}; static_assert(mw == month_weekday(November, Monday[3])); constexpr auto mwdl{December/Sunday[last]}; static_assert(mwdl == month_weekday_last(month(12), weekday_last(Sunday))); // Those 3 year/month/day orders that people actually use on this planet and beyond: constexpr auto ymd{year(2021)/January/day(23)}; static_assert(ymd == month{1}/23/2021); static_assert(ymd == day{23}/1/2021); static_assert(ymd == year_month_day(2021y, month(January), 23d)); int main() {}