Namespaces
Variants

std::chrono:: operator/ (calendar)

From cppreference.net
**Примечание:** В данном фрагменте HTML нет текста для перевода, кроме содержимого тега ` `, которое согласно инструкциям не подлежит переводу, так как является C++ специфическим термином. **Примечание:** В данном фрагменте HTML нет текста для перевода, кроме содержимого тега ` `, которое согласно инструкциям не подлежит переводу, так как является C++ специфическим термином. **Примечание:** Текст внутри тега ` ` не переведен, как и требовалось, поскольку `month_weekday` является C++ специфическим термином. HTML структура и атрибуты полностью сохранены без изменений. **Примечание:** Текст `month_weekday_last` не был переведен, так как это C++ специфический термин и находится внутри тега ` `, как указано в требованиях. Текст не требует перевода, так как: 1. `year_month_day` находится внутри тега ` ` - согласно правилам, текст внутри ` ` не переводится 2. Это C++ специфический термин - согласно правилам, C++ термины не переводятся 3. Остальной текст отсутствует - только HTML разметка **Примечание:** Текст внутри тега ` ` не переведён, так как это C++ специфический термин, который должен сохранить оригинальное написание согласно требованиям. HTML структура и атрибуты полностью сохранены без изменений. **Примечание:** В данном случае весь текст находится внутри тега ` `, который согласно инструкциям не подлежит переводу. Поэтому перевод не требуется, исходный формат сохранен. **Объяснение:** - HTML-теги и атрибуты сохранены без изменений - Текст внутри тега ` ` не переведен, так как это C++ специфический термин - Форматирование и структура таблицы полностью сохранены - Термин `year_month_weekday_last` является частью C++ стандартной библиотеки chrono и не подлежит переводу
Определено в заголовочном файле <chrono>
year_month
constexpr auto operator / ( const std:: chrono :: year & y,

const std:: chrono :: month & m ) noexcept

- > std:: chrono :: year_month ;
(1) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: year & y, int m ) noexcept
- > std:: chrono :: year_month ;
(2) (начиная с C++20)
month_day
constexpr auto operator / ( const std:: chrono :: month & m,

const std:: chrono :: day & d ) noexcept

- > std:: chrono :: month_day ;
(3) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: month & m, int d ) noexcept
- > std:: chrono :: month_day ;
(4) (начиная с C++20)
constexpr auto operator / ( int m, const std:: chrono :: day & d ) noexcept
- > std:: chrono :: month_day ;
(5) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: day & d,

const std:: chrono :: month & m ) noexcept

- > std:: chrono :: month_day ;
(6) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: day & d, int m ) noexcept
- > std:: chrono :: month_day ;
(7) (начиная с C++20)
month_day_last
(8) (начиная с C++20)
constexpr auto operator / ( int m, std:: chrono :: last_spec ) noexcept
- > std:: chrono :: month_day_last ;
(9) (начиная с C++20)
constexpr auto operator / ( std:: chrono :: last_spec ,

const std:: chrono :: month & m ) noexcept

- > std:: chrono :: month_day_last ;
(10) (начиная с C++20)
constexpr auto operator / ( std:: chrono :: last_spec , int m ) noexcept
- > std:: chrono :: month_day_last ;
(11) (начиная с C++20)
month_weekday
constexpr auto operator / ( const std:: chrono :: month & m,

const std:: chrono :: weekday_indexed & wdi ) noexcept

- > std:: chrono :: month_weekday ;
(12) (начиная с C++20)
constexpr auto operator / ( int m, const std:: chrono :: weekday_indexed & wdi ) noexcept
- > std:: chrono :: month_weekday ;
(13) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: weekday_indexed & wdi,

const std:: chrono :: month & m ) noexcept

- > std:: chrono :: month_weekday ;
(14) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: weekday_indexed & wdi, int m ) noexcept
- > std:: chrono :: month_weekday ;
(15) (начиная с C++20)
month_weekday_last
constexpr auto operator / ( const std:: chrono :: month & m,

const std:: chrono :: weekday_last & wdl ) noexcept

- > std:: chrono :: month_weekday_last ;
(16) (начиная с C++20)
constexpr auto operator / ( int m, const std:: chrono :: weekday_last & wdl ) noexcept
- > std:: chrono :: month_weekday_last ;
(17) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: weekday_last & wdl,

const std:: chrono :: month & m ) noexcept

- > std:: chrono :: month_weekday_last ;
(18) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: weekday_last & wdl, int m ) noexcept
- > std:: chrono :: month_weekday_last ;
(19) (начиная с C++20)
year_month_day
constexpr auto operator / ( const std:: chrono :: year_month & ym,

const std:: chrono :: day & d ) noexcept

- > std:: chrono :: year_month_day ;
(20) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: year_month & ym, int d ) noexcept
- > std:: chrono :: year_month_day ;
(21) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: year & y,

const std:: chrono :: month_day & md ) noexcept

- > std:: chrono :: year_month_day ;
(22) (начиная с C++20)
constexpr auto operator / ( int y, const std:: chrono :: month_day & md ) noexcept
- > std:: chrono :: year_month_day ;
(23) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: month_day & md,

const std:: chrono :: year & y ) noexcept

- > std:: chrono :: year_month_day ;
(24) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: month_day & md, int y ) noexcept
- > std:: chrono :: year_month_day ;
(25) (начиная с C++20)
year_month_day_last
(26) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: year & y,

const std:: chrono :: month_day_last & mdl ) noexcept

- > std:: chrono :: year_month_day_last ;
(27) (начиная с C++20)
constexpr auto operator / ( int y, const std:: chrono :: month_day_last & mdl ) noexcept
- > std:: chrono :: year_month_day_last ;
(28) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: month_day_last & mdl,

const std:: chrono :: year & y ) noexcept

- > std:: chrono :: year_month_day_last ;
(29) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: month_day_last & mdl, int y ) noexcept
- > std:: chrono :: year_month_day_last ;
(30) (начиная с C++20)
year_month_weekday
constexpr auto operator / ( const std:: chrono :: year_month & ym,

const std:: chrono :: weekday_indexed & wdi ) noexcept

- > std:: chrono :: year_month_weekday ;
(31) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: year & y,

const std:: chrono :: month_weekday & mwd ) noexcept

- > std:: chrono :: year_month_weekday ;
(32) (начиная с C++20)
constexpr auto operator / ( int y, const std:: chrono :: month_weekday & mwd ) noexcept
- > std:: chrono :: year_month_weekday ;
(33) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: month_weekday & mwd,

const std:: chrono :: year & y ) noexcept

- > std:: chrono :: year_month_weekday ;
(34) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: month_weekday & mwd, int y ) noexcept
- > std:: chrono :: year_month_weekday ;
(35) (начиная с C++20)
year_month_weekday_last
constexpr auto operator / ( const std:: chrono :: year_month & ym,

const std:: chrono :: weekday_last & wdl ) noexcept

- > std:: chrono :: year_month_weekday_last ;
(36) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: year & y,

const std:: chrono :: month_weekday_last & mwdl ) noexcept

- > std:: chrono :: year_month_weekday_last ;
(37) (начиная с C++20)
constexpr auto operator / ( int y, const std:: chrono :: month_weekday_last & mwdl ) noexcept
- > std:: chrono :: year_month_weekday_last ;
(38) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: month_weekday_last & mwdl,

const std:: chrono :: year & y ) noexcept

- > std:: chrono :: year_month_weekday_last ;
(39) (начиная с C++20)
constexpr auto operator / ( const std:: chrono :: month_weekday_last & mwdl, int y ) noexcept
- > std:: chrono :: year_month_weekday_last ;
(40) (начиная с C++20)

Эти operator / перегрузки предоставляют стандартный синтаксис для создания дат пролептического григорианского календаря .

Для создания полной даты принимается любой из следующих трех порядков:

  • year/month/day ,
  • month/day/year ,
  • day/month/year .

В каждом случае day может быть заменён одним из:

  • std::chrono::last , для последнего дня месяца;
  • weekday [ i ] , для i -го weekday месяца;
  • weekday [ std::chrono::last ] , для последнего weekday месяца.

Обычное целое число принимается, если его значение однозначно определяется по типам других операндов: 2005y / 4 / 5 допустимо, но 5 / April / 2005 недопустимо.

Типы частичных дат ( year_month , month_day и др.) могут быть созданы без применения второго operator / в любом из трех порядков.

Возвращаемое значение

20) std:: chrono :: year_month_day ( ym. year ( ) , ym. month ( ) , d )
21) std:: chrono :: year_month_day ( ym. year ( ) , ym. month ( ) , std:: chrono :: day ( d ) )
22,24) std:: chrono :: year_month_day ( y, md. month ( ) , md. day ( ) )
23,25) std:: chrono :: year_month_day ( std:: chrono :: year ( y ) , md. month ( ) , md. day ( ) )
31) std:: chrono :: year_month_weekday ( ym. year ( ) , ym. month ( ) , wdi )
32,34) std:: chrono :: year_month_weekday ( y, mwd. month ( ) , mwd. weekday_indexed ( ) )
33,35) std:: chrono :: year_month_weekday ( std:: chrono :: year ( y ) , mwd. month ( ) , mwd. weekday_indexed ( ) )
36) std:: chrono :: year_month_weekday_last ( ym. year ( ) , ym. month ( ) , wdl )
37,39) std:: chrono :: year_month_weekday_last ( y, mwdl. month ( ) , mwdl. weekday_last ( ) )
38,40) std:: chrono :: year_month_weekday_last ( std:: chrono :: year ( y ) , mwdl. month ( ) , mwdl. weekday_last ( ) )

Пример

#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)));
// Три порядка год/месяц/день, которые люди фактически используют на этой планете и за ее пределами:
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() {}