diff options
| author | Anton Samokhvalov <[email protected]> | 2022-02-10 16:45:17 +0300 |
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:45:17 +0300 |
| commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
| tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/generic/guid.h | |
| parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
Restoring authorship annotation for Anton Samokhvalov <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'util/generic/guid.h')
| -rw-r--r-- | util/generic/guid.h | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/util/generic/guid.h b/util/generic/guid.h index 9f1adf1f61d..2bf6c8ad99c 100644 --- a/util/generic/guid.h +++ b/util/generic/guid.h @@ -3,7 +3,7 @@ #include "fwd.h" #include <util/str_stl.h> - + /** * UUID generation * @@ -14,16 +14,16 @@ * See https://clubs.at.yandex-team.ru/stackoverflow/10238/10240 * and https://st.yandex-team.ru/IGNIETFERRO-768 for details. */ -struct TGUID { +struct TGUID { ui32 dw[4] = {}; constexpr bool IsEmpty() const noexcept { - return (dw[0] | dw[1] | dw[2] | dw[3]) == 0; - } - + return (dw[0] | dw[1] | dw[2] | dw[3]) == 0; + } + constexpr explicit operator bool() const noexcept { - return !IsEmpty(); - } + return !IsEmpty(); + } // xxxx-xxxx-xxxx-xxxx TString AsGuidString() const; @@ -43,29 +43,29 @@ struct TGUID { **/ static TGUID CreateTimebased(); }; - + constexpr bool operator==(const TGUID& a, const TGUID& b) noexcept { return a.dw[0] == b.dw[0] && a.dw[1] == b.dw[1] && a.dw[2] == b.dw[2] && a.dw[3] == b.dw[3]; -} - +} + constexpr bool operator!=(const TGUID& a, const TGUID& b) noexcept { - return !(a == b); -} - -struct TGUIDHash { + return !(a == b); +} + +struct TGUIDHash { constexpr int operator()(const TGUID& a) const noexcept { - return a.dw[0] + a.dw[1] + a.dw[2] + a.dw[3]; - } + return a.dw[0] + a.dw[1] + a.dw[2] + a.dw[3]; + } }; - + template <> -struct THash<TGUID> { +struct THash<TGUID> { constexpr size_t operator()(const TGUID& g) const noexcept { return (unsigned int)TGUIDHash()(g); } }; -void CreateGuid(TGUID* res); +void CreateGuid(TGUID* res); TString GetGuidAsString(const TGUID& g); TString CreateGuidAsString(); TGUID GetGuid(TStringBuf s); |
