载入中...
搜索中...
未找到
StrongUint64.h
浏览该文件的文档.
1#pragma once
2
5#include <compare>
6#include <cstddef>
7#include <cstdint>
8#include <functional>
9#include <limits>
10#include <optional>
11
12namespace eve::detail {
13
14template <typename Tag>
17public:
19 constexpr StrongUint64() noexcept = default;
21 explicit constexpr StrongUint64(std::uint64_t value) noexcept : value_(value) {}
22
24 [[nodiscard]] static constexpr StrongUint64 zero() noexcept { return {}; }
26 [[nodiscard]] constexpr std::uint64_t value() const noexcept { return value_; }
28 [[nodiscard]] constexpr bool isZero() const noexcept { return value_ == 0; }
30 [[nodiscard]] constexpr std::optional<StrongUint64> incremented() const noexcept {
31 if (value_ == std::numeric_limits<std::uint64_t>::max()) return std::nullopt;
33 return StrongUint64(value_ + 1);
34 }
35
37 friend constexpr bool operator==(const StrongUint64&, const StrongUint64&) noexcept = default;
39 friend constexpr auto operator<=>(const StrongUint64&, const StrongUint64&) noexcept = default;
40
41private:
42 std::uint64_t value_ = 0;
43};
44
45} // namespace eve::detail
46
47namespace std {
48
49template <typename Tag>
51struct hash<eve::detail::StrongUint64<Tag>> {
53 std::size_t operator()(const eve::detail::StrongUint64<Tag>& value) const noexcept {
54 return std::hash<std::uint64_t>{}(value.value());
55 }
56};
57
58} // namespace std
double value
std::array< std::uint8_t, 32 > hash
Definition Evpack.cpp:172
StrongUint64 public API.
constexpr std::optional< StrongUint64 > incremented() const noexcept
Returns the next value, or empty instead of unsigned wraparound.
friend constexpr bool operator==(const StrongUint64 &, const StrongUint64 &) noexcept=default
Operator ==.
constexpr std::uint64_t value() const noexcept
Returns the underlying value at an explicit protocol boundary.
constexpr StrongUint64() noexcept=default
Constructs the zero value.
friend constexpr auto operator<=>(const StrongUint64 &, const StrongUint64 &) noexcept=default
Operator <=>.
static constexpr StrongUint64 zero() noexcept
Returns the zero value for this strong type.
constexpr bool isZero() const noexcept
Returns whether this value is zero.
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16