Skip to content

Commit f7daaa1

Browse files
committed
Additional comments
1 parent 265a865 commit f7daaa1

File tree

2 files changed

+65
-10
lines changed

2 files changed

+65
-10
lines changed

ciphers/uint128_t.hpp

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,17 @@ class uint128_t {
177177
#endif
178178
}
179179

180-
inline uint32_t _len() { return _lez(); }
181-
182-
// Casting operators
183-
inline explicit operator bool() const { return f || s; }
180+
/**
181+
* @brief casting operator to boolean value
182+
* @returns true if value of this is non-zero, else false
183+
*/
184+
inline explicit operator bool() const { return (f || s); }
184185

186+
/**
187+
* @brief casting operator to any integer valu
188+
* @tparam T any integer type
189+
* @returns integer value casted to mentioned type
190+
*/
185191
template <typename T, typename = typename std::enable_if<
186192
std::is_integral<T>::value, T>::type>
187193
inline explicit operator T() const {
@@ -200,20 +206,43 @@ class uint128_t {
200206
*/
201207
inline uint64_t upper() const { return f; }
202208

209+
/**
210+
* @brief operator = for other types
211+
* @tparam T denoting any integer type
212+
* @param p an integer to assign it's value
213+
* @returns this pointer with it's value equal to `p`
214+
*/
203215
template <typename T, typename = typename std::enable_if<
204216
std::is_integral<T>::value, T>::type>
205217
inline uint128_t &operator=(const T &p) {
206218
this->s = p;
207219
return *this;
208220
}
209221

222+
/**
223+
* @brief operator = for type string
224+
* @param p a string to assign it's value to equivalent integer
225+
* @returns this pointer with it's value equal to `p`
226+
*/
210227
inline uint128_t &operator=(const std::string &p) {
211-
__get_integer_from_string(p);
228+
this->__get_integer_from_string(p);
212229
return *this;
213230
}
214231

215-
inline uint128_t &operator=(const uint128_t &p) = default;
232+
/**
233+
* @brief operator = for uint128_t
234+
* @param p an 128-bit integer to assign it's value
235+
* @returns this pointer with it's value equal to `p`
236+
*/
237+
inline uint128_t &operator=(const uint128_t &p) {
238+
f = p.f;
239+
s = p.s;
240+
return *this;
241+
}
216242

243+
/**
244+
* @brief Move assignment operator
245+
*/
217246
inline uint128_t &operator=(uint128_t &&p) = default;
218247

219248
/**

ciphers/uint256_t.hpp

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,27 @@ class uint256_t {
139139
return 128 + f._trz();
140140
}
141141

142-
inline uint32_t _len() { return _lez(); }
143-
142+
/**
143+
* @brief casting operator to boolean value
144+
* @returns true if value of this is non-zero, else false
145+
*/
144146
inline explicit operator bool() const { return f || s; }
145147

146148
/**
147-
* @brief casting operator
149+
* @brief casting operator to any integer value
150+
* @tparam T any integer type
151+
* @returns integer value casted to mentioned type
148152
*/
149153
template <typename T, typename = typename std::enable_if<
150154
std::is_integral<T>::value, T>::type>
151155
inline explicit operator T() const {
152156
return static_cast<T>(s);
153157
}
154158

159+
/**
160+
* @brief casting operator to uint128_t
161+
* @returns returns lower 128-bit integer part
162+
*/
155163
inline explicit operator uint128_t() const { return s; }
156164

157165
/**
@@ -166,21 +174,39 @@ class uint256_t {
166174
*/
167175
inline uint128_t upper() const { return f; }
168176

169-
// Assign
177+
/**
178+
* @brief operator = for uint256_t
179+
* @param p an 256-bit integer to assign it's value
180+
* @returns this pointer with it's value equal to `p`
181+
*/
170182
inline uint256_t &operator=(const uint256_t &p) = default;
171183

184+
/**
185+
* @brief operator = for other types
186+
* @tparam T denoting any integer type
187+
* @param p an integer to assign it's value
188+
* @returns this pointer with it's value equal to `p`
189+
*/
172190
template <typename T, typename = typename std::enable_if<
173191
std::is_integral<T>::value, T>::type>
174192
inline uint256_t &operator=(const T &p) {
175193
this->s = p;
176194
return *this;
177195
}
178196

197+
/**
198+
* @brief operator = for type string
199+
* @param p a string to assign it's value to equivalent integer
200+
* @returns this pointer with it's value equal to `p`
201+
*/
179202
inline uint256_t &operator=(const std::string &p) {
180203
__get_integer_from_string(p);
181204
return *this;
182205
}
183206

207+
/**
208+
* @brief Move assignment operator
209+
*/
184210
inline uint256_t &operator=(uint256_t &&p) = default;
185211

186212
/**

0 commit comments

Comments
 (0)