3#ifndef RPNX_DATASTRUCTURES_RPNX_UINT64_BASE_HPP
4#define RPNX_DATASTRUCTURES_RPNX_UINT64_BASE_HPP
19 template <
typename derived_t >
27 uint64_base() : value_(0)
46 value_ = other.value_;
48 return static_cast< derived_t&
>(*this);
52 operator std::uint64_t()
const
60 return derived_t(value_ + other.value_);
66 return derived_t(value_ - other.value_);
72 return derived_t(value_ * other.value_);
79 return derived_t(value_ / other.value_);
85 return derived_t(value_ % other.value_);
91 value_ += other.value_;
92 return static_cast< derived_t&
>(*this);
98 value_ -= other.value_;
99 return static_cast< derived_t&
>(*this);
105 value_ *= other.value_;
106 return static_cast< derived_t&
>(*this);
112 value_ /= other.value_;
113 return static_cast< derived_t&
>(*this);
119 value_ %= other.value_;
120 return static_cast< derived_t&
>(*this);
127 return static_cast< derived_t&
>(*this);
133 derived_t temp =
static_cast< derived_t&
>(*this);
142 return static_cast< derived_t&
>(*this);
148 derived_t temp =
static_cast< derived_t&
>(*this);
156 return value_ == other.value_;
162 return value_ == other.value_;
168 return value_ != other.value_;
174 return value_ != other.value_;
180 return value_ < other.value_;
186 return value_ > other.value_;
192 return value_ <= other.value_;
198 return value_ >= other.value_;
204 return derived_t(value_ & other.value_);
210 return derived_t(value_ | other.value_);
216 return derived_t(value_ ^ other.value_);
222 return derived_t(~value_);
228 return derived_t(value_ << shift);
234 return derived_t(value_ >> shift);
240 value_ &= other.value_;
241 return static_cast< derived_t&
>(*this);
247 value_ |= other.value_;
248 return static_cast< derived_t&
>(*this);
254 value_ ^= other.value_;
255 return static_cast< derived_t&
>(*this);
262 return static_cast< derived_t&
>(*this);
269 return static_cast< derived_t&
>(*this);
287 return std::tie(value_);
292 return std::tie(value_);
298 return std::vector< std::string >{
"value" };
313#define RPNX_UNIQUE_U64(name) \
314 struct name : public rpnx::uint64_base< name > \
316 using rpnx::uint64_base< name >::uint64_base; \
317 static constexpr auto class_name() { return #name; } \
318 using rpnx::uint64_base< name >::operator=; \
320 using rpnx::uint64_base< name >::operator==; \
321 using rpnx::uint64_base< name >::operator!=; \
322 using rpnx::uint64_base< name >::operator<; \
323 using rpnx::uint64_base< name >::operator>; \
324 using rpnx::uint64_base< name >::operator<=; \
325 using rpnx::uint64_base< name >::operator>=; \
derived_t & operator>>=(int shift)
Shifts right and assigns.
Definition uint64_base.hpp:266
auto tie() const
Returns the serialization fields as an immutable tuple.
Definition uint64_base.hpp:285
derived_t & operator/=(const derived_t &other)
Divides and assigns.
Definition uint64_base.hpp:110
derived_t & operator=(const derived_t &other)
Assigns a value from the derived wrapper type.
Definition uint64_base.hpp:42
derived_t operator/(const derived_t &other) const
Divides two wrapped values.
Definition uint64_base.hpp:76
derived_t operator-(const derived_t &other) const
Subtracts two wrapped values.
Definition uint64_base.hpp:64
bool operator!=(const derived_t &other) const
Compares with a derived value for inequality.
Definition uint64_base.hpp:166
derived_t & operator|=(const derived_t &other)
Computes bitwise OR and assigns.
Definition uint64_base.hpp:245
bool operator!=(uint64_base< derived_t > const &other) const
Compares with a base value for inequality.
Definition uint64_base.hpp:172
bool operator==(const derived_t &other) const
Compares with a derived value for equality.
Definition uint64_base.hpp:154
derived_t operator*(const derived_t &other) const
Multiplies two wrapped values.
Definition uint64_base.hpp:70
derived_t operator++(int)
Increments the stored value.
Definition uint64_base.hpp:131
uint64_base(const derived_t &other)
Copies a value from the derived wrapper type.
Definition uint64_base.hpp:37
derived_t operator--(int)
Decrements the stored value.
Definition uint64_base.hpp:146
static auto constexpr strings()
Returns serialization field names in tuple order.
Definition uint64_base.hpp:296
derived_t & operator--()
Decrements the stored value.
Definition uint64_base.hpp:139
derived_t operator&(const derived_t &other) const
Computes bitwise AND.
Definition uint64_base.hpp:202
derived_t operator^(const derived_t &other) const
Computes bitwise exclusive OR.
Definition uint64_base.hpp:214
derived_t operator~() const
Computes bitwise complement.
Definition uint64_base.hpp:220
uint64_base(std::uint64_t val)
Constructs from an unsigned 64-bit value.
Definition uint64_base.hpp:32
bool operator==(uint64_base< derived_t > const &other) const
Compares with a base value for equality.
Definition uint64_base.hpp:160
std::uint64_t & deserialize_interface()
Exposes the stored integer to deserialization code.
Definition uint64_base.hpp:279
derived_t & operator*=(const derived_t &other)
Multiplies and assigns.
Definition uint64_base.hpp:103
std::uint64_t const & serialize_interface() const
Exposes the stored integer to serialization code.
Definition uint64_base.hpp:273
bool operator>=(const derived_t &other) const
Tests whether this value is greater than or equal.
Definition uint64_base.hpp:196
bool operator>(const derived_t &other) const
Tests whether this value is greater.
Definition uint64_base.hpp:184
derived_t & operator-=(const derived_t &other)
Subtracts and assigns.
Definition uint64_base.hpp:96
bool operator<=(const derived_t &other) const
Tests whether this value is less than or equal.
Definition uint64_base.hpp:190
derived_t operator<<(int shift) const
Shifts left.
Definition uint64_base.hpp:226
derived_t operator|(const derived_t &other) const
Computes bitwise OR.
Definition uint64_base.hpp:208
derived_t operator>>(int shift) const
Shifts right.
Definition uint64_base.hpp:232
derived_t & operator%=(const derived_t &other)
Computes a remainder and assigns.
Definition uint64_base.hpp:117
derived_t & operator&=(const derived_t &other)
Computes bitwise AND and assigns.
Definition uint64_base.hpp:238
derived_t & operator+=(const derived_t &other)
Adds and assigns.
Definition uint64_base.hpp:89
derived_t & operator^=(const derived_t &other)
Computes bitwise exclusive OR and assigns.
Definition uint64_base.hpp:252
bool operator<(const derived_t &other) const
Tests whether this value is less.
Definition uint64_base.hpp:178
derived_t & operator++()
Increments the stored value.
Definition uint64_base.hpp:124
derived_t operator%(const derived_t &other) const
Computes the remainder of two wrapped values.
Definition uint64_base.hpp:83
auto tie()
Returns the serialization fields as a mutable tuple.
Definition uint64_base.hpp:290
derived_t & operator<<=(int shift)
Shifts left and assigns.
Definition uint64_base.hpp:259
derived_t operator+(const derived_t &other) const
Adds two wrapped values.
Definition uint64_base.hpp:58
Containers, iterator adapters, callable wrappers, and value utilities.
Definition annex.hpp:14