mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-05-05 20:48:22 +08:00
Additional comments
This commit is contained in:
@@ -177,11 +177,17 @@ class uint128_t {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint32_t _len() { return _lez(); }
|
/**
|
||||||
|
* @brief casting operator to boolean value
|
||||||
// Casting operators
|
* @returns true if value of this is non-zero, else false
|
||||||
inline explicit operator bool() const { return f || s; }
|
*/
|
||||||
|
inline explicit operator bool() const { return (f || s); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief casting operator to any integer valu
|
||||||
|
* @tparam T any integer type
|
||||||
|
* @returns integer value casted to mentioned type
|
||||||
|
*/
|
||||||
template <typename T, typename = typename std::enable_if<
|
template <typename T, typename = typename std::enable_if<
|
||||||
std::is_integral<T>::value, T>::type>
|
std::is_integral<T>::value, T>::type>
|
||||||
inline explicit operator T() const {
|
inline explicit operator T() const {
|
||||||
@@ -200,6 +206,12 @@ class uint128_t {
|
|||||||
*/
|
*/
|
||||||
inline uint64_t upper() const { return f; }
|
inline uint64_t upper() const { return f; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief operator = for other types
|
||||||
|
* @tparam T denoting any integer type
|
||||||
|
* @param p an integer to assign it's value
|
||||||
|
* @returns this pointer with it's value equal to `p`
|
||||||
|
*/
|
||||||
template <typename T, typename = typename std::enable_if<
|
template <typename T, typename = typename std::enable_if<
|
||||||
std::is_integral<T>::value, T>::type>
|
std::is_integral<T>::value, T>::type>
|
||||||
inline uint128_t &operator=(const T &p) {
|
inline uint128_t &operator=(const T &p) {
|
||||||
@@ -207,13 +219,30 @@ class uint128_t {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief operator = for type string
|
||||||
|
* @param p a string to assign it's value to equivalent integer
|
||||||
|
* @returns this pointer with it's value equal to `p`
|
||||||
|
*/
|
||||||
inline uint128_t &operator=(const std::string &p) {
|
inline uint128_t &operator=(const std::string &p) {
|
||||||
__get_integer_from_string(p);
|
this->__get_integer_from_string(p);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint128_t &operator=(const uint128_t &p) = default;
|
/**
|
||||||
|
* @brief operator = for uint128_t
|
||||||
|
* @param p an 128-bit integer to assign it's value
|
||||||
|
* @returns this pointer with it's value equal to `p`
|
||||||
|
*/
|
||||||
|
inline uint128_t &operator=(const uint128_t &p) {
|
||||||
|
f = p.f;
|
||||||
|
s = p.s;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Move assignment operator
|
||||||
|
*/
|
||||||
inline uint128_t &operator=(uint128_t &&p) = default;
|
inline uint128_t &operator=(uint128_t &&p) = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -139,12 +139,16 @@ class uint256_t {
|
|||||||
return 128 + f._trz();
|
return 128 + f._trz();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint32_t _len() { return _lez(); }
|
/**
|
||||||
|
* @brief casting operator to boolean value
|
||||||
|
* @returns true if value of this is non-zero, else false
|
||||||
|
*/
|
||||||
inline explicit operator bool() const { return f || s; }
|
inline explicit operator bool() const { return f || s; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief casting operator
|
* @brief casting operator to any integer value
|
||||||
|
* @tparam T any integer type
|
||||||
|
* @returns integer value casted to mentioned type
|
||||||
*/
|
*/
|
||||||
template <typename T, typename = typename std::enable_if<
|
template <typename T, typename = typename std::enable_if<
|
||||||
std::is_integral<T>::value, T>::type>
|
std::is_integral<T>::value, T>::type>
|
||||||
@@ -152,6 +156,10 @@ class uint256_t {
|
|||||||
return static_cast<T>(s);
|
return static_cast<T>(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief casting operator to uint128_t
|
||||||
|
* @returns returns lower 128-bit integer part
|
||||||
|
*/
|
||||||
inline explicit operator uint128_t() const { return s; }
|
inline explicit operator uint128_t() const { return s; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -166,9 +174,19 @@ class uint256_t {
|
|||||||
*/
|
*/
|
||||||
inline uint128_t upper() const { return f; }
|
inline uint128_t upper() const { return f; }
|
||||||
|
|
||||||
// Assign
|
/**
|
||||||
|
* @brief operator = for uint256_t
|
||||||
|
* @param p an 256-bit integer to assign it's value
|
||||||
|
* @returns this pointer with it's value equal to `p`
|
||||||
|
*/
|
||||||
inline uint256_t &operator=(const uint256_t &p) = default;
|
inline uint256_t &operator=(const uint256_t &p) = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief operator = for other types
|
||||||
|
* @tparam T denoting any integer type
|
||||||
|
* @param p an integer to assign it's value
|
||||||
|
* @returns this pointer with it's value equal to `p`
|
||||||
|
*/
|
||||||
template <typename T, typename = typename std::enable_if<
|
template <typename T, typename = typename std::enable_if<
|
||||||
std::is_integral<T>::value, T>::type>
|
std::is_integral<T>::value, T>::type>
|
||||||
inline uint256_t &operator=(const T &p) {
|
inline uint256_t &operator=(const T &p) {
|
||||||
@@ -176,11 +194,19 @@ class uint256_t {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief operator = for type string
|
||||||
|
* @param p a string to assign it's value to equivalent integer
|
||||||
|
* @returns this pointer with it's value equal to `p`
|
||||||
|
*/
|
||||||
inline uint256_t &operator=(const std::string &p) {
|
inline uint256_t &operator=(const std::string &p) {
|
||||||
__get_integer_from_string(p);
|
__get_integer_from_string(p);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Move assignment operator
|
||||||
|
*/
|
||||||
inline uint256_t &operator=(uint256_t &&p) = default;
|
inline uint256_t &operator=(uint256_t &&p) = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user