diff --git a/ciphers/uint128_t.hpp b/ciphers/uint128_t.hpp index e6a0240bb..96d046e5f 100644 --- a/ciphers/uint128_t.hpp +++ b/ciphers/uint128_t.hpp @@ -177,11 +177,17 @@ class uint128_t { #endif } - inline uint32_t _len() { return _lez(); } - - // Casting operators - inline explicit operator bool() const { return f || s; } + /** + * @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); } + /** + * @brief casting operator to any integer valu + * @tparam T any integer type + * @returns integer value casted to mentioned type + */ template ::value, T>::type> inline explicit operator T() const { @@ -200,6 +206,12 @@ class uint128_t { */ 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 ::value, T>::type> inline uint128_t &operator=(const T &p) { @@ -207,13 +219,30 @@ class uint128_t { 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) { - __get_integer_from_string(p); + this->__get_integer_from_string(p); 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; /** diff --git a/ciphers/uint256_t.hpp b/ciphers/uint256_t.hpp index 82b18ae87..8f264d432 100644 --- a/ciphers/uint256_t.hpp +++ b/ciphers/uint256_t.hpp @@ -139,12 +139,16 @@ class uint256_t { 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; } /** - * @brief casting operator + * @brief casting operator to any integer value + * @tparam T any integer type + * @returns integer value casted to mentioned type */ template ::value, T>::type> @@ -152,6 +156,10 @@ class uint256_t { return static_cast(s); } + /** + * @brief casting operator to uint128_t + * @returns returns lower 128-bit integer part + */ inline explicit operator uint128_t() const { return s; } /** @@ -166,9 +174,19 @@ class uint256_t { */ 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; + /** + * @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 ::value, T>::type> inline uint256_t &operator=(const T &p) { @@ -176,11 +194,19 @@ class uint256_t { 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) { __get_integer_from_string(p); return *this; } + /** + * @brief Move assignment operator + */ inline uint256_t &operator=(uint256_t &&p) = default; /**