Espacios de nombres
Variantes
Acciones

std::chrono::operator==,<=>(std::chrono::year)

De cppreference.com
< cpp‎ | chrono‎ | year
 
 
Biblioteca de servicios
 
 
 
Definido en el archivo de encabezado <chrono>
constexpr bool operator==( const std::chrono::year& x,
                           const std::chrono::year& y ) noexcept;
(1) (desde C++20)
constexpr std::strong_ordering operator<=>( const std::chrono::year& x,
                                            const std::chrono::year& y ) noexcept;
(2) (desde C++20)

Compara los dos valores de tipo std::chrono::year x e y.

Los operadores <, <=, >, >=, y != se sintetizan de operator<=> y operator==, respectivamente.

[editar] Valor de retorno

1) int(x) == int(y)
2) int(x) <=> int(y)

[editar] Ejemplo

#include <iostream>
#include <chrono>
 
int main()
{
    using namespace std::chrono;
 
    constexpr year y1{2020};
    constexpr year y2{2021};
 
    std::cout << std::boolalpha << (y1 != y2) << '\n';
 
    static_assert(
        (2020y < 2023y) && (2020y == 2020y) && (2020y <= 2023y) &&
        (2023y > 2020y) && (2023y != 2020y) && (2023y >= 2020y)
    );
}

Salida:

true