5 static_assert(
sizeof(
int) * 8 == 32,
"Make sure the logic here remains correct");
7 template<
class T,
class X =
void>
11 template<
class T,
class X =
void>
17 template<
class Self,
class Other>
19 template<
class Self,
class Other>
22 template<
class Self,
class Other>
27 inline static SelfMaxBit cast_for_32_op(
const Self&
self) {
33 friend SelfMaxBit
operator+(
const Other& lhs,
const Self& rhs) {
return lhs + cast_for_32_op(rhs); }
34 friend SelfMaxBit
operator+(
const Self& lhs,
const Other& rhs) {
return cast_for_32_op(lhs) + rhs; }
36 friend SelfMaxBit
operator-(
const Other& lhs,
const Self& rhs) {
return lhs - cast_for_32_op(rhs); }
37 friend SelfMaxBit
operator-(
const Self& lhs,
const Other& rhs) {
return cast_for_32_op(lhs) - rhs; }
39 friend SelfMaxBit
operator*(
const Other& lhs,
const Self& rhs) {
return lhs * cast_for_32_op(rhs); }
40 friend SelfMaxBit
operator*(
const Self& lhs,
const Other& rhs) {
return cast_for_32_op(lhs) * rhs; }
42 friend SelfMaxBit
operator/(
const Other& lhs,
const Self& rhs) {
return lhs / cast_for_32_op(rhs); }
43 friend SelfMaxBit
operator/(
const Self& lhs,
const Other& rhs) {
return cast_for_32_op(lhs) / rhs; }
45 friend SelfMaxBit
operator%(
const Other& lhs,
const Self& rhs) {
return lhs % cast_for_32_op(rhs); }
46 friend SelfMaxBit
operator%(
const Self& lhs,
const Other& rhs) {
return cast_for_32_op(lhs) % rhs; }
48 friend SelfMaxBit operator&(
const Other& lhs,
const Self& rhs) {
return lhs & cast_for_32_op(rhs); }
49 friend SelfMaxBit operator&(
const Self& lhs,
const Other& rhs) {
return cast_for_32_op(lhs) & rhs; }
51 friend SelfMaxBit
operator|(
const Other& lhs,
const Self& rhs) {
return lhs | cast_for_32_op(rhs); }
52 friend SelfMaxBit
operator|(
const Self& lhs,
const Other& rhs) {
return cast_for_32_op(lhs) | rhs; }
54 friend SelfMaxBit
operator^(
const Other& lhs,
const Self& rhs) {
return lhs ^ cast_for_32_op(rhs); }
55 friend SelfMaxBit
operator^(
const Self& lhs,
const Other& rhs) {
return cast_for_32_op(lhs) ^ rhs; }
57 friend SelfMaxBit
operator<<(
const Other& lhs,
const Self& rhs) {
return lhs << cast_for_32_op(rhs); }
58 friend SelfMaxBit
operator<<(
const Self& lhs,
const Other& rhs) {
return cast_for_32_op(lhs) << rhs; }
60 friend SelfMaxBit
operator>>(
const Other& lhs,
const Self& rhs) {
return lhs >> cast_for_32_op(rhs); }
61 friend SelfMaxBit
operator>>(
const Self& lhs,
const Other& rhs) {
return cast_for_32_op(lhs) >> rhs; }
63 friend bool operator==(
const Other& lhs,
const Self& rhs) {
return lhs == cast_for_32_op(rhs); }
64 friend bool operator==(
const Self& lhs,
const Other& rhs) {
return cast_for_32_op(lhs) == rhs; }
66 friend bool operator!=(
const Other& lhs,
const Self& rhs) {
return lhs != cast_for_32_op(rhs); }
67 friend bool operator!=(
const Self& lhs,
const Other& rhs) {
return cast_for_32_op(lhs) != rhs; }
69 friend bool operator>(
const Other& lhs,
const Self& rhs) {
return lhs > cast_for_32_op(rhs); }
70 friend bool operator>(
const Self& lhs,
const Other& rhs) {
return cast_for_32_op(lhs) > rhs; }
72 friend bool operator<(
const Other& lhs,
const Self& rhs) {
return lhs < cast_for_32_op(rhs); }
73 friend bool operator<(
const Self& lhs,
const Other& rhs) {
return cast_for_32_op(lhs) < rhs; }
75 friend bool operator>=(
const Other& lhs,
const Self& rhs) {
return lhs >= cast_for_32_op(rhs); }
76 friend bool operator>=(
const Self& lhs,
const Other& rhs) {
return cast_for_32_op(lhs) >= rhs; }
78 friend bool operator<=(
const Other& lhs,
const Self& rhs) {
return lhs <= cast_for_32_op(rhs); }
79 friend bool operator<=(
const Self& lhs,
const Other& rhs) {
return cast_for_32_op(lhs) <= rhs; }
82 template<
class Self,
class Other>
87 inline static Other cast_for_64_op(
const Self&
self) {
93 friend Other
operator+(
const Other& lhs,
const Self& rhs) {
return lhs + cast_for_64_op(rhs); }
94 friend Other
operator+(
const Self& lhs,
const Other& rhs) {
return cast_for_64_op(lhs) + rhs; }
96 friend Other
operator-(
const Other& lhs,
const Self& rhs) {
return lhs - cast_for_64_op(rhs); }
97 friend Other
operator-(
const Self& lhs,
const Other& rhs) {
return cast_for_64_op(lhs) - rhs; }
99 friend Other
operator*(
const Other& lhs,
const Self& rhs) {
return lhs * cast_for_64_op(rhs); }
100 friend Other
operator*(
const Self& lhs,
const Other& rhs) {
return cast_for_64_op(lhs) * rhs; }
102 friend Other
operator/(
const Other& lhs,
const Self& rhs) {
return lhs / cast_for_64_op(rhs); }
103 friend Other
operator/(
const Self& lhs,
const Other& rhs) {
return cast_for_64_op(lhs) / rhs; }
105 friend Other
operator%(
const Other& lhs,
const Self& rhs) {
return lhs % cast_for_64_op(rhs); }
106 friend Other
operator%(
const Self& lhs,
const Other& rhs) {
return cast_for_64_op(lhs) % rhs; }
108 friend Other operator&(
const Other& lhs,
const Self& rhs) {
return lhs & cast_for_64_op(rhs); }
109 friend Other operator&(
const Self& lhs,
const Other& rhs) {
return cast_for_64_op(lhs) & rhs; }
111 friend Other
operator|(
const Other& lhs,
const Self& rhs) {
return lhs | cast_for_64_op(rhs); }
112 friend Other
operator|(
const Self& lhs,
const Other& rhs) {
return cast_for_64_op(lhs) | rhs; }
114 friend Other
operator^(
const Other& lhs,
const Self& rhs) {
return lhs ^ cast_for_64_op(rhs); }
115 friend Other
operator^(
const Self& lhs,
const Other& rhs) {
return cast_for_64_op(lhs) ^ rhs; }
117 friend Other
operator<<(
const Other& lhs,
const Self& rhs) {
return lhs << cast_for_64_op(rhs); }
118 friend Other
operator<<(
const Self& lhs,
const Other& rhs) {
return cast_for_64_op(lhs) << rhs; }
120 friend Other
operator>>(
const Other& lhs,
const Self& rhs) {
return lhs >> cast_for_64_op(rhs); }
121 friend Other
operator>>(
const Self& lhs,
const Other& rhs) {
return cast_for_64_op(lhs) >> rhs; }
123 friend bool operator==(
const Other& lhs,
const Self& rhs) {
return lhs == cast_for_64_op(rhs); }
124 friend bool operator==(
const Self& lhs,
const Other& rhs) {
return cast_for_64_op(lhs) == rhs; }
126 friend bool operator!=(
const Other& lhs,
const Self& rhs) {
return lhs != cast_for_64_op(rhs); }
127 friend bool operator!=(
const Self& lhs,
const Other& rhs) {
return cast_for_64_op(lhs) != rhs; }
129 friend bool operator>(
const Other& lhs,
const Self& rhs) {
return lhs > cast_for_64_op(rhs); }
130 friend bool operator>(
const Self& lhs,
const Other& rhs) {
return cast_for_64_op(lhs) > rhs; }
132 friend bool operator<(
const Other& lhs,
const Self& rhs) {
return lhs < cast_for_64_op(rhs); }
133 friend bool operator<(
const Self& lhs,
const Other& rhs) {
return cast_for_64_op(lhs) < rhs; }
135 friend bool operator>=(
const Other& lhs,
const Self& rhs) {
return lhs >= cast_for_64_op(rhs); }
136 friend bool operator>=(
const Self& lhs,
const Other& rhs) {
return cast_for_64_op(lhs) >= rhs; }
138 friend bool operator<=(
const Other& lhs,
const Self& rhs) {
return lhs <= cast_for_64_op(rhs); }
139 friend bool operator<=(
const Self& lhs,
const Other& rhs) {
return cast_for_64_op(lhs) <= rhs; }
147 inline static SelfMaxBit cast_for_self_op(
const Self&
self) {
153 friend SelfMaxBit
operator+(
const Self& lhs,
const Self& rhs) {
return cast_for_self_op(lhs) + cast_for_self_op(rhs); }
154 friend SelfMaxBit
operator-(
const Self& lhs,
const Self& rhs) {
return cast_for_self_op(lhs) - cast_for_self_op(rhs); }
155 friend SelfMaxBit
operator*(
const Self& lhs,
const Self& rhs) {
return cast_for_self_op(lhs) * cast_for_self_op(rhs); }
156 friend SelfMaxBit
operator/(
const Self& lhs,
const Self& rhs) {
return cast_for_self_op(lhs) / cast_for_self_op(rhs); }
157 friend SelfMaxBit
operator%(
const Self& lhs,
const Self& rhs) {
return cast_for_self_op(lhs) % cast_for_self_op(rhs); }
158 friend SelfMaxBit operator&(
const Self& lhs,
const Self& rhs) {
return cast_for_self_op(lhs) & cast_for_self_op(rhs); }
159 friend SelfMaxBit
operator|(
const Self& lhs,
const Self& rhs) {
return cast_for_self_op(lhs) | cast_for_self_op(rhs); }
160 friend SelfMaxBit
operator^(
const Self& lhs,
const Self& rhs) {
return cast_for_self_op(lhs) ^ cast_for_self_op(rhs); }
161 friend SelfMaxBit
operator~(
const Self&
self) {
return ~(cast_for_self_op(
self)); }
162 friend SelfMaxBit
operator<<(
const Self& lhs,
const Self& rhs) {
return cast_for_self_op(lhs) << cast_for_self_op(rhs); }
163 friend SelfMaxBit
operator>>(
const Self& lhs,
const Self& rhs) {
return cast_for_self_op(lhs) >> cast_for_self_op(rhs); }
164 friend bool operator==(
const Self& lhs,
const Self& rhs) {
return cast_for_self_op(lhs) == cast_for_self_op(rhs); }
165 friend bool operator!=(
const Self& lhs,
const Self& rhs) {
return cast_for_self_op(lhs) != cast_for_self_op(rhs); }
166 friend bool operator>(
const Self& lhs,
const Self& rhs) {
return cast_for_self_op(lhs) > cast_for_self_op(rhs); }
167 friend bool operator<(
const Self& lhs,
const Self& rhs) {
return cast_for_self_op(lhs) < cast_for_self_op(rhs); }
168 friend bool operator>=(
const Self& lhs,
const Self& rhs) {
return cast_for_self_op(lhs) >= cast_for_self_op(rhs); }
169 friend bool operator<=(
const Self& lhs,
const Self& rhs) {
return cast_for_self_op(lhs) <= cast_for_self_op(rhs); }
172 template<
typename...>
175 template<
typename T,
typename... Ts>
199 template<
class Self,
class Other>
202 inline static void assign(Self&
self, uint32_t v) {
206 inline static void assign(Self&
self, uint64_t v) {
210 Self&
operator+=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self + v);
return self; }
211 Self&
operator-=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self - v);
return self; }
212 Self&
operator*=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self * v);
return self; }
213 Self&
operator/=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self / v);
return self; }
214 Self&
operator%=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self % v);
return self; }
215 Self& operator&=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self & v);
return self; }
216 Self&
operator|=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self | v);
return self; }
217 Self&
operator^=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self ^ v);
return self; }
218 Self&
operator>>=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self >> v);
return self; }
219 Self&
operator<<=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self << v);
return self; }
222 template<
class Self,
class Other>
225 inline static void assign(Self&
self, uint32_t v) {
229 inline static void assign(Self&
self, uint64_t v) {
233 Self&
operator+=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self + v);
return self; }
234 Self&
operator-=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self - v);
return self; }
235 Self&
operator*=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self * v);
return self; }
236 Self&
operator/=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self / v);
return self; }
237 Self&
operator%=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self % v);
return self; }
238 Self& operator&=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self & v);
return self; }
239 Self&
operator|=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self | v);
return self; }
240 Self&
operator^=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self ^ v);
return self; }
241 Self&
operator>>=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self >> v);
return self; }
242 Self&
operator<<=(
const Other& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self << v);
return self; }
249 inline static SelfMaxBit cast_for_self_op(
const Self&
self) {
253 inline static void assign(Self&
self, uint32_t v) {
257 inline static void assign(Self&
self, uint64_t v) {
261 Self&
operator+=(
const Self& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self + v);
return self; }
262 Self&
operator-=(
const Self& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self - v);
return self; }
263 Self&
operator*=(
const Self& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self * v);
return self; }
264 Self&
operator/=(
const Self& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self / v);
return self; }
265 Self&
operator%=(
const Self& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self % v);
return self; }
267 Self&
operator++() {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self + 1u);
return self; }
268 Self&
operator--() {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self - 1u);
return self; }
269 SelfMaxBit
operator++(
int) {
auto&
self =
static_cast<Self&
>(*this);
auto tmp = cast_for_self_op(
self); assign(
self,
self + 1u);
return tmp; }
270 SelfMaxBit
operator--(
int) {
auto&
self =
static_cast<Self&
>(*this);
auto tmp = cast_for_self_op(
self); assign(
self,
self - 1u);
return tmp; }
272 Self& operator&=(
const Self& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self & v);
return self; }
273 Self&
operator|=(
const Self& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self | v);
return self; }
274 Self&
operator^=(
const Self& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self ^ v);
return self; }
275 Self&
operator>>=(
const Self& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self >> v);
return self; }
276 Self&
operator<<=(
const Self& v) {
auto&
self =
static_cast<Self&
>(*this); assign(
self,
self << v);
return self; }
285 template<
typename...>
288 template<
typename T,
typename... Ts>
291 using T::operator +=;
292 using T::operator -=;
293 using T::operator *=;
294 using T::operator /=;
295 using T::operator %=;
296 using T::operator &=;
297 using T::operator |=;
298 using T::operator ^=;
299 using T::operator >>=;
300 using T::operator <<=;
317 using T::operator +=;
318 using T::operator -=;
319 using T::operator *=;
320 using T::operator /=;
321 using T::operator %=;
322 using T::operator &=;
323 using T::operator |=;
324 using T::operator ^=;
325 using T::operator >>=;
326 using T::operator <<=;
friend bool operator<=(const Self &lhs, const Other &rhs)
Self & operator^=(const Other &v)
friend SelfMaxBit operator<<(const Other &lhs, const Self &rhs)
Contains the text compression and encoding framework.
Self & operator<<=(const Other &v)
friend bool operator!=(const Other &lhs, const Self &rhs)
friend bool operator>(const Self &lhs, const Other &rhs)
Self & operator*=(const Self &v)
friend bool operator<(const Other &lhs, const Self &rhs)
Self & operator+=(const Other &v)
friend SelfMaxBit operator%(const Self &lhs, const Self &rhs)
friend Other operator%(const Self &lhs, const Other &rhs)
friend Other operator-(const Self &lhs, const Other &rhs)
friend SelfMaxBit operator/(const Self &lhs, const Other &rhs)
friend SelfMaxBit operator^(const Self &lhs, const Self &rhs)
friend bool operator>(const Other &lhs, const Self &rhs)
friend Other operator+(const Self &lhs, const Other &rhs)
friend bool operator==(const Self &lhs, const Self &rhs)
friend SelfMaxBit operator+(const Self &lhs, const Self &rhs)
friend SelfMaxBit operator^(const Other &lhs, const Self &rhs)
friend bool operator>=(const Other &lhs, const Self &rhs)
friend SelfMaxBit operator>>(const Other &lhs, const Self &rhs)
Self & operator/=(const Other &v)
friend bool operator==(const Self &lhs, const Other &rhs)
friend bool operator<(const Self &lhs, const Other &rhs)
Self & operator-=(const Other &v)
friend bool operator<=(const Self &lhs, const Other &rhs)
friend bool operator!=(const Other &lhs, const Self &rhs)
friend SelfMaxBit operator*(const Other &lhs, const Self &rhs)
friend Other operator/(const Self &lhs, const Other &rhs)
friend SelfMaxBit operator|(const Self &lhs, const Self &rhs)
friend bool operator<(const Other &lhs, const Self &rhs)
friend bool operator<=(const Other &lhs, const Self &rhs)
friend Other operator|(const Self &lhs, const Other &rhs)
friend SelfMaxBit operator^(const Self &lhs, const Other &rhs)
friend Other operator^(const Self &lhs, const Other &rhs)
Self & operator^=(const Other &v)
Self & operator<<=(const Self &v)
Self & operator<<=(const Other &v)
friend bool operator>=(const Self &lhs, const Other &rhs)
Self & operator+=(const Other &v)
friend SelfMaxBit operator*(const Self &lhs, const Self &rhs)
friend SelfMaxBit operator-(const Self &lhs, const Self &rhs)
Self & operator%=(const Other &v)
friend bool operator==(const Self &lhs, const Other &rhs)
friend bool operator!=(const Self &lhs, const Self &rhs)
ConstIntegerBaseTrait< Self >::Dispatch::SelfMaxBit SelfMaxBit
ConstIntegerBaseTrait< Self >::Dispatch::SelfMaxBit SelfMaxBit
friend Other operator>>(const Other &lhs, const Self &rhs)
friend Other operator<<(const Self &lhs, const Other &rhs)
friend bool operator<=(const Other &lhs, const Self &rhs)
friend SelfMaxBit operator/(const Self &lhs, const Self &rhs)
friend Other operator<<(const Other &lhs, const Self &rhs)
friend Other operator>>(const Self &lhs, const Other &rhs)
friend SelfMaxBit operator>>(const Self &lhs, const Self &rhs)
Self & operator-=(const Other &v)
friend bool operator<(const Self &lhs, const Self &rhs)
friend Other operator*(const Self &lhs, const Other &rhs)
friend SelfMaxBit operator|(const Other &lhs, const Self &rhs)
friend SelfMaxBit operator+(const Other &lhs, const Self &rhs)
friend Other operator^(const Other &lhs, const Self &rhs)
Self & operator|=(const Other &v)
Self & operator^=(const Self &v)
Self & operator-=(const Self &v)
friend bool operator>=(const Other &lhs, const Self &rhs)
friend bool operator>=(const Self &lhs, const Self &rhs)
friend SelfMaxBit operator~(const Self &self)
Self & operator>>=(const Other &v)
friend Other operator+(const Other &lhs, const Self &rhs)
friend SelfMaxBit operator-(const Other &lhs, const Self &rhs)
friend Other operator|(const Other &lhs, const Self &rhs)
friend bool operator!=(const Self &lhs, const Other &rhs)
friend Other operator-(const Other &lhs, const Self &rhs)
SelfMaxBit operator++(int)
friend bool operator==(const Other &lhs, const Self &rhs)
Self & operator/=(const Other &v)
friend bool operator<=(const Self &lhs, const Self &rhs)
friend bool operator>(const Self &lhs, const Self &rhs)
friend Other operator/(const Other &lhs, const Self &rhs)
Self & operator+=(const Self &v)
Self & operator|=(const Other &v)
Self & operator/=(const Self &v)
ConstIntegerBaseTrait< Self >::Dispatch::SelfMaxBit SelfMaxBit
friend SelfMaxBit operator+(const Self &lhs, const Other &rhs)
friend SelfMaxBit operator<<(const Self &lhs, const Other &rhs)
friend SelfMaxBit operator|(const Self &lhs, const Other &rhs)
Self & operator*=(const Other &v)
friend bool operator>(const Self &lhs, const Other &rhs)
friend Other operator%(const Other &lhs, const Self &rhs)
friend SelfMaxBit operator<<(const Self &lhs, const Self &rhs)
friend SelfMaxBit operator>>(const Self &lhs, const Other &rhs)
friend bool operator!=(const Self &lhs, const Other &rhs)
friend bool operator>(const Other &lhs, const Self &rhs)
friend Other operator*(const Other &lhs, const Self &rhs)
SelfMaxBit operator--(int)
Self & operator%=(const Self &v)
friend SelfMaxBit operator%(const Other &lhs, const Self &rhs)
friend bool operator>=(const Self &lhs, const Other &rhs)
friend SelfMaxBit operator*(const Self &lhs, const Other &rhs)
friend SelfMaxBit operator/(const Other &lhs, const Self &rhs)
friend SelfMaxBit operator-(const Self &lhs, const Other &rhs)
Self & operator%=(const Other &v)
Self & operator>>=(const Other &v)
friend bool operator==(const Other &lhs, const Self &rhs)
Self & operator|=(const Self &v)
friend bool operator<(const Self &lhs, const Other &rhs)
friend SelfMaxBit operator%(const Self &lhs, const Other &rhs)
Self & operator*=(const Other &v)
Self & operator>>=(const Self &v)