#include <OpaqueInteger.h>
Public Member Functions | |
OpaqueInteger () | |
OpaqueInteger (T t) | |
int | operator== (OpaqueInteger< T, Dummy > other) const |
int | operator!= (OpaqueInteger< T, Dummy > other) const |
int | operator< (OpaqueInteger< T, Dummy > other) const |
int | operator> (OpaqueInteger< T, Dummy > other) const |
int | operator<= (OpaqueInteger< T, Dummy > other) const |
int | operator>= (OpaqueInteger< T, Dummy > other) const |
OpaqueInteger< T, Dummy > | operator++ () |
OpaqueInteger< T, Dummy > | operator++ (int) |
OpaqueInteger< T, Dummy > | operator-- () |
OpaqueInteger< T, Dummy > | operator-- (int) |
OpaqueInteger< T, Dummy > | operator *= (OpaqueInteger< T, Dummy > i) |
OpaqueInteger< T, Dummy > | operator/= (OpaqueInteger< T, Dummy > i) |
OpaqueInteger< T, Dummy > | operator+= (OpaqueInteger< T, Dummy > i) |
OpaqueInteger< T, Dummy > | operator-= (OpaqueInteger< T, Dummy > i) |
OpaqueInteger< T, Dummy > | operator%= (OpaqueInteger< T, Dummy > i) |
OpaqueInteger< T, Dummy > | operator *= (T t) |
OpaqueInteger< T, Dummy > | operator/= (T t) |
OpaqueInteger< T, Dummy > | operator+= (T t) |
OpaqueInteger< T, Dummy > | operator-= (T t) |
OpaqueInteger< T, Dummy > | operator%= (T t) |
OpaqueInteger< T, Dummy > | operator>>= (int i) |
OpaqueInteger< T, Dummy > | operator<<= (int i) |
OpaqueInteger< T, Dummy > | operator>> (int i) const |
OpaqueInteger< T, Dummy > | operator<< (int i) const |
OpaqueInteger< T, Dummy > | operator% (T i) const |
OpaqueInteger< T, Dummy > | operator/ (T i) const |
OpaqueInteger< T, Dummy > | operator * (T i) const |
OpaqueInteger< T, Dummy > | operator+ (T t) const |
OpaqueInteger< T, Dummy > | operator- (T t) const |
OpaqueInteger< T, Dummy > | operator% (OpaqueInteger< T, Dummy > i) const |
OpaqueInteger< T, Dummy > | operator/ (OpaqueInteger< T, Dummy > i) const |
OpaqueInteger< T, Dummy > | operator * (OpaqueInteger< T, Dummy > i) const |
OpaqueInteger< T, Dummy > | operator+ (OpaqueInteger< T, Dummy > i) const |
OpaqueInteger< T, Dummy > | operator- (OpaqueInteger< T, Dummy > i) const |
T | getWrapped () const |
Protected Attributes | |
T | val |
It is not meant to be used directly; instead, use the macros at the end of this file. If an operation you need isn't here all ready, please add it. However, do NOT add an automatic cast operator or implicit constructor. The point of this class is to help prevent implicit conversions between values with different semantics. For example:
DEFINE_OPAQUE_INTEGER(Apple,uint);
DEFINE_OPAQUE_INTEGER(Orange,uint);
Apple apple_jack,apple_seed(20);
Orange oj;
apple_jack = apple_seed+2; // legal
oj = apple_jack; // won't compile, can't compare apples&oranges
Note that in a non-debug build, the macro expands to a simple typedef, so there is no performance penalty for using it. However, this also means that you have to be careful with overloading to avoid release-build breakage.
// TODO: extend the mechanism to be able to handle inheritance (e.g. BTreeId isa PageOwnerId).
Definition at line 63 of file OpaqueInteger.h.
OpaqueInteger< T, Dummy >::OpaqueInteger | ( | ) | [inline] |
Definition at line 68 of file OpaqueInteger.h.
00069 { 00070 // NOTE: the default constructor should NOT 00071 // initialize to 0, because this doesn't match the non-DEBUG 00072 // behavior, AND actually breaks some code (scary but true) 00073 }
OpaqueInteger< T, Dummy >::OpaqueInteger | ( | T | t | ) | [inline, explicit] |
Definition at line 75 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00076 { 00077 val = t; 00078 }
int OpaqueInteger< T, Dummy >::operator== | ( | OpaqueInteger< T, Dummy > | other | ) | const [inline] |
int OpaqueInteger< T, Dummy >::operator!= | ( | OpaqueInteger< T, Dummy > | other | ) | const [inline] |
int OpaqueInteger< T, Dummy >::operator< | ( | OpaqueInteger< T, Dummy > | other | ) | const [inline] |
int OpaqueInteger< T, Dummy >::operator> | ( | OpaqueInteger< T, Dummy > | other | ) | const [inline] |
int OpaqueInteger< T, Dummy >::operator<= | ( | OpaqueInteger< T, Dummy > | other | ) | const [inline] |
int OpaqueInteger< T, Dummy >::operator>= | ( | OpaqueInteger< T, Dummy > | other | ) | const [inline] |
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator++ | ( | ) | [inline] |
Definition at line 110 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00111 { 00112 return OpaqueInteger<T,Dummy>(++val); 00113 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator++ | ( | int | ) | [inline] |
Definition at line 115 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00116 { 00117 return OpaqueInteger<T,Dummy>(val++); 00118 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator-- | ( | ) | [inline] |
Definition at line 120 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00121 { 00122 return OpaqueInteger<T,Dummy>(--val); 00123 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator-- | ( | int | ) | [inline] |
Definition at line 125 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00126 { 00127 return OpaqueInteger<T,Dummy>(val--); 00128 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator *= | ( | OpaqueInteger< T, Dummy > | i | ) | [inline] |
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator/= | ( | OpaqueInteger< T, Dummy > | i | ) | [inline] |
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator+= | ( | OpaqueInteger< T, Dummy > | i | ) | [inline] |
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator-= | ( | OpaqueInteger< T, Dummy > | i | ) | [inline] |
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator%= | ( | OpaqueInteger< T, Dummy > | i | ) | [inline] |
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator *= | ( | T | t | ) | [inline] |
Definition at line 160 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00161 { 00162 val *= t; 00163 return *this; 00164 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator/= | ( | T | t | ) | [inline] |
Definition at line 166 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00167 { 00168 val /= t; 00169 return *this; 00170 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator+= | ( | T | t | ) | [inline] |
Definition at line 172 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00173 { 00174 val += t; 00175 return *this; 00176 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator-= | ( | T | t | ) | [inline] |
Definition at line 178 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00179 { 00180 val -= t; 00181 return *this; 00182 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator%= | ( | T | t | ) | [inline] |
Definition at line 184 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00185 { 00186 val %= t; 00187 return *this; 00188 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator>>= | ( | int | i | ) | [inline] |
Definition at line 190 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00191 { 00192 val >>= i; 00193 return *this; 00194 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator<<= | ( | int | i | ) | [inline] |
Definition at line 196 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00197 { 00198 val >>= i; 00199 return *this; 00200 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator>> | ( | int | i | ) | const [inline] |
Definition at line 202 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00203 { 00204 return OpaqueInteger<T,Dummy>(val >> i); 00205 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator<< | ( | int | i | ) | const [inline] |
Definition at line 207 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00208 { 00209 return OpaqueInteger<T,Dummy>(val << i); 00210 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator% | ( | T | i | ) | const [inline] |
Definition at line 212 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00213 { 00214 return OpaqueInteger<T,Dummy>(val % i); 00215 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator/ | ( | T | i | ) | const [inline] |
Definition at line 217 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00218 { 00219 return OpaqueInteger<T,Dummy>(val / i); 00220 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator * | ( | T | i | ) | const [inline] |
Definition at line 222 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00223 { 00224 return OpaqueInteger<T,Dummy>(val * i); 00225 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator+ | ( | T | t | ) | const [inline] |
Definition at line 227 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00228 { 00229 return OpaqueInteger<T,Dummy>(val+t); 00230 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator- | ( | T | t | ) | const [inline] |
Definition at line 232 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00233 { 00234 return OpaqueInteger<T,Dummy>(val-t); 00235 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator% | ( | OpaqueInteger< T, Dummy > | i | ) | const [inline] |
Definition at line 237 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00238 { 00239 return OpaqueInteger<T,Dummy>(val % i.val); 00240 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator/ | ( | OpaqueInteger< T, Dummy > | i | ) | const [inline] |
Definition at line 242 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00243 { 00244 return OpaqueInteger<T,Dummy>(val / i.val); 00245 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator * | ( | OpaqueInteger< T, Dummy > | i | ) | const [inline] |
Definition at line 247 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00248 { 00249 return OpaqueInteger<T,Dummy>(val * i.val); 00250 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator+ | ( | OpaqueInteger< T, Dummy > | i | ) | const [inline] |
Definition at line 252 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00253 { 00254 return OpaqueInteger<T,Dummy>(val+i.val); 00255 }
OpaqueInteger<T,Dummy> OpaqueInteger< T, Dummy >::operator- | ( | OpaqueInteger< T, Dummy > | i | ) | const [inline] |
Definition at line 257 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
00258 { 00259 return OpaqueInteger<T,Dummy>(val-i.val); 00260 }
T OpaqueInteger< T, Dummy >::getWrapped | ( | ) | const [inline] |
Definition at line 262 of file OpaqueInteger.h.
References OpaqueInteger< T, Dummy >::val.
Referenced by opaqueToInt().
00263 { 00264 return val; 00265 }
T OpaqueInteger< T, Dummy >::val [protected] |
Definition at line 66 of file OpaqueInteger.h.
Referenced by OpaqueInteger< T, Dummy >::getWrapped(), OpaqueInteger< T, Dummy >::OpaqueInteger(), OpaqueInteger< T, Dummy >::operator *(), OpaqueInteger< T, Dummy >::operator *=(), OpaqueInteger< T, Dummy >::operator!=(), OpaqueInteger< T, Dummy >::operator%(), OpaqueInteger< T, Dummy >::operator%=(), OpaqueInteger< T, Dummy >::operator+(), OpaqueInteger< T, Dummy >::operator++(), OpaqueInteger< T, Dummy >::operator+=(), OpaqueInteger< T, Dummy >::operator-(), OpaqueInteger< T, Dummy >::operator--(), OpaqueInteger< T, Dummy >::operator-=(), OpaqueInteger< T, Dummy >::operator/(), OpaqueInteger< T, Dummy >::operator/=(), OpaqueInteger< T, Dummy >::operator<(), OpaqueInteger< T, Dummy >::operator<<(), OpaqueInteger< T, Dummy >::operator<<=(), OpaqueInteger< T, Dummy >::operator<=(), OpaqueInteger< T, Dummy >::operator==(), OpaqueInteger< T, Dummy >::operator>(), OpaqueInteger< T, Dummy >::operator>=(), OpaqueInteger< T, Dummy >::operator>>(), and OpaqueInteger< T, Dummy >::operator>>=().