std::chrono::weekday:: operator[]
From ru.cppreference.net
|
constexpr
std::
chrono
::
weekday_indexed
operator [ ] ( unsigned index ) const noexcept ; |
(1) | (начиная с C++20) |
|
constexpr
std::
chrono
::
weekday_last
operator [ ] ( std:: chrono :: last_spec ) const noexcept ; |
(2) | (начиная с C++20) |
1)
Создает объект
weekday_indexed
из
*
this
и
index
. Результат представляет
index
-й день недели в некотором пока не определенном месяце. Если
index
не находится в диапазоне
[
0
,
7
]
или если
!
ok
(
)
, значения (базовый день недели и индекс), хранящиеся в результате, не определены.
2)
Создает
weekday_last
из
*
this
. Результат представляет последний день недели в некотором пока не указанном месяце.
Возвращаемое значение
1)
std::
chrono
::
weekday_indexed
(
*
this, index
)
2)
std::
chrono
::
weekday_last
(
*
this
)
Пример
Запустить этот код
#include <chrono> #include <iostream> using namespace std::chrono; int main() { constexpr auto second_tuesday_in_October_2019 = year_month_day{Tuesday[2] / October / 2019y}; constexpr auto last_tuesday_in_October_2019 = year_month_day{Tuesday[last] / October / 2019y}; std::cout << second_tuesday_in_October_2019 << '\n' << last_tuesday_in_October_2019 << '\n'; }
Возможный вывод:
2019-10-08 2019-10-29