Namespaces
Variants

std::chrono::weekday_indexed:: weekday_indexed

From cppreference.net
weekday_indexed ( ) = default ;
(1) (desde C++20)
constexpr weekday_indexed ( const std:: chrono :: weekday & wd, unsigned index ) noexcept ;
(2) (desde C++20)

Construye un weekday_indexed .

1) El constructor por defecto deja tanto el std::chrono::weekday como el valor del índice sin inicializar.
2) Construye un weekday_indexed que almacena el día de la semana wd y el índice index . Los valores almacenados no están especificados si ! wd. ok ( ) || index > 7 .

Notas

Una forma más conveniente de construir un weekday_indexed es con el weekday 's operator [ ] , es decir, wd [ index ] .

Ejemplo

#include <chrono>
#include <iostream>
using namespace std::chrono;
int main()
{
    constexpr auto third_friday = weekday_indexed(Friday, 3); // uses constructor (2)
    static_assert(third_friday == Friday[3]);
    weekday_indexed wdi = Tuesday[2]; // represents the 2nd Tuesday
    std::cout << year_month_day{ wdi / October / 2019y } << '\n';
}

Salida posible:

2019-10-08

Véase también

sintaxis conveniente para construir un weekday_indexed o weekday_last a partir de este weekday
(función miembro pública de std::chrono::weekday )