time_point_operator_cmp
time_point_operator_cmp (time_point 비교 연산)
std::chrono::time_point에 대한 비교 연산자예요. 두 시간점을 ==, !=, <, <=, >, >=, <=>로 비교해요.
출처: cppreference
본문
std::chrono::time_point의 비교 연산자는 <chrono> 헤더에 정의되어 있어요.
template< class Clock, class Duration1, class Duration2 >
constexpr bool operator==( const std::chrono::time_point<Clock, Duration1>& lhs,
const std::chrono::time_point<Clock, Duration2>& rhs );
template< class Clock, class Duration1, class Duration2 >
constexpr /* three-way */ operator<=>( const std::chrono::time_point<Clock, Duration1>& lhs,
const std::chrono::time_point<Clock, Duration2>& rhs );
같은 시계의 두 시간점을 비교해요. 기간을 공통 타입으로 변환해 비교해요.
예제 (Example)
#include <chrono>
#include <iostream>
int main()
{
using namespace std::chrono;
steady_clock::time_point a = steady_clock::now();
steady_clock::time_point b = a + seconds{1};
std::cout << (a < b) << '\n'; // 1
}