|
VLink
2.0.0
A high-performance communication middleware
|
128-bit unsigned integer represented as two 64-bit halves with full operator support. 更多...
#include <uint128.h>
Public 成员函数 | |
| Uint128 () noexcept=default | |
Default-constructs a zero-valued Uint128. 更多... | |
| template<typename T > | |
| constexpr | Uint128 (T v) noexcept |
Constructs from an integral-like type T (implicit on purpose). 更多... | |
| Uint128 (uint64_t high, uint64_t low) noexcept | |
| Constructs from explicit high and low halves. 更多... | |
| Uint128 | operator+ (const Uint128 &other) const noexcept |
Returns the sum of *this and other. 更多... | |
| Uint128 | operator- (const Uint128 &other) const noexcept |
Returns the difference of *this and other. 更多... | |
| Uint128 | operator* (const Uint128 &other) const noexcept |
Returns the product of *this and other. 更多... | |
| Uint128 | operator/ (const Uint128 &other) const |
Returns the quotient of *this divided by other. 更多... | |
| Uint128 | operator% (const Uint128 &other) const |
Returns the remainder of *this divided by other. 更多... | |
| Uint128 & | operator+= (const Uint128 &other) noexcept |
Adds other to *this in-place with carry propagation. 更多... | |
| Uint128 & | operator-= (const Uint128 &other) noexcept |
Subtracts other from *this in-place with borrow propagation. 更多... | |
| Uint128 & | operator*= (const Uint128 &other) noexcept |
Multiplies *this by other in-place. 更多... | |
| Uint128 & | operator/= (const Uint128 &other) |
Divides *this by other in-place. 更多... | |
| Uint128 & | operator%= (const Uint128 &other) |
Computes *this modulo other in-place. 更多... | |
| Uint128 | operator| (const Uint128 &other) const noexcept |
Returns the bitwise OR of *this and other. 更多... | |
| Uint128 | operator& (const Uint128 &other) const noexcept |
Returns the bitwise AND of *this and other. 更多... | |
| Uint128 | operator^ (const Uint128 &other) const noexcept |
Returns the bitwise XOR of *this and other. 更多... | |
| Uint128 | operator~ () const noexcept |
Returns the bitwise complement of *this. 更多... | |
| Uint128 | operator<< (int shift) const noexcept |
Returns *this shifted left by shift bits. 更多... | |
| Uint128 | operator>> (int shift) const noexcept |
Returns *this shifted right by shift bits (logical, zero-fill). 更多... | |
| Uint128 & | operator|= (const Uint128 &other) noexcept |
Applies bitwise OR with other in-place. 更多... | |
| Uint128 & | operator&= (const Uint128 &other) noexcept |
Applies bitwise AND with other in-place. 更多... | |
| Uint128 & | operator^= (const Uint128 &other) noexcept |
Applies bitwise XOR with other in-place. 更多... | |
| Uint128 & | operator<<= (int shift) noexcept |
Shifts *this left by shift bits in-place. 更多... | |
| Uint128 & | operator>>= (int shift) noexcept |
Shifts *this right by shift bits in-place (logical, zero-fill). 更多... | |
| bool | operator== (const Uint128 &other) const noexcept |
Returns true when both halves of *this and other are equal. 更多... | |
| bool | operator!= (const Uint128 &other) const noexcept |
Returns true when any half differs. 更多... | |
| bool | operator< (const Uint128 &other) const noexcept |
Returns true when *this is strictly less than other. 更多... | |
| bool | operator> (const Uint128 &other) const noexcept |
Returns true when *this is strictly greater than other. 更多... | |
| bool | operator<= (const Uint128 &other) const noexcept |
Returns true when *this is less than or equal to other. 更多... | |
| bool | operator>= (const Uint128 &other) const noexcept |
Returns true when *this is greater than or equal to other. 更多... | |
| Uint128 & | operator++ () noexcept |
| Pre-increment with carry across the 64-bit boundary. 更多... | |
| Uint128 | operator++ (int) noexcept |
| Post-increment returning a copy of the value prior to incrementing. 更多... | |
| Uint128 & | operator-- () noexcept |
| Pre-decrement with borrow across the 64-bit boundary. 更多... | |
| Uint128 | operator-- (int) noexcept |
| Post-decrement returning a copy of the value prior to decrementing. 更多... | |
| uint64_t | get_high () const noexcept |
| Returns the upper 64 bits of the stored value. 更多... | |
| uint64_t | get_low () const noexcept |
| Returns the lower 64 bits of the stored value. 更多... | |
友元 | |
| VLINK_EXPORT friend std::ostream & | operator<< (std::ostream &os, const Uint128 &value) noexcept |
Writes the uppercase hexadecimal representation of value to os. 更多... | |
128-bit unsigned integer represented as two 64-bit halves with full operator support.
Logical layout is (high_ << 64) | low_. All arithmetic propagates carry and borrow across the 64-bit boundary so the observable behaviour matches a true 128-bit unsigned integer.
|
defaultnoexcept |
|
inlineconstexprnoexcept |
Constructs from an integral-like type T (implicit on purpose).
T is __uint128_t (where available) the source is split into halves.T is signed the source is sign-extended: a negative value yields high_ = ~uint64_t{0} and low_ = the two's-complement bit pattern.T is unsigned the source is zero-extended into low_ with high_ = 0.T both halves keep their default value of 0; no diagnostic is emitted because integrality is intentionally not asserted here.| T | Source type (integral or __uint128_t). |
| v | Source value. |
|
inlineexplicitnoexcept |
Constructs from explicit high and low halves.
Details
| high | Upper 64 bits. |
| low | Lower 64 bits. |
|
inlinenoexcept |
Returns the upper 64 bits of the stored value.
|
inlinenoexcept |
Returns the lower 64 bits of the stored value.
|
inlinenoexcept |
Returns true when any half differs.
| other | Right operand. |
Returns the remainder of *this divided by other.
| other | Divisor. |
| std::domain_error | when other is zero. |
Computes *this modulo other in-place.
| other | Divisor. |
*this.| std::domain_error | when other is zero. |
Returns the bitwise AND of *this and other.
| other | Right operand. |
Applies bitwise AND with other in-place.
| other | Right operand. |
*this. Returns the product of *this and other.
Delegates to native __uint128_t multiplication when available; otherwise falls back to mul_u128_fallback.
| other | Right operand. |
Multiplies *this by other in-place.
| other | Right operand. |
*this. Returns the sum of *this and other.
| other | Right operand. |
*this + other (wraps on overflow).
|
inlinenoexcept |
Pre-increment with carry across the 64-bit boundary.
|
inlinenoexcept |
Post-increment returning a copy of the value prior to incrementing.
Adds other to *this in-place with carry propagation.
| other | Right operand. |
*this. Returns the difference of *this and other.
| other | Right operand. |
*this - other (wraps on underflow).
|
inlinenoexcept |
Pre-decrement with borrow across the 64-bit boundary.
|
inlinenoexcept |
Post-decrement returning a copy of the value prior to decrementing.
Subtracts other from *this in-place with borrow propagation.
| other | Right operand. |
*this. Returns the quotient of *this divided by other.
| other | Divisor. |
| std::domain_error | when other is zero. |
Divides *this by other in-place.
| other | Divisor. |
*this.| std::domain_error | when other is zero. |
|
inlinenoexcept |
Returns true when *this is strictly less than other.
Compares the high half first; ties are broken by the low half.
| other | Right operand. |
|
inlinenoexcept |
Returns *this shifted left by shift bits.
Shift values <= 0 leave the value unchanged; >= 128 produce zero; values in [64, 127] move bits across the 64-bit boundary.
| shift | Bit positions to shift. |
|
inlinenoexcept |
Shifts *this left by shift bits in-place.
| shift | Bit positions to shift. |
*this.
|
inlinenoexcept |
Returns true when *this is less than or equal to other.
| other | Right operand. |
|
inlinenoexcept |
Returns true when both halves of *this and other are equal.
| other | Right operand. |
|
inlinenoexcept |
Returns true when *this is strictly greater than other.
| other | Right operand. |
|
inlinenoexcept |
Returns true when *this is greater than or equal to other.
| other | Right operand. |
|
inlinenoexcept |
Returns *this shifted right by shift bits (logical, zero-fill).
Same edge-case rules as operator<<.
| shift | Bit positions to shift. |
|
inlinenoexcept |
Shifts *this right by shift bits in-place (logical, zero-fill).
| shift | Bit positions to shift. |
*this. Returns the bitwise XOR of *this and other.
| other | Right operand. |
Applies bitwise XOR with other in-place.
| other | Right operand. |
*this. Returns the bitwise OR of *this and other.
| other | Right operand. |
Applies bitwise OR with other in-place.
| other | Right operand. |
*this.
|
inlinenoexcept |
Returns the bitwise complement of *this.
|
friend |
Writes the uppercase hexadecimal representation of value to os.
| os | Output stream. |
| value | Value to print. |
os.