|
VLink
2.0.0
A high-performance communication middleware
|
Portable 128-bit unsigned integer with native-fastpath multiplication. 更多...
#include <cstdint>#include <iostream>#include <type_traits>#include <utility>#include "./macros.h"类 | |
| class | vlink::Uint128 |
| 128-bit unsigned integer represented as two 64-bit halves with full operator support. 更多... | |
| struct | std::hash< vlink::Uint128 > |
std::hash specialisation enabling vlink::Uint128 keys in unordered containers. 更多... | |
命名空间 | |
| vlink | |
类型定义 | |
| using | vlink::uint128_t = Uint128 |
| Convenience alias matching the lowercase fixed-width style of the standard integer types. 更多... | |
Portable 128-bit unsigned integer with native-fastpath multiplication.
vlink::Uint128 stores the value as a pair of uint64_t halves (high_, low_). On GCC and Clang 64-bit targets the multiplication, division and modulo paths delegate to the compiler-native __uint128_t for maximum performance; on platforms without that builtin the portable fallback (mul_u128_fallback / u128_divmod) is used.
Supported operator set:
| Category | Operators | Notes |
|---|---|---|
| Arithmetic | + - * / % += -= *= /= %= | Division throws on divisor 0 |
| Bitwise | OR AND XOR NOT shift compound-assign | Shifts clamp to [0, 128] |
| Comparison | == != < > <= >= | Lexicographic over (high, low) |
| Increment | ++ – (prefix and postfix) | Carry/borrow crosses the 64-bit line |
| Stream | operator<<(std::ostream&) | Uppercase hexadecimal output |
Uint128 transparently. Signed source values are sign-extended, unsigned values are zero-extended, and __uint128_t source values are split into halves.__uint128_t operator __uint128_t() is provided on platforms that expose the type.std::hash<vlink::Uint128> specialisation at the bottom of this file enables use inside std::unordered_map and std::unordered_set.