aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/misc/compare.h
blob: 22e452b355c285a4d2bf8da4c029537e19535f01 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once

#include <util/generic/string.h>

#include <string_view>

namespace NYT {

////////////////////////////////////////////////////////////////////////////////

//! Compares #lhs with #rhs;
//! returns -1 (if |lhs < rhs|), 0 (if |lhs == rhs|), or 1 (|lhs > rhs|).
template <class T>
int TernaryCompare(const T& lhs, const T& rhs);

//! Same as #TernaryCompare but handles NaN values gracefully
//! (assuming NaNs are larger than any regular number and all NaNs are equal).
//! If |T| is not a floating-point type, #NaNSafeTernaryCompare is equivalent to #TernaryCompare.
template <class T>
int NaNSafeTernaryCompare(const T& lhs, const T& rhs);

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT

#define COMPARE_INL_H_
#include "compare-inl.h"
#undef COMPARE_INL_H_