VLink  2.0.0
A high-performance communication middleware
vlink::Uint128类 参考final

128-bit unsigned integer represented as two 64-bit halves with full operator support. 更多...

#include <uint128.h>

vlink::Uint128 的协作图:

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. 更多...
 
Uint128operator+= (const Uint128 &other) noexcept
 Adds other to *this in-place with carry propagation. 更多...
 
Uint128operator-= (const Uint128 &other) noexcept
 Subtracts other from *this in-place with borrow propagation. 更多...
 
Uint128operator*= (const Uint128 &other) noexcept
 Multiplies *this by other in-place. 更多...
 
Uint128operator/= (const Uint128 &other)
 Divides *this by other in-place. 更多...
 
Uint128operator%= (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). 更多...
 
Uint128operator|= (const Uint128 &other) noexcept
 Applies bitwise OR with other in-place. 更多...
 
Uint128operator&= (const Uint128 &other) noexcept
 Applies bitwise AND with other in-place. 更多...
 
Uint128operator^= (const Uint128 &other) noexcept
 Applies bitwise XOR with other in-place. 更多...
 
Uint128operator<<= (int shift) noexcept
 Shifts *this left by shift bits in-place. 更多...
 
Uint128operator>>= (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. 更多...
 
Uint128operator++ () 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. 更多...
 
Uint128operator-- () 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.

构造及析构函数说明

◆ Uint128() [1/3]

vlink::Uint128::Uint128 ( )
defaultnoexcept

Default-constructs a zero-valued Uint128.

这是这个函数的调用关系图:

◆ Uint128() [2/3]

template<typename T >
constexpr vlink::Uint128::Uint128 ( v)
inlineconstexprnoexcept

Constructs from an integral-like type T (implicit on purpose).

  • When T is __uint128_t (where available) the source is split into halves.
  • When T is signed the source is sign-extended: a negative value yields high_ = ~uint64_t{0} and low_ = the two's-complement bit pattern.
  • When T is unsigned the source is zero-extended into low_ with high_ = 0.
  • For any other T both halves keep their default value of 0; no diagnostic is emitted because integrality is intentionally not asserted here.
模板参数
TSource type (integral or __uint128_t).
参数
vSource value.
注解
Non-explicit by design so integral literals interoperate naturally.

◆ Uint128() [3/3]

vlink::Uint128::Uint128 ( uint64_t  high,
uint64_t  low 
)
inlineexplicitnoexcept

Constructs from explicit high and low halves.

Details

参数
highUpper 64 bits.
lowLower 64 bits.

成员函数说明

◆ get_high()

uint64_t vlink::Uint128::get_high ( ) const
inlinenoexcept

Returns the upper 64 bits of the stored value.

返回
High half.

◆ get_low()

uint64_t vlink::Uint128::get_low ( ) const
inlinenoexcept

Returns the lower 64 bits of the stored value.

返回
Low half.

◆ operator!=()

bool vlink::Uint128::operator!= ( const Uint128 other) const
inlinenoexcept

Returns true when any half differs.

参数
otherRight operand.
返回
Inequality result.

◆ operator%()

Uint128 vlink::Uint128::operator% ( const Uint128 other) const
inline

Returns the remainder of *this divided by other.

参数
otherDivisor.
返回
Remainder.
异常
std::domain_errorwhen other is zero.

◆ operator%=()

Uint128 & vlink::Uint128::operator%= ( const Uint128 other)
inline

Computes *this modulo other in-place.

参数
otherDivisor.
返回
Reference to *this.
异常
std::domain_errorwhen other is zero.

◆ operator&()

Uint128 vlink::Uint128::operator& ( const Uint128 other) const
inlinenoexcept

Returns the bitwise AND of *this and other.

参数
otherRight operand.
返回
New value with each bit set only when set in both operands.

◆ operator&=()

Uint128 & vlink::Uint128::operator&= ( const Uint128 other)
inlinenoexcept

Applies bitwise AND with other in-place.

参数
otherRight operand.
返回
Reference to *this.

◆ operator*()

Uint128 vlink::Uint128::operator* ( const Uint128 other) const
inlinenoexcept

Returns the product of *this and other.

Delegates to native __uint128_t multiplication when available; otherwise falls back to mul_u128_fallback.

参数
otherRight operand.
返回
Low 128 bits of the true product.

◆ operator*=()

Uint128 & vlink::Uint128::operator*= ( const Uint128 other)
inlinenoexcept

Multiplies *this by other in-place.

参数
otherRight operand.
返回
Reference to *this.

◆ operator+()

Uint128 vlink::Uint128::operator+ ( const Uint128 other) const
inlinenoexcept

Returns the sum of *this and other.

参数
otherRight operand.
返回
New value equal to *this + other (wraps on overflow).

◆ operator++() [1/2]

Uint128 & vlink::Uint128::operator++ ( )
inlinenoexcept

Pre-increment with carry across the 64-bit boundary.

返回
Reference to the incremented value.

◆ operator++() [2/2]

Uint128 vlink::Uint128::operator++ ( int  )
inlinenoexcept

Post-increment returning a copy of the value prior to incrementing.

返回
Pre-increment value.

◆ operator+=()

Uint128 & vlink::Uint128::operator+= ( const Uint128 other)
inlinenoexcept

Adds other to *this in-place with carry propagation.

参数
otherRight operand.
返回
Reference to *this.

◆ operator-()

Uint128 vlink::Uint128::operator- ( const Uint128 other) const
inlinenoexcept

Returns the difference of *this and other.

参数
otherRight operand.
返回
New value equal to *this - other (wraps on underflow).

◆ operator--() [1/2]

Uint128 & vlink::Uint128::operator-- ( )
inlinenoexcept

Pre-decrement with borrow across the 64-bit boundary.

返回
Reference to the decremented value.

◆ operator--() [2/2]

Uint128 vlink::Uint128::operator-- ( int  )
inlinenoexcept

Post-decrement returning a copy of the value prior to decrementing.

返回
Pre-decrement value.

◆ operator-=()

Uint128 & vlink::Uint128::operator-= ( const Uint128 other)
inlinenoexcept

Subtracts other from *this in-place with borrow propagation.

参数
otherRight operand.
返回
Reference to *this.

◆ operator/()

Uint128 vlink::Uint128::operator/ ( const Uint128 other) const
inline

Returns the quotient of *this divided by other.

参数
otherDivisor.
返回
Quotient.
异常
std::domain_errorwhen other is zero.

◆ operator/=()

Uint128 & vlink::Uint128::operator/= ( const Uint128 other)
inline

Divides *this by other in-place.

参数
otherDivisor.
返回
Reference to *this.
异常
std::domain_errorwhen other is zero.

◆ operator<()

bool vlink::Uint128::operator< ( const Uint128 other) const
inlinenoexcept

Returns true when *this is strictly less than other.

Compares the high half first; ties are broken by the low half.

参数
otherRight operand.
返回
Comparison result.

◆ operator<<()

Uint128 vlink::Uint128::operator<< ( int  shift) const
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.

参数
shiftBit positions to shift.
返回
Shifted value.

◆ operator<<=()

Uint128 & vlink::Uint128::operator<<= ( int  shift)
inlinenoexcept

Shifts *this left by shift bits in-place.

参数
shiftBit positions to shift.
返回
Reference to *this.

◆ operator<=()

bool vlink::Uint128::operator<= ( const Uint128 other) const
inlinenoexcept

Returns true when *this is less than or equal to other.

参数
otherRight operand.
返回
Comparison result.

◆ operator==()

bool vlink::Uint128::operator== ( const Uint128 other) const
inlinenoexcept

Returns true when both halves of *this and other are equal.

参数
otherRight operand.
返回
Equality result.

◆ operator>()

bool vlink::Uint128::operator> ( const Uint128 other) const
inlinenoexcept

Returns true when *this is strictly greater than other.

参数
otherRight operand.
返回
Comparison result.

◆ operator>=()

bool vlink::Uint128::operator>= ( const Uint128 other) const
inlinenoexcept

Returns true when *this is greater than or equal to other.

参数
otherRight operand.
返回
Comparison result.

◆ operator>>()

Uint128 vlink::Uint128::operator>> ( int  shift) const
inlinenoexcept

Returns *this shifted right by shift bits (logical, zero-fill).

Same edge-case rules as operator<<.

参数
shiftBit positions to shift.
返回
Shifted value.

◆ operator>>=()

Uint128 & vlink::Uint128::operator>>= ( int  shift)
inlinenoexcept

Shifts *this right by shift bits in-place (logical, zero-fill).

参数
shiftBit positions to shift.
返回
Reference to *this.

◆ operator^()

Uint128 vlink::Uint128::operator^ ( const Uint128 other) const
inlinenoexcept

Returns the bitwise XOR of *this and other.

参数
otherRight operand.
返回
New value with each bit set when the bits differ between operands.

◆ operator^=()

Uint128 & vlink::Uint128::operator^= ( const Uint128 other)
inlinenoexcept

Applies bitwise XOR with other in-place.

参数
otherRight operand.
返回
Reference to *this.

◆ operator|()

Uint128 vlink::Uint128::operator| ( const Uint128 other) const
inlinenoexcept

Returns the bitwise OR of *this and other.

参数
otherRight operand.
返回
New value with each bit set if it is set in either operand.

◆ operator|=()

Uint128 & vlink::Uint128::operator|= ( const Uint128 other)
inlinenoexcept

Applies bitwise OR with other in-place.

参数
otherRight operand.
返回
Reference to *this.

◆ operator~()

Uint128 vlink::Uint128::operator~ ( ) const
inlinenoexcept

Returns the bitwise complement of *this.

返回
New value with all 128 bits inverted.
函数调用图:

友元及相关函数文档

◆ operator<<

VLINK_EXPORT friend std::ostream& operator<< ( std::ostream &  os,
const Uint128 value 
)
friend

Writes the uppercase hexadecimal representation of value to os.

参数
osOutput stream.
valueValue to print.
返回
Reference to os.

该类的文档由以下文件生成: