|
VLink 2.0.0
A high-performance communication middleware
|
Portable 128-bit unsigned integer with full arithmetic, bitwise, and comparison operators. 更多...
#include <cstdint>#include <iostream>#include <type_traits>#include <utility>#include "./macros.h"类 | |
| class | vlink::Uint128 |
| 128-bit unsigned integer stored as two 64-bit halves with full operator support. 更多... | |
| struct | std::hash< vlink::Uint128 > |
std::hash specialisation for vlink::Uint128. 更多... | |
命名空间 | |
| namespace | vlink |
| namespace | std |
| STL namespace | |
类型定义 | |
| using | vlink::uint128_t = Uint128 |
Portable 128-bit unsigned integer with full arithmetic, bitwise, and comparison operators.
Uint128 represents a 128-bit unsigned value as two uint64_t halves (high_ and low_). On platforms that provide __uint128_t (GCC/Clang with 64-bit targets), multiplication is delegated to the compiler's native type for maximum performance. On other platforms a portable fallback algorithm (mul_u128_fallback) is used.
Supported operations:
| Category | Operators | Notes |
|---|---|---|
| Arithmetic | + - * / % += -= *= /= %= | / and % throw on divisor zero |
| Bitwise | | & ^ ~ << >> |= &= ^= <<= >>= | Shifts clamped to [0, 127] | | Comparison | == != < > <= >= | Lexicographic (high then low) | | Increment | ++ – (prefix and postfix) | 128-bit carry propagated | | Stream | operator<<(ostream) | Hexadecimal output |
T: T is __uint128_t (when available), high and low halves are extracted.operator __uint128_t() is provided for interoperability with compiler-native 128-bit arithmetic.std::hash<vlink::Uint128> specialisation is defined at the bottom of this file, enabling Uint128 to be used as a key in std::unordered_map / std::unordered_set.