CppCommon  1.0.4.1
C++ Common Library
uint256.h
Go to the documentation of this file.
1 
9 #ifndef CPPCOMMON_UINT256_H
10 #define CPPCOMMON_UINT256_H
11 
12 #include "uint128.h"
13 
14 namespace CppCommon {
15 
17 
20 class uint256_t
21 {
22 public:
23  uint256_t() noexcept;
24  uint256_t(int8_t value) noexcept;
25  uint256_t(uint8_t value) noexcept;
26  uint256_t(int16_t value) noexcept;
27  uint256_t(uint16_t value) noexcept;
28  uint256_t(int32_t value) noexcept;
29  uint256_t(uint32_t value) noexcept;
30  uint256_t(int64_t value) noexcept;
31  uint256_t(uint64_t value) noexcept;
32  uint256_t(uint128_t value) noexcept;
33  template <typename T>
34  explicit uint256_t(const T& value) noexcept;
35  template <typename TUpper, typename TLower>
36  uint256_t(const TUpper& upper, const TLower& lower) noexcept;
37  template <typename TUpperUpper, typename TUpperLower, typename TLowerUpper, typename TLowerLower>
38  uint256_t(const TUpperUpper& upper_upper, const TUpperLower& upper_lower, const TLowerUpper& lower_upper, const TLowerLower& lower_lower) noexcept;
39  uint256_t(const uint256_t&) noexcept = default;
40  uint256_t(uint256_t&&) noexcept = default;
41  ~uint256_t() noexcept = default;
42 
43  template <typename T>
44  uint256_t& operator=(const T& value) noexcept;
45  uint256_t& operator=(const uint256_t&) noexcept = default;
46  uint256_t& operator=(uint256_t&&) noexcept = default;
47 
48  // Arithmetic operators
49  uint256_t operator+() const noexcept { return *this; }
50  uint256_t operator-() const noexcept { return ~*this + 1; }
51 
52  uint256_t& operator++() noexcept { return *this += 1; }
53  uint256_t operator++(int) noexcept { uint256_t temp(*this); ++*this; return temp; }
54  uint256_t& operator--() noexcept { return *this -= 1; }
55  uint256_t operator--(int) noexcept { uint256_t temp(*this); --*this; return temp; }
56 
57  uint256_t& operator+=(const uint256_t& value) noexcept { return *this = *this + value; }
58  uint256_t& operator-=(const uint256_t& value) noexcept { return *this = *this - value; }
59  uint256_t& operator*=(const uint256_t& value) noexcept { return *this = *this * value; }
60  uint256_t& operator/=(const uint256_t& value) { return *this = *this / value; }
61  uint256_t& operator%=(const uint256_t& value) { return *this = *this % value; }
62 
63  template <typename T>
64  uint256_t& operator+=(const T& value) noexcept { return *this = *this + uint256_t(value); }
65  template <typename T>
66  uint256_t& operator-=(const T& value) noexcept { return *this = *this - uint256_t(value); }
67  template <typename T>
68  uint256_t& operator*=(const T& value) noexcept { return *this = *this * uint256_t(value); }
69  template <typename T>
70  uint256_t& operator/=(const T& value) { return *this = *this / uint256_t(value); }
71  template <typename T>
72  uint256_t& operator%=(const T& value) { return *this = *this % uint256_t(value); }
73 
74  friend uint128_t& operator+=(uint128_t& value1, const uint256_t& value2) noexcept { return value1 = (uint256_t(value1) + value2).lower(); }
75  friend uint128_t& operator-=(uint128_t& value1, const uint256_t& value2) noexcept { return value1 = (uint256_t(value1) - value2).lower(); }
76  friend uint128_t& operator*=(uint128_t& value1, const uint256_t& value2) noexcept { return value1 = (uint256_t(value1) * value2).lower(); }
77  friend uint128_t& operator/=(uint128_t& value1, const uint256_t& value2) { return value1 = (uint256_t(value1) / value2).lower(); }
78  friend uint128_t& operator%=(uint128_t& value1, const uint256_t& value2) { return value1 = (uint256_t(value1) % value2).lower(); }
79 
80  template <typename T>
81  friend T& operator+=(T& value1, const uint256_t& value2) noexcept { return value1 = (T)(uint256_t(value1) + value2); }
82  template <typename T>
83  friend T& operator-=(T& value1, const uint256_t& value2) noexcept { return value1 = (T)(uint256_t(value1) - value2); }
84  template <typename T>
85  friend T& operator*=(T& value1, const uint256_t& value2) noexcept { return value1 = static_cast<T>(uint256_t(value1) * value2); }
86  template <typename T>
87  friend T& operator/=(T& value1, const uint256_t& value2) { return value1 = (T)(uint256_t(value1) / value2); }
88  template <typename T>
89  friend T& operator%=(T& value1, const uint256_t& value2) { return value1 = (T)(uint256_t(value1) % value2); }
90 
91  template <typename T>
92  friend uint256_t operator+(const T& value1, const uint256_t& value2) noexcept { return uint256_t(value1) + value2; }
93  template <typename T>
94  friend uint256_t operator+(const uint256_t& value1, const T& value2) noexcept { return value1 + uint256_t(value2); }
95  friend uint256_t operator+(const uint128_t& value1, const uint256_t& value2) noexcept { return uint256_t(value1) + value2; }
96  friend uint256_t operator+(const uint256_t& value1, const uint128_t& value2) noexcept { return value1 + uint256_t(value2); }
97  friend uint256_t operator+(const uint256_t& value1, const uint256_t& value2) noexcept;
98 
99  template <typename T>
100  friend uint256_t operator-(const T& value1, const uint256_t& value2) noexcept { return uint256_t(value1) - value2; }
101  template <typename T>
102  friend uint256_t operator-(const uint256_t& value1, const T& value2) noexcept { return value1 - uint256_t(value2); }
103  friend uint256_t operator-(const uint128_t& value1, const uint256_t& value2) noexcept { return uint256_t(value1) - value2; }
104  friend uint256_t operator-(const uint256_t& value1, const uint128_t& value2) noexcept { return value1 - uint256_t(value2); }
105  friend uint256_t operator-(const uint256_t& value1, const uint256_t& value2) noexcept;
106 
107  template <typename T>
108  friend uint256_t operator*(const T& value1, const uint256_t& value2) noexcept { return uint256_t(value1) * value2; }
109  template <typename T>
110  friend uint256_t operator*(const uint256_t& value1, const T& value2) noexcept { return value1 * uint256_t(value2); }
111  friend uint256_t operator*(const uint128_t& value1, const uint256_t& value2) noexcept { return uint256_t(value1) * value2; }
112  friend uint256_t operator*(const uint256_t& value1, const uint128_t& value2) noexcept { return value1 * uint256_t(value2); }
113  friend uint256_t operator*(const uint256_t& value1, const uint256_t& value2) noexcept;
114 
115  template <typename T>
116  friend uint256_t operator/(const T& value1, const uint256_t& value2) { return uint256_t(value1) / value2; }
117  template <typename T>
118  friend uint256_t operator/(const uint256_t& value1, const T& value2) { return value1 / uint256_t(value2); }
119  friend uint256_t operator/(const uint128_t& value1, const uint256_t& value2) { return uint256_t(value1) / value2; }
120  friend uint256_t operator/(const uint256_t& value1, const uint128_t& value2) { return value1 / uint256_t(value2); }
121  friend uint256_t operator/(const uint256_t& value1, const uint256_t& value2);
122 
123  template <typename T>
124  friend uint256_t operator%(const T& value1, const uint256_t& value2) { return uint256_t(value1) % value2; }
125  template <typename T>
126  friend uint256_t operator%(const uint256_t& value1, const T& value2) { return value1 % uint256_t(value2); }
127  friend uint256_t operator%(const uint128_t& value1, const uint256_t& value2) { return uint256_t(value1) % value2; }
128  friend uint256_t operator%(const uint256_t& value1, const uint128_t& value2) { return value1 % uint256_t(value2); }
129  friend uint256_t operator%(const uint256_t& value1, const uint256_t& value2);
130 
131  // Bit operators
132  uint256_t operator~() const noexcept { return uint256_t(~_upper, ~_lower); }
133 
134  uint256_t& operator&=(const uint256_t& value) noexcept { return *this = *this & value; }
135  uint256_t& operator|=(const uint256_t& value) noexcept { return *this = *this | value; }
136  uint256_t& operator^=(const uint256_t& value) noexcept { return *this = *this ^ value; }
137 
138  template <typename T>
139  uint256_t& operator&=(const T& value) noexcept { return *this = *this & uint256_t(value); }
140  template <typename T>
141  uint256_t& operator|=(const T& value) noexcept { return *this = *this | uint256_t(value); }
142  template <typename T>
143  uint256_t& operator^=(const T& value) noexcept { return *this = *this ^ uint256_t(value); }
144 
145  friend uint128_t& operator&=(uint128_t& value1, const uint256_t& value2) noexcept { return value1 = (uint256_t(value1) & value2).lower(); }
146  friend uint128_t& operator|=(uint128_t& value1, const uint256_t& value2) noexcept { return value1 = (uint256_t(value1) | value2).lower(); }
147  friend uint128_t& operator^=(uint128_t& value1, const uint256_t& value2) noexcept { return value1 = (uint256_t(value1) ^ value2).lower(); }
148 
149  template <typename T>
150  friend T& operator&=(T& value1, const uint256_t& value2) noexcept { return value1 = (T)(uint256_t(value1) & value2); }
151  template <typename T>
152  friend T& operator|=(T& value1, const uint256_t& value2) noexcept { return value1 = (T)(uint256_t(value1) | value2); }
153  template <typename T>
154  friend T& operator^=(T& value1, const uint256_t& value2) noexcept { return value1 = (T)(uint256_t(value1) ^ value2); }
155 
156  template <typename T>
157  friend uint256_t operator&(const T& value1, const uint256_t& value2) noexcept { return uint256_t(value1) & value2; }
158  template <typename T>
159  friend uint256_t operator&(const uint256_t& value1, const T& value2) noexcept { return value1 & uint256_t(value2); }
160  friend uint256_t operator&(const uint128_t& value1, const uint256_t& value2) noexcept { return uint256_t(value1) & value2; }
161  friend uint256_t operator&(const uint256_t& value1, const uint128_t& value2) noexcept { return value1 & uint256_t(value2); }
162  friend uint256_t operator&(const uint256_t& value1, const uint256_t& value2) noexcept;
163 
164  template <typename T>
165  friend uint256_t operator|(const T& value1, const uint256_t& value2) noexcept { return uint256_t(value1) | value2; }
166  template <typename T>
167  friend uint256_t operator|(const uint256_t& value1, const T& value2) noexcept { return value1 | uint256_t(value2); }
168  friend uint256_t operator|(const uint128_t& value1, const uint256_t& value2) noexcept { return uint256_t(value1) | value2; }
169  friend uint256_t operator|(const uint256_t& value1, const uint128_t& value2) noexcept { return value1 | uint256_t(value2); }
170  friend uint256_t operator|(const uint256_t& value1, const uint256_t& value2) noexcept;
171 
172  template <typename T>
173  friend uint256_t operator^(const T& value1, const uint256_t& value2) noexcept { return uint256_t(value1) ^ value2; }
174  template <typename T>
175  friend uint256_t operator^(const uint256_t& value1, const T& value2) noexcept { return value1 ^ uint256_t(value2); }
176  friend uint256_t operator^(const uint128_t& value1, const uint256_t& value2) noexcept { return uint256_t(value1) ^ value2; }
177  friend uint256_t operator^(const uint256_t& value1, const uint128_t& value2) noexcept { return value1 ^ uint256_t(value2); }
178  friend uint256_t operator^(const uint256_t& value1, const uint256_t& value2) noexcept;
179 
180  // Comparison operators
181  template <typename T>
182  friend bool operator==(const T& value1, const uint256_t& value2) noexcept { return uint256_t(value1) == value2; }
183  template <typename T>
184  friend bool operator==(const uint256_t& value1, const T& value2) noexcept { return value1 == uint256_t(value2); }
185  friend bool operator==(const uint128_t& value1, const uint256_t& value2) noexcept { return uint256_t(value1) == value2; }
186  friend bool operator==(const uint256_t& value1, const uint128_t& value2) noexcept { return value1 == uint256_t(value2); }
187  friend bool operator==(const uint256_t& value1, const uint256_t& value2) noexcept;
188 
189  template <typename T>
190  friend bool operator!=(const T& value1, const uint256_t& value2) noexcept { return uint256_t(value1) != value2; }
191  template <typename T>
192  friend bool operator!=(const uint256_t& value1, const T& value2) noexcept { return value1 != uint256_t(value2); }
193  friend bool operator!=(const uint128_t& value1, const uint256_t& value2) noexcept { return uint256_t(value1) != value2; }
194  friend bool operator!=(const uint256_t& value1, const uint128_t& value2) noexcept { return value1 != uint256_t(value2); }
195  friend bool operator!=(const uint256_t& value1, const uint256_t& value2) noexcept;
196 
197  template <typename T>
198  friend bool operator<(const T& value1, const uint256_t& value2) noexcept { return uint256_t(value1) < value2; }
199  template <typename T>
200  friend bool operator<(const uint256_t& value1, const T& value2) noexcept { return value1 < uint256_t(value2); }
201  friend bool operator<(const uint128_t& value1, const uint256_t& value2) noexcept { return uint256_t(value1) < value2; }
202  friend bool operator<(const uint256_t& value1, const uint128_t& value2) noexcept { return value1 < uint256_t(value2); }
203  friend bool operator<(const uint256_t& value1, const uint256_t& value2) noexcept;
204 
205  template <typename T>
206  friend bool operator>(const T& value1, const uint256_t& value2) noexcept { return uint256_t(value1) > value2; }
207  template <typename T>
208  friend bool operator>(const uint256_t& value1, const T& value2) noexcept { return value1 > uint256_t(value2); }
209  friend bool operator>(const uint128_t& value1, const uint256_t& value2) noexcept { return uint256_t(value1) > value2; }
210  friend bool operator>(const uint256_t& value1, const uint128_t& value2) noexcept { return value1 > uint256_t(value2); }
211  friend bool operator>(const uint256_t& value1, const uint256_t& value2) noexcept;
212 
213  template <typename T>
214  friend bool operator<=(const T& value1, const uint256_t& value2) noexcept { return uint256_t(value1) <= value2; }
215  template <typename T>
216  friend bool operator<=(const uint256_t& value1, const T& value2) noexcept { return value1 <= uint256_t(value2); }
217  friend bool operator<=(const uint128_t& value1, const uint256_t& value2) noexcept { return uint256_t(value1) <= value2; }
218  friend bool operator<=(const uint256_t& value1, const uint128_t& value2) noexcept { return value1 <= uint256_t(value2); }
219  friend bool operator<=(const uint256_t& value1, const uint256_t& value2) noexcept;
220 
221  template <typename T>
222  friend bool operator>=(const T& value1, const uint256_t& value2) noexcept { return uint256_t(value1) >= value2; }
223  template <typename T>
224  friend bool operator>=(const uint256_t& value1, const T& value2) noexcept { return value1 >= uint256_t(value2); }
225  friend bool operator>=(const uint128_t& value1, const uint256_t& value2) noexcept { return uint256_t(value1) >= value2; }
226  friend bool operator>=(const uint256_t& value1, const uint128_t& value2) noexcept { return value1 >= uint256_t(value2); }
227  friend bool operator>=(const uint256_t& value1, const uint256_t& value2) noexcept;
228 
229  // Logical operators
230  bool operator!() const noexcept { return !(bool)(_upper | _lower); }
231 
232  template <typename T>
233  friend bool operator&&(const T& value1, const uint256_t& value2) noexcept { return uint256_t(value1) && value2; }
234  template <typename T>
235  friend bool operator&&(const uint256_t& value1, const T& value2) noexcept { return value1 && uint256_t(value2); }
236  friend bool operator&&(const uint128_t& value1, const uint256_t& value2) noexcept { return uint256_t(value1) && value2; }
237  friend bool operator&&(const uint256_t& value1, const uint128_t& value2) noexcept { return value1 && uint256_t(value2); }
238  friend bool operator&&(const uint256_t& value1, const uint256_t& value2) noexcept;
239 
240  template <typename T>
241  friend bool operator||(const T& value1, const uint256_t& value2) noexcept { return uint256_t(value1) || value2; }
242  template <typename T>
243  friend bool operator||(const uint256_t& value1, const T& value2) noexcept { return value1 || uint256_t(value2); }
244  friend bool operator||(const uint128_t& value1, const uint256_t& value2) noexcept { return uint256_t(value1) || value2; }
245  friend bool operator||(const uint256_t& value1, const uint128_t& value2) noexcept { return value1 || uint256_t(value2); }
246  friend bool operator||(const uint256_t& value1, const uint256_t& value2) noexcept;
247 
248  // Shift operators
249  uint256_t& operator<<=(const uint256_t& value) noexcept { return *this = *this << value; }
250  uint256_t& operator>>=(const uint256_t& value) noexcept { return *this = *this >> value; }
251 
252  template <typename T>
253  uint256_t& operator<<=(const T& value) noexcept { return *this = *this << uint256_t(value); }
254  template <typename T>
255  friend T& operator<<=(T& value1, const uint256_t& value2) noexcept { return value1 = (T)(uint256_t(value1) << value2); }
256 
257  friend uint128_t& operator<<=(uint128_t& value1, const uint256_t& value2) noexcept { return value1 = (uint256_t(value1) << value2).lower(); }
258  friend uint128_t& operator>>=(uint128_t& value1, const uint256_t& value2) noexcept { return value1 = (uint256_t(value1) >> value2).lower(); }
259 
260  template <typename T>
261  uint256_t& operator>>=(const T& value) noexcept { return *this = *this >> uint256_t(value); }
262  template <typename T>
263  friend T& operator>>=(T& value1, const uint256_t& value2) noexcept { return value1 = (T)(uint256_t(value1) >> value2); }
264 
265  template <typename T>
266  friend uint256_t operator<<(const uint256_t& value1, const T& value2) noexcept { return value1 << uint256_t(value2); }
267  friend uint256_t operator<<(bool value1, const uint256_t& value2) noexcept { return uint256_t(value1) << value2; }
268  friend uint256_t operator<<(int8_t value1, const uint256_t& value2) noexcept { return uint256_t(value1) << value2; }
269  friend uint256_t operator<<(int16_t value1, const uint256_t& value2) noexcept { return uint256_t(value1) << value2; }
270  friend uint256_t operator<<(int32_t value1, const uint256_t& value2) noexcept { return uint256_t(value1) << value2; }
271  friend uint256_t operator<<(int64_t value1, const uint256_t& value2) noexcept { return uint256_t(value1) << value2; }
272  friend uint256_t operator<<(uint8_t value1, const uint256_t& value2) noexcept { return uint256_t(value1) << value2; }
273  friend uint256_t operator<<(uint16_t value1, const uint256_t& value2) noexcept { return uint256_t(value1) << value2; }
274  friend uint256_t operator<<(uint32_t value1, const uint256_t& value2) noexcept { return uint256_t(value1) << value2; }
275  friend uint256_t operator<<(uint64_t value1, const uint256_t& value2) noexcept { return uint256_t(value1) << value2; }
276  friend uint256_t operator<<(const uint128_t& value1, const uint256_t& value2) noexcept { return uint256_t(value1) << value2; }
277  friend uint256_t operator<<(const uint256_t& value1, const uint256_t& value2) noexcept;
278 
279  template <typename T>
280  friend uint256_t operator>>(const uint256_t& value1, const T& value2) noexcept { return value1 >> uint256_t(value2); }
281  friend uint256_t operator>>(bool value1, const uint256_t& value2) noexcept { return uint256_t(value1) >> value2; }
282  friend uint256_t operator>>(int8_t value1, const uint256_t& value2) noexcept { return uint256_t(value1) >> value2; }
283  friend uint256_t operator>>(int16_t value1, const uint256_t& value2) noexcept { return uint256_t(value1) >> value2; }
284  friend uint256_t operator>>(int32_t value1, const uint256_t& value2) noexcept { return uint256_t(value1) >> value2; }
285  friend uint256_t operator>>(int64_t value1, const uint256_t& value2) noexcept { return uint256_t(value1) >> value2; }
286  friend uint256_t operator>>(uint8_t value1, const uint256_t& value2) noexcept { return uint256_t(value1) >> value2; }
287  friend uint256_t operator>>(uint16_t value1, const uint256_t& value2) noexcept { return uint256_t(value1) >> value2; }
288  friend uint256_t operator>>(uint32_t value1, const uint256_t& value2) noexcept { return uint256_t(value1) >> value2; }
289  friend uint256_t operator>>(uint64_t value1, const uint256_t& value2) noexcept { return uint256_t(value1) >> value2; }
290  friend uint256_t operator>>(const uint128_t& value1, const uint256_t& value2) noexcept { return uint256_t(value1) >> value2; }
291  friend uint256_t operator>>(const uint256_t& value1, const uint256_t& value2) noexcept;
292 
293  // Type cast
294  operator bool() const noexcept { return (bool)(_upper | _lower); }
295  operator uint8_t() const noexcept { return (uint8_t)_lower; }
296  operator uint16_t() const noexcept { return (uint16_t)_lower; }
297  operator uint32_t() const noexcept { return (uint32_t)_lower; }
298  operator uint64_t() const noexcept { return (uint64_t)_lower; }
299  operator uint128_t() const noexcept { return _lower; }
300 
302  uint128_t upper() const noexcept { return _upper; }
304  uint128_t lower() const noexcept { return _lower; }
305 
307  size_t bits() const noexcept;
308 
310 
315  std::string string(size_t base = 10, size_t length = 0) const;
317 
322  std::wstring wstring(size_t base = 10, size_t length = 0) const;
323 
325 
330  static std::pair<uint256_t, uint256_t> divmod(const uint256_t& x, const uint256_t& y);
331 
333  friend std::istream& operator>>(std::istream& is, uint256_t& value)
334  { is >> value._upper >> value._lower; return is; }
336  friend std::wistream& operator>>(std::wistream& is, uint256_t& value)
337  { is >> value._upper >> value._lower; return is; }
339  friend std::ostream& operator<<(std::ostream& os, const uint256_t& value);
341  friend std::wostream& operator<<(std::wostream& os, const uint256_t& value);
342 
344  void swap(uint256_t& value) noexcept;
345  friend void swap(uint256_t& value1, uint256_t& value2) noexcept;
346 
347 private:
348  uint128_t _upper;
349  uint128_t _lower;
350 };
351 
354 } // namespace CppCommon
355 
356 #include "uint256.inl"
357 
358 #endif // CPPCOMMON_UINT256_H
Unsigned 128-bit integer type.
Definition: uint128.h:28
Unsigned 256-bit integer type.
Definition: uint256.h:21
friend uint256_t operator<<(uint64_t value1, const uint256_t &value2) noexcept
Definition: uint256.h:275
friend uint256_t operator^(const uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:176
friend bool operator!=(const uint256_t &value1, const uint128_t &value2) noexcept
Definition: uint256.h:194
friend uint256_t operator*(const uint256_t &value1, const uint128_t &value2) noexcept
Definition: uint256.h:112
friend bool operator==(const uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:185
friend uint256_t operator+(const uint256_t &value1, const T &value2) noexcept
Definition: uint256.h:94
uint256_t & operator+=(const T &value) noexcept
Definition: uint256.h:64
friend uint256_t operator>>(int8_t value1, const uint256_t &value2) noexcept
Definition: uint256.h:282
friend uint128_t & operator|=(uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:146
uint256_t(uint256_t &&) noexcept=default
size_t bits() const noexcept
Get the count of bits.
Definition: uint256.cpp:83
friend uint256_t operator<<(int16_t value1, const uint256_t &value2) noexcept
Definition: uint256.h:269
friend uint256_t operator<<(bool value1, const uint256_t &value2) noexcept
Definition: uint256.h:267
friend uint256_t operator>>(int32_t value1, const uint256_t &value2) noexcept
Definition: uint256.h:284
uint256_t(const uint256_t &) noexcept=default
uint256_t & operator*=(const uint256_t &value) noexcept
Definition: uint256.h:59
friend bool operator&&(const uint256_t &value1, const T &value2) noexcept
Definition: uint256.h:235
friend uint256_t operator^(const uint256_t &value1, const uint128_t &value2) noexcept
Definition: uint256.h:177
friend T & operator+=(T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:81
friend uint256_t operator-(const uint256_t &value1, const uint128_t &value2) noexcept
Definition: uint256.h:104
friend uint256_t operator<<(int64_t value1, const uint256_t &value2) noexcept
Definition: uint256.h:271
friend bool operator&&(const uint256_t &value1, const uint128_t &value2) noexcept
Definition: uint256.h:237
friend uint256_t operator>>(uint64_t value1, const uint256_t &value2) noexcept
Definition: uint256.h:289
friend uint256_t operator<<(int8_t value1, const uint256_t &value2) noexcept
Definition: uint256.h:268
friend bool operator&&(const T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:233
uint256_t & operator^=(const T &value) noexcept
Definition: uint256.h:143
friend uint256_t operator>>(const uint256_t &value1, const T &value2) noexcept
Definition: uint256.h:280
friend uint128_t & operator>>=(uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:258
friend uint256_t operator-(const T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:100
friend uint256_t operator<<(const uint256_t &value1, const T &value2) noexcept
Definition: uint256.h:266
friend uint128_t & operator/=(uint128_t &value1, const uint256_t &value2)
Definition: uint256.h:77
uint256_t & operator>>=(const T &value) noexcept
Definition: uint256.h:261
friend uint256_t operator*(const T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:108
friend uint256_t operator<<(uint32_t value1, const uint256_t &value2) noexcept
Definition: uint256.h:274
friend bool operator>(const uint256_t &value1, const T &value2) noexcept
Definition: uint256.h:208
friend uint256_t operator-(const uint256_t &value1, const T &value2) noexcept
Definition: uint256.h:102
uint256_t & operator*=(const T &value) noexcept
Definition: uint256.h:68
uint256_t & operator<<=(const uint256_t &value) noexcept
Definition: uint256.h:249
friend T & operator/=(T &value1, const uint256_t &value2)
Definition: uint256.h:87
uint256_t & operator|=(const T &value) noexcept
Definition: uint256.h:141
uint256_t operator-() const noexcept
Definition: uint256.h:50
friend uint256_t operator+(const uint256_t &value1, const uint128_t &value2) noexcept
Definition: uint256.h:96
friend uint256_t operator%(const T &value1, const uint256_t &value2)
Definition: uint256.h:124
uint256_t operator--(int) noexcept
Definition: uint256.h:55
friend bool operator>(const T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:206
friend bool operator>=(const uint256_t &value1, const uint128_t &value2) noexcept
Definition: uint256.h:226
friend bool operator&&(const uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:236
friend uint256_t operator/(const uint256_t &value1, const T &value2)
Definition: uint256.h:118
friend bool operator<(const uint256_t &value1, const T &value2) noexcept
Definition: uint256.h:200
friend T & operator&=(T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:150
friend uint256_t operator|(const uint256_t &value1, const T &value2) noexcept
Definition: uint256.h:167
uint256_t & operator/=(const T &value)
Definition: uint256.h:70
friend bool operator>(const uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:209
friend T & operator|=(T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:152
friend bool operator||(const uint256_t &value1, const uint128_t &value2) noexcept
Definition: uint256.h:245
uint256_t & operator--() noexcept
Definition: uint256.h:54
friend bool operator<=(const T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:214
uint256_t operator+() const noexcept
Definition: uint256.h:49
friend uint256_t operator*(const uint256_t &value1, const T &value2) noexcept
Definition: uint256.h:110
friend uint256_t operator^(const uint256_t &value1, const T &value2) noexcept
Definition: uint256.h:175
friend uint256_t operator+(const T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:92
uint256_t & operator/=(const uint256_t &value)
Definition: uint256.h:60
friend bool operator>(const uint256_t &value1, const uint128_t &value2) noexcept
Definition: uint256.h:210
friend uint256_t operator>>(int64_t value1, const uint256_t &value2) noexcept
Definition: uint256.h:285
friend uint256_t operator|(const T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:165
friend uint256_t operator%(const uint256_t &value1, const uint128_t &value2)
Definition: uint256.h:128
friend bool operator==(const T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:182
uint128_t lower() const noexcept
Get the lower part of the 256-bit integer.
Definition: uint256.h:304
uint128_t upper() const noexcept
Get the upper part of the 256-bit integer.
Definition: uint256.h:302
uint256_t & operator^=(const uint256_t &value) noexcept
Definition: uint256.h:136
friend bool operator<(const T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:198
friend bool operator<=(const uint256_t &value1, const uint128_t &value2) noexcept
Definition: uint256.h:218
friend uint256_t operator+(const uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:95
std::wstring wstring(size_t base=10, size_t length=0) const
Get wide string from the current 128-bit integer.
Definition: uint256.cpp:135
friend T & operator*=(T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:85
friend bool operator!=(const T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:190
uint256_t & operator-=(const T &value) noexcept
Definition: uint256.h:66
friend T & operator^=(T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:154
uint256_t & operator%=(const uint256_t &value)
Definition: uint256.h:61
friend uint256_t operator>>(uint32_t value1, const uint256_t &value2) noexcept
Definition: uint256.h:288
friend uint256_t operator<<(const uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:276
friend uint256_t operator&(const T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:157
friend uint128_t & operator+=(uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:74
uint256_t & operator>>=(const uint256_t &value) noexcept
Definition: uint256.h:250
friend uint256_t operator>>(const uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:290
friend uint256_t operator|(const uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:168
friend T & operator%=(T &value1, const uint256_t &value2)
Definition: uint256.h:89
friend uint256_t operator%(const uint128_t &value1, const uint256_t &value2)
Definition: uint256.h:127
friend uint256_t operator<<(uint8_t value1, const uint256_t &value2) noexcept
Definition: uint256.h:272
friend uint256_t operator<<(uint16_t value1, const uint256_t &value2) noexcept
Definition: uint256.h:273
friend std::wistream & operator>>(std::wistream &is, uint256_t &value)
Input instance from the given wide input stream.
Definition: uint256.h:336
friend bool operator!=(const uint256_t &value1, const T &value2) noexcept
Definition: uint256.h:192
friend bool operator<(const uint256_t &value1, const uint128_t &value2) noexcept
Definition: uint256.h:202
friend bool operator<=(const uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:217
friend uint256_t operator/(const T &value1, const uint256_t &value2)
Definition: uint256.h:116
uint256_t & operator|=(const uint256_t &value) noexcept
Definition: uint256.h:135
friend uint256_t operator|(const uint256_t &value1, const uint128_t &value2) noexcept
Definition: uint256.h:169
uint256_t & operator<<=(const T &value) noexcept
Definition: uint256.h:253
friend uint256_t operator-(const uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:103
friend uint128_t & operator<<=(uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:257
static std::pair< uint256_t, uint256_t > divmod(const uint256_t &x, const uint256_t &y)
Calculate quotient and remainder when dividing X by Y.
Definition: uint256.cpp:160
friend bool operator==(const uint256_t &value1, const T &value2) noexcept
Definition: uint256.h:184
friend T & operator<<=(T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:255
friend uint256_t operator&(const uint256_t &value1, const uint128_t &value2) noexcept
Definition: uint256.h:161
friend uint256_t operator<<(int32_t value1, const uint256_t &value2) noexcept
Definition: uint256.h:270
friend bool operator>=(const uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:225
friend uint256_t operator&(const uint256_t &value1, const T &value2) noexcept
Definition: uint256.h:159
friend bool operator||(const uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:244
uint256_t & operator%=(const T &value)
Definition: uint256.h:72
friend bool operator==(const uint256_t &value1, const uint128_t &value2) noexcept
Definition: uint256.h:186
friend bool operator>=(const uint256_t &value1, const T &value2) noexcept
Definition: uint256.h:224
friend uint256_t operator>>(int16_t value1, const uint256_t &value2) noexcept
Definition: uint256.h:283
friend T & operator-=(T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:83
uint256_t() noexcept
Definition: uint256.inl:11
friend uint128_t & operator-=(uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:75
friend uint256_t operator/(const uint128_t &value1, const uint256_t &value2)
Definition: uint256.h:119
friend bool operator||(const uint256_t &value1, const T &value2) noexcept
Definition: uint256.h:243
uint256_t operator++(int) noexcept
Definition: uint256.h:53
friend bool operator||(const T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:241
uint256_t & operator++() noexcept
Definition: uint256.h:52
friend bool operator<(const uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:201
friend uint128_t & operator&=(uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:145
friend uint256_t operator*(const uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:111
friend bool operator>=(const T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:222
uint256_t & operator+=(const uint256_t &value) noexcept
Definition: uint256.h:57
friend T & operator>>=(T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:263
uint256_t & operator&=(const T &value) noexcept
Definition: uint256.h:139
friend uint256_t operator>>(uint16_t value1, const uint256_t &value2) noexcept
Definition: uint256.h:287
void swap(uint256_t &value) noexcept
Swap two instances.
Definition: uint256.inl:189
friend uint128_t & operator*=(uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:76
uint256_t operator~() const noexcept
Definition: uint256.h:132
friend uint256_t operator^(const T &value1, const uint256_t &value2) noexcept
Definition: uint256.h:173
friend uint256_t operator%(const uint256_t &value1, const T &value2)
Definition: uint256.h:126
uint256_t & operator&=(const uint256_t &value) noexcept
Definition: uint256.h:134
friend uint256_t operator&(const uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:160
friend bool operator!=(const uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:193
friend uint256_t operator>>(bool value1, const uint256_t &value2) noexcept
Definition: uint256.h:281
friend uint128_t & operator%=(uint128_t &value1, const uint256_t &value2)
Definition: uint256.h:78
friend uint256_t operator>>(uint8_t value1, const uint256_t &value2) noexcept
Definition: uint256.h:286
uint256_t & operator-=(const uint256_t &value) noexcept
Definition: uint256.h:58
friend uint256_t operator/(const uint256_t &value1, const uint128_t &value2)
Definition: uint256.h:120
friend bool operator<=(const uint256_t &value1, const T &value2) noexcept
Definition: uint256.h:216
friend uint128_t & operator^=(uint128_t &value1, const uint256_t &value2) noexcept
Definition: uint256.h:147
bool operator!() const noexcept
Definition: uint256.h:230
C++ Common project definitions.
Definition: token_bucket.h:15
Unsigned 128-bit integer type definition.
Unsigned 256-bit integer type inline implementation.