RPNX::DataStructures
Header-only C++ data structures and supporting utilities.
Loading...
Searching...
No Matches
rpnx::uint64_base< derived_t > Class Template Reference

CRTP base for strongly typed unsigned 64-bit integer wrappers. More...

#include <uint64_base.hpp>

Public Member Functions

 uint64_base (std::uint64_t val)
 Constructs from an unsigned 64-bit value.
 
 uint64_base (const derived_t &other)
 Copies a value from the derived wrapper type.
 
derived_t & operator= (const derived_t &other)
 Assigns a value from the derived wrapper type.
 
 operator std::uint64_t () const
 Converts to the underlying unsigned integer.
 
derived_t operator+ (const derived_t &other) const
 Adds two wrapped values.
 
derived_t operator- (const derived_t &other) const
 Subtracts two wrapped values.
 
derived_t operator* (const derived_t &other) const
 Multiplies two wrapped values.
 
derived_t operator/ (const derived_t &other) const
 Divides two wrapped values.
 
derived_t operator% (const derived_t &other) const
 Computes the remainder of two wrapped values.
 
derived_t & operator+= (const derived_t &other)
 Adds and assigns.
 
derived_t & operator-= (const derived_t &other)
 Subtracts and assigns.
 
derived_t & operator*= (const derived_t &other)
 Multiplies and assigns.
 
derived_t & operator/= (const derived_t &other)
 Divides and assigns.
 
derived_t & operator%= (const derived_t &other)
 Computes a remainder and assigns.
 
derived_t & operator++ ()
 Increments the stored value.
 
derived_t operator++ (int)
 Increments the stored value.
 
derived_t & operator-- ()
 Decrements the stored value.
 
derived_t operator-- (int)
 Decrements the stored value.
 
bool operator== (const derived_t &other) const
 Compares with a derived value for equality.
 
bool operator== (uint64_base< derived_t > const &other) const
 Compares with a base value for equality.
 
bool operator!= (const derived_t &other) const
 Compares with a derived value for inequality.
 
bool operator!= (uint64_base< derived_t > const &other) const
 Compares with a base value for inequality.
 
bool operator< (const derived_t &other) const
 Tests whether this value is less.
 
bool operator> (const derived_t &other) const
 Tests whether this value is greater.
 
bool operator<= (const derived_t &other) const
 Tests whether this value is less than or equal.
 
bool operator>= (const derived_t &other) const
 Tests whether this value is greater than or equal.
 
derived_t operator& (const derived_t &other) const
 Computes bitwise AND.
 
derived_t operator| (const derived_t &other) const
 Computes bitwise OR.
 
derived_t operator^ (const derived_t &other) const
 Computes bitwise exclusive OR.
 
derived_t operator~ () const
 Computes bitwise complement.
 
derived_t operator<< (int shift) const
 Shifts left.
 
derived_t operator>> (int shift) const
 Shifts right.
 
derived_t & operator&= (const derived_t &other)
 Computes bitwise AND and assigns.
 
derived_t & operator|= (const derived_t &other)
 Computes bitwise OR and assigns.
 
derived_t & operator^= (const derived_t &other)
 Computes bitwise exclusive OR and assigns.
 
derived_t & operator<<= (int shift)
 Shifts left and assigns.
 
derived_t & operator>>= (int shift)
 Shifts right and assigns.
 
std::uint64_t const & serialize_interface () const
 Exposes the stored integer to serialization code.
 
std::uint64_t & deserialize_interface ()
 Exposes the stored integer to deserialization code.
 
auto tie () const
 Returns the serialization fields as an immutable tuple.
 
auto tie ()
 Returns the serialization fields as a mutable tuple.
 

Static Public Member Functions

static auto constexpr strings ()
 Returns serialization field names in tuple order.
 

Detailed Description

template<typename derived_t>
class rpnx::uint64_base< derived_t >

CRTP base for strongly typed unsigned 64-bit integer wrappers.

Derived types inherit ordinary unsigned arithmetic, comparison, bitwise, and serialization operations while remaining distinct from one another. Arithmetic follows std::uint64_t modulo-2^64 semantics.

Template Parameters
derived_tComplete wrapper type derived from this specialization.

Constructor & Destructor Documentation

◆ uint64_base() [1/2]

template<typename derived_t>
rpnx::uint64_base< derived_t >::uint64_base ( std::uint64_t val)
inlineexplicit

Constructs from an unsigned 64-bit value.

Parameters
valInitial value.

◆ uint64_base() [2/2]

template<typename derived_t>
rpnx::uint64_base< derived_t >::uint64_base ( const derived_t & other)
inline

Copies a value from the derived wrapper type.

Parameters
otherValue to copy.

Member Function Documentation

◆ deserialize_interface()

template<typename derived_t>
std::uint64_t & rpnx::uint64_base< derived_t >::deserialize_interface ( )
inline

Exposes the stored integer to deserialization code.

Returns
Mutable reference to the stored value.

◆ operator std::uint64_t()

template<typename derived_t>
rpnx::uint64_base< derived_t >::operator std::uint64_t ( ) const
inline

Converts to the underlying unsigned integer.

Returns
Stored value.

◆ operator!=() [1/2]

template<typename derived_t>
bool rpnx::uint64_base< derived_t >::operator!= ( const derived_t & other) const
inline

Compares with a derived value for inequality.

Parameters
otherValue to compare.
Returns
Comparison result.

◆ operator!=() [2/2]

template<typename derived_t>
bool rpnx::uint64_base< derived_t >::operator!= ( uint64_base< derived_t > const & other) const
inline

Compares with a base value for inequality.

Parameters
otherValue to compare.
Returns
Comparison result.

◆ operator%()

template<typename derived_t>
derived_t rpnx::uint64_base< derived_t >::operator% ( const derived_t & other) const
inline

Computes the remainder of two wrapped values.

Parameters
otherDivisor.
Returns
Remainder.
Precondition
other is nonzero.

◆ operator%=()

template<typename derived_t>
derived_t & rpnx::uint64_base< derived_t >::operator%= ( const derived_t & other)
inline

Computes a remainder and assigns.

Parameters
otherNonzero divisor.
Returns
Reference to the derived object.

◆ operator&()

template<typename derived_t>
derived_t rpnx::uint64_base< derived_t >::operator& ( const derived_t & other) const
inline

Computes bitwise AND.

Parameters
otherRight operand.
Returns
Derived result.

◆ operator&=()

template<typename derived_t>
derived_t & rpnx::uint64_base< derived_t >::operator&= ( const derived_t & other)
inline

Computes bitwise AND and assigns.

Parameters
otherRight operand.
Returns
Reference to the derived object.

◆ operator*()

template<typename derived_t>
derived_t rpnx::uint64_base< derived_t >::operator* ( const derived_t & other) const
inline

Multiplies two wrapped values.

Parameters
otherRight operand.
Returns
Product modulo 2^64.

◆ operator*=()

template<typename derived_t>
derived_t & rpnx::uint64_base< derived_t >::operator*= ( const derived_t & other)
inline

Multiplies and assigns.

Parameters
otherRight operand.
Returns
Reference to the derived object.

◆ operator+()

template<typename derived_t>
derived_t rpnx::uint64_base< derived_t >::operator+ ( const derived_t & other) const
inline

Adds two wrapped values.

Parameters
otherRight operand.
Returns
Sum modulo 2^64.

◆ operator++() [1/2]

template<typename derived_t>
derived_t & rpnx::uint64_base< derived_t >::operator++ ( )
inline

Increments the stored value.

Returns
Reference to the derived object after incrementing.

◆ operator++() [2/2]

template<typename derived_t>
derived_t rpnx::uint64_base< derived_t >::operator++ ( int )
inline

Increments the stored value.

Returns
Derived value before incrementing.

◆ operator+=()

template<typename derived_t>
derived_t & rpnx::uint64_base< derived_t >::operator+= ( const derived_t & other)
inline

Adds and assigns.

Parameters
otherRight operand.
Returns
Reference to the derived object.

◆ operator-()

template<typename derived_t>
derived_t rpnx::uint64_base< derived_t >::operator- ( const derived_t & other) const
inline

Subtracts two wrapped values.

Parameters
otherRight operand.
Returns
Difference modulo 2^64.

◆ operator--() [1/2]

template<typename derived_t>
derived_t & rpnx::uint64_base< derived_t >::operator-- ( )
inline

Decrements the stored value.

Returns
Reference to the derived object after decrementing.

◆ operator--() [2/2]

template<typename derived_t>
derived_t rpnx::uint64_base< derived_t >::operator-- ( int )
inline

Decrements the stored value.

Returns
Derived value before decrementing.

◆ operator-=()

template<typename derived_t>
derived_t & rpnx::uint64_base< derived_t >::operator-= ( const derived_t & other)
inline

Subtracts and assigns.

Parameters
otherRight operand.
Returns
Reference to the derived object.

◆ operator/()

template<typename derived_t>
derived_t rpnx::uint64_base< derived_t >::operator/ ( const derived_t & other) const
inline

Divides two wrapped values.

Parameters
otherDivisor.
Returns
Integer quotient.
Precondition
other is nonzero.

◆ operator/=()

template<typename derived_t>
derived_t & rpnx::uint64_base< derived_t >::operator/= ( const derived_t & other)
inline

Divides and assigns.

Parameters
otherNonzero divisor.
Returns
Reference to the derived object.

◆ operator<()

template<typename derived_t>
bool rpnx::uint64_base< derived_t >::operator< ( const derived_t & other) const
inline

Tests whether this value is less.

Parameters
otherValue to compare.
Returns
Comparison result.

◆ operator<<()

template<typename derived_t>
derived_t rpnx::uint64_base< derived_t >::operator<< ( int shift) const
inline

Shifts left.

Parameters
shiftBit count in [0, 63].
Returns
Shifted derived result.

◆ operator<<=()

template<typename derived_t>
derived_t & rpnx::uint64_base< derived_t >::operator<<= ( int shift)
inline

Shifts left and assigns.

Parameters
shiftBit count in [0, 63].
Returns
Reference to the derived object.

◆ operator<=()

template<typename derived_t>
bool rpnx::uint64_base< derived_t >::operator<= ( const derived_t & other) const
inline

Tests whether this value is less than or equal.

Parameters
otherValue to compare.
Returns
Comparison result.

◆ operator=()

template<typename derived_t>
derived_t & rpnx::uint64_base< derived_t >::operator= ( const derived_t & other)
inline

Assigns a value from the derived wrapper type.

Parameters
otherValue to copy.
Returns
Reference to the derived object.

◆ operator==() [1/2]

template<typename derived_t>
bool rpnx::uint64_base< derived_t >::operator== ( const derived_t & other) const
inline

Compares with a derived value for equality.

Parameters
otherValue to compare.
Returns
Comparison result.

◆ operator==() [2/2]

template<typename derived_t>
bool rpnx::uint64_base< derived_t >::operator== ( uint64_base< derived_t > const & other) const
inline

Compares with a base value for equality.

Parameters
otherValue to compare.
Returns
Comparison result.

◆ operator>()

template<typename derived_t>
bool rpnx::uint64_base< derived_t >::operator> ( const derived_t & other) const
inline

Tests whether this value is greater.

Parameters
otherValue to compare.
Returns
Comparison result.

◆ operator>=()

template<typename derived_t>
bool rpnx::uint64_base< derived_t >::operator>= ( const derived_t & other) const
inline

Tests whether this value is greater than or equal.

Parameters
otherValue to compare.
Returns
Comparison result.

◆ operator>>()

template<typename derived_t>
derived_t rpnx::uint64_base< derived_t >::operator>> ( int shift) const
inline

Shifts right.

Parameters
shiftBit count in [0, 63].
Returns
Shifted derived result.

◆ operator>>=()

template<typename derived_t>
derived_t & rpnx::uint64_base< derived_t >::operator>>= ( int shift)
inline

Shifts right and assigns.

Parameters
shiftBit count in [0, 63].
Returns
Reference to the derived object.

◆ operator^()

template<typename derived_t>
derived_t rpnx::uint64_base< derived_t >::operator^ ( const derived_t & other) const
inline

Computes bitwise exclusive OR.

Parameters
otherRight operand.
Returns
Derived result.

◆ operator^=()

template<typename derived_t>
derived_t & rpnx::uint64_base< derived_t >::operator^= ( const derived_t & other)
inline

Computes bitwise exclusive OR and assigns.

Parameters
otherRight operand.
Returns
Reference to the derived object.

◆ operator|()

template<typename derived_t>
derived_t rpnx::uint64_base< derived_t >::operator| ( const derived_t & other) const
inline

Computes bitwise OR.

Parameters
otherRight operand.
Returns
Derived result.

◆ operator|=()

template<typename derived_t>
derived_t & rpnx::uint64_base< derived_t >::operator|= ( const derived_t & other)
inline

Computes bitwise OR and assigns.

Parameters
otherRight operand.
Returns
Reference to the derived object.

◆ operator~()

template<typename derived_t>
derived_t rpnx::uint64_base< derived_t >::operator~ ( ) const
inline

Computes bitwise complement.

Returns
Derived result.

◆ serialize_interface()

template<typename derived_t>
std::uint64_t const & rpnx::uint64_base< derived_t >::serialize_interface ( ) const
inline

Exposes the stored integer to serialization code.

Returns
Immutable reference to the stored value.

◆ strings()

template<typename derived_t>
static auto constexpr rpnx::uint64_base< derived_t >::strings ( )
inlinestaticconstexpr

Returns serialization field names in tuple order.

Returns
A single-element list containing "value".

◆ tie() [1/2]

template<typename derived_t>
auto rpnx::uint64_base< derived_t >::tie ( )
inline

Returns the serialization fields as a mutable tuple.

Returns
Tuple containing the stored integer.

◆ tie() [2/2]

template<typename derived_t>
auto rpnx::uint64_base< derived_t >::tie ( ) const
inline

Returns the serialization fields as an immutable tuple.

Returns
Tuple containing the stored integer.

The documentation for this class was generated from the following file: