VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
vlink::Uint128类 参考final

128-bit unsigned integer stored 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 a Uint128 from any integral type T (implicit conversion).
 Uint128 (uint64_t high, uint64_t low) noexcept
 Constructs a Uint128 from explicit high and low 64-bit 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 NOT (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 if *this equals other.
bool operator!= (const Uint128 &other) const noexcept
 Returns true if *this does not equal other.
bool operator< (const Uint128 &other) const noexcept
 Returns true if *this is less than other.
bool operator> (const Uint128 &other) const noexcept
 Returns true if *this is greater than other.
bool operator<= (const Uint128 &other) const noexcept
 Returns true if *this is less than or equal to other.
bool operator>= (const Uint128 &other) const noexcept
 Returns true if *this is greater than or equal to other.
Uint128operator++ () noexcept
 Pre-increment: increments the value by one and returns *this.
Uint128 operator++ (int) noexcept
 Post-increment: increments the value by one and returns the previous value.
Uint128operator-- () noexcept
 Pre-decrement: decrements the value by one and returns *this.
Uint128 operator-- (int) noexcept
 Post-decrement: decrements the value by one and returns the previous value.
uint64_t get_high () const noexcept
 Returns the upper 64 bits of the 128-bit value.
uint64_t get_low () const noexcept
 Returns the lower 64 bits of the 128-bit value.

友元

VLINK_EXPORT friend std::ostream & operator<< (std::ostream &os, const Uint128 &value) noexcept
 Writes the hexadecimal string representation of the value to os.

详细描述

128-bit unsigned integer stored as two 64-bit halves with full operator support.

Stores the value as (high_ << 64) | low_. All arithmetic correctly handles carry/borrow across the 64-bit boundary. Division and modulo are implemented using a portable binary-long-division algorithm (u128_divmod).

构造及析构函数说明

◆ Uint128() [1/3]

vlink::Uint128::Uint128 ( )
defaultnoexcept

Default-constructs a zero-valued Uint128.

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

◆ Uint128() [2/3]

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

Constructs a Uint128 from any integral type T (implicit conversion).

  • If T is __uint128_t (available on GCC/Clang 64-bit), splits into high and low halves.
  • Otherwise zero-extends the value into low_; high_ is set to zero.
模板参数
TSource integral type.
参数
vSource value.
注解
This constructor is intentionally non-explicit to allow natural integral literals.

◆ Uint128() [3/3]

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

Constructs a Uint128 from explicit high and low 64-bit halves.

Details

参数
highUpper 64 bits.
lowLower 64 bits.

成员函数说明

◆ get_high()

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

Returns the upper 64 bits of the 128-bit value.

返回
High 64-bit word.
这是这个函数的调用关系图:

◆ get_low()

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

Returns the lower 64 bits of the 128-bit value.

返回
Low 64-bit word.
这是这个函数的调用关系图:

◆ operator!=()

bool vlink::Uint128::operator!= ( const Uint128 & other) const
inlinenodiscardnoexcept

Returns true if *this does not equal other.

参数
otherRight-hand operand.
返回
true if any word differs.
函数调用图:

◆ operator%()

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

Returns the remainder of *this divided by other.

参数
otherDivisor.
返回
New Uint128 equal to *this % other.
异常
std::domain_error(or similar) if other is zero.
函数调用图:

◆ operator%=()

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

Computes *this modulo other in-place.

参数
otherDivisor.
返回
Reference to *this.
异常
std::domain_error(or similar) if other is zero.
函数调用图:

◆ operator&()

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

Returns the bitwise AND of *this and other.

参数
otherRight-hand operand.
返回
New Uint128 with each bit set only if set in both operands.
函数调用图:

◆ operator&=()

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

Applies bitwise AND with other in-place.

参数
otherRight-hand operand.
返回
Reference to *this.
函数调用图:

◆ operator*()

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

Returns the product of *this and other.

Uses __uint128_t multiplication when available; falls back to mul_u128_fallback otherwise.

参数
otherRight-hand operand.
返回
New Uint128 equal to *this * other (low 128 bits of true product).
函数调用图:

◆ operator*=()

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

Multiplies *this by other in-place.

参数
otherRight-hand operand.
返回
Reference to *this.
函数调用图:

◆ operator+()

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

Returns the sum of *this and other.

参数
otherRight-hand operand.
返回
New Uint128 equal to *this + other.
函数调用图:

◆ operator++() [1/2]

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

Pre-increment: increments the value by one and returns *this.

Carry from the low word is propagated to the high word.

返回
Reference to the incremented value.
函数调用图:

◆ operator++() [2/2]

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

Post-increment: increments the value by one and returns the previous value.

返回
Copy of the value before incrementing.
函数调用图:

◆ operator+=()

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

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

参数
otherRight-hand operand.
返回
Reference to *this.
函数调用图:

◆ operator-()

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

Returns the difference of *this and other.

参数
otherRight-hand operand.
返回
New Uint128 equal to *this - other (wraps on underflow).
函数调用图:

◆ operator--() [1/2]

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

Pre-decrement: decrements the value by one and returns *this.

Borrow from the low word underflow is propagated to the high word.

返回
Reference to the decremented value.
函数调用图:

◆ operator--() [2/2]

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

Post-decrement: decrements the value by one and returns the previous value.

返回
Copy of the value before decrementing.
函数调用图:

◆ operator-=()

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

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

参数
otherRight-hand operand.
返回
Reference to *this.
函数调用图:

◆ operator/()

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

Returns the quotient of *this divided by other.

参数
otherDivisor.
返回
New Uint128 equal to *this / other.
异常
std::domain_error(or similar) if other is zero.
函数调用图:

◆ operator/=()

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

Divides *this by other in-place.

参数
otherDivisor.
返回
Reference to *this.
异常
std::domain_error(or similar) if other is zero.
函数调用图:

◆ operator<()

bool vlink::Uint128::operator< ( const Uint128 & other) const
inlinenodiscardnoexcept

Returns true if *this is less than other.

Compares the high word first; if equal, compares the low word.

参数
otherRight-hand operand.
返回
true if *this < other.
函数调用图:

◆ operator<<()

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

Returns *this shifted left by shift bits.

  • Shift <= 0: returns *this unchanged.
  • Shift >= 128: returns zero.
  • Shift in [64, 127]: low bits are shifted into the high word.
参数
shiftNumber of bit positions to shift left.
返回
Shifted value.
函数调用图:

◆ operator<<=()

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

Shifts *this left by shift bits in-place.

参数
shiftNumber of bit positions to shift left.
返回
Reference to *this.
函数调用图:

◆ operator<=()

bool vlink::Uint128::operator<= ( const Uint128 & other) const
inlinenodiscardnoexcept

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

参数
otherRight-hand operand.
返回
true if *this <= other.
函数调用图:

◆ operator==()

bool vlink::Uint128::operator== ( const Uint128 & other) const
inlinenodiscardnoexcept

Returns true if *this equals other.

参数
otherRight-hand operand.
返回
true if high and low words are both equal.
函数调用图:

◆ operator>()

bool vlink::Uint128::operator> ( const Uint128 & other) const
inlinenodiscardnoexcept

Returns true if *this is greater than other.

参数
otherRight-hand operand.
返回
true if *this > other.
函数调用图:

◆ operator>=()

bool vlink::Uint128::operator>= ( const Uint128 & other) const
inlinenodiscardnoexcept

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

参数
otherRight-hand operand.
返回
true if *this >= other.
函数调用图:

◆ operator>>()

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

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

  • Shift <= 0: returns *this unchanged.
  • Shift >= 128: returns zero.
  • Shift in [64, 127]: high bits are shifted into the low word.
参数
shiftNumber of bit positions to shift right.
返回
Shifted value.
函数调用图:

◆ operator>>=()

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

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

参数
shiftNumber of bit positions to shift right.
返回
Reference to *this.
函数调用图:

◆ operator^()

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

Returns the bitwise XOR of *this and other.

参数
otherRight-hand operand.
返回
New Uint128 with each bit set if it differs between operands.
函数调用图:

◆ operator^=()

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

Applies bitwise XOR with other in-place.

参数
otherRight-hand operand.
返回
Reference to *this.
函数调用图:

◆ operator|()

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

Returns the bitwise OR of *this and other.

参数
otherRight-hand operand.
返回
New Uint128 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-hand operand.
返回
Reference to *this.
函数调用图:

◆ operator~()

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

Returns the bitwise NOT (complement) of *this.

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

◆ operator<<

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

Writes the hexadecimal string representation of the value to os.

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

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