diff options
author | arkady-e1ppa <arkady-e1ppa@yandex-team.com> | 2023-11-24 02:58:57 +0300 |
---|---|---|
committer | arkady-e1ppa <arkady-e1ppa@yandex-team.com> | 2023-11-24 03:21:46 +0300 |
commit | a7789e237827cb31cf0cf2f0d3f4a388a75d73e3 (patch) | |
tree | 526956192159b539e0c3119793897b316c917750 /library/cpp/yt/misc/guid-inl.h | |
parent | 7b1701b1c40fea4015925f883a628af9e20f8f6d (diff) | |
download | ydb-a7789e237827cb31cf0cf2f0d3f4a388a75d73e3.tar.gz |
YT-20547: TJobId is now strongly typed
Diffstat (limited to 'library/cpp/yt/misc/guid-inl.h')
-rw-r--r-- | library/cpp/yt/misc/guid-inl.h | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/library/cpp/yt/misc/guid-inl.h b/library/cpp/yt/misc/guid-inl.h index 2d94b5701b..1c71d794bd 100644 --- a/library/cpp/yt/misc/guid-inl.h +++ b/library/cpp/yt/misc/guid-inl.h @@ -32,18 +32,7 @@ Y_FORCE_INLINE TGuid::operator bool() const //////////////////////////////////////////////////////////////////////////////// -Y_FORCE_INLINE bool operator == (TGuid lhs, TGuid rhs) -{ - return lhs.Parts64[0] == rhs.Parts64[0] && - lhs.Parts64[1] == rhs.Parts64[1]; -} - -Y_FORCE_INLINE bool operator != (TGuid lhs, TGuid rhs) -{ - return !(lhs == rhs); -} - -Y_FORCE_INLINE bool operator < (TGuid lhs, TGuid rhs) +Y_FORCE_INLINE bool LessImpl(TGuid lhs, TGuid rhs) noexcept { #ifdef __GNUC__ ui64 lhs0 = __builtin_bswap64(lhs.Parts64[0]); @@ -62,6 +51,25 @@ Y_FORCE_INLINE bool operator < (TGuid lhs, TGuid rhs) #endif } +Y_FORCE_INLINE bool operator == (const TGuid& lhs, const TGuid& rhs) noexcept +{ + return lhs.Parts64[0] == rhs.Parts64[0] && + lhs.Parts64[1] == rhs.Parts64[1]; +} + +Y_FORCE_INLINE std::strong_ordering operator <=> (const TGuid& lhs, const TGuid& rhs) noexcept +{ + if (LessImpl(lhs, rhs)) { + return std::strong_ordering::less; + } + + if (lhs == rhs) { + return std::strong_ordering::equal; + } + + return std::strong_ordering::greater; +} + //////////////////////////////////////////////////////////////////////////////// } // namespace NYT |