STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Namespaces | Classes | Enumerations | Functions
msl::utilities Namespace Reference

Namespaces

 details
 

Classes

class  SafeInt
 
struct  SafeIntErrorPolicy_InvalidParameter
 
struct  SafeIntErrorPolicy_SafeIntException
 
class  SafeIntException
 

Enumerations

enum  SafeIntError { SafeIntNoError = 0, SafeIntArithmeticOverflow, SafeIntDivideByZero }
 

Functions

template<typename T , typename U >
bool SafeCast (const T From, U &To) throw ()
 
template<typename T , typename U >
bool SafeEquals (const T t, const U u) throw ()
 
template<typename T , typename U >
bool SafeNotEquals (const T t, const U u) throw ()
 
template<typename T , typename U >
bool SafeGreaterThan (const T t, const U u) throw ()
 
template<typename T , typename U >
bool SafeGreaterThanEquals (const T t, const U u) throw ()
 
template<typename T , typename U >
bool SafeLessThan (const T t, const U u) throw ()
 
template<typename T , typename U >
bool SafeLessThanEquals (const T t, const U u) throw ()
 
template<typename T , typename U >
bool SafeModulus (const T &t, const U &u, T &result) throw ()
 
template<typename T , typename U >
bool SafeMultiply (T t, U u, T &result) throw ()
 
template<typename T , typename U >
bool SafeDivide (T t, U u, T &result) throw ()
 
template<typename T , typename U >
bool SafeAdd (T t, U u, T &result) throw ()
 
template<typename T , typename U >
bool SafeSubtract (T t, U u, T &result) throw ()
 
template<typename T , typename U , typename E >
bool operator< (U lhs, SafeInt< T, E > rhs) throw ()
 
template<typename T , typename U , typename E >
bool operator< (SafeInt< U, E > lhs, SafeInt< T, E > rhs) throw ()
 
template<typename T , typename U , typename E >
bool operator> (U lhs, SafeInt< T, E > rhs) throw ()
 
template<typename T , typename U , typename E >
bool operator> (SafeInt< T, E > lhs, SafeInt< U, E > rhs) throw ()
 
template<typename T , typename U , typename E >
bool operator>= (U lhs, SafeInt< T, E > rhs) throw ()
 
template<typename T , typename U , typename E >
bool operator>= (SafeInt< T, E > lhs, SafeInt< U, E > rhs) throw ()
 
template<typename T , typename U , typename E >
bool operator<= (U lhs, SafeInt< T, E > rhs) throw ()
 
template<typename T , typename U , typename E >
bool operator<= (SafeInt< T, E > lhs, SafeInt< U, E > rhs) throw ()
 
template<typename T , typename E >
bool operator== (bool lhs, SafeInt< T, E > rhs) throw ()
 
template<typename T , typename U , typename E >
bool operator== (U lhs, SafeInt< T, E > rhs) throw ()
 
template<typename T , typename U , typename E >
bool operator== (SafeInt< T, E > lhs, SafeInt< U, E > rhs) throw ()
 
template<typename T , typename U , typename E >
bool operator!= (U lhs, SafeInt< T, E > rhs) throw ()
 
template<typename T , typename E >
bool operator!= (bool lhs, SafeInt< T, E > rhs) throw ()
 
template<typename T , typename U , typename E >
bool operator!= (SafeInt< T, E > lhs, SafeInt< U, E > rhs) throw ()
 
template<typename T , typename U , typename E >
SafeInt< T, E > operator% (U lhs, SafeInt< T, E > rhs)
 
template<typename T , typename U , typename E >
SafeInt< T, E > operator* (U lhs, SafeInt< T, E > rhs)
 
template<typename T , typename U , typename E >
SafeInt< T, E > operator/ (U lhs, SafeInt< T, E > rhs)
 
template<typename T , typename U , typename E >
SafeInt< T, E > operator+ (U lhs, SafeInt< T, E > rhs)
 
template<typename T , typename U , typename E >
SafeInt< T, E > operator- (U lhs, SafeInt< T, E > rhs)
 
template<typename T , typename U , typename E >
T & operator+= (T &lhs, SafeInt< U, E > rhs)
 
template<typename T , typename U , typename E >
T & operator-= (T &lhs, SafeInt< U, E > rhs)
 
template<typename T , typename U , typename E >
T & operator*= (T &lhs, SafeInt< U, E > rhs)
 
template<typename T , typename U , typename E >
T & operator/= (T &lhs, SafeInt< U, E > rhs)
 
template<typename T , typename U , typename E >
T & operator%= (T &lhs, SafeInt< U, E > rhs)
 
template<typename T , typename U , typename E >
T & operator&= (T &lhs, SafeInt< U, E > rhs) throw ()
 
template<typename T , typename U , typename E >
T & operator^= (T &lhs, SafeInt< U, E > rhs) throw ()
 
template<typename T , typename U , typename E >
T & operator|= (T &lhs, SafeInt< U, E > rhs) throw ()
 
template<typename T , typename U , typename E >
T & operator<<= (T &lhs, SafeInt< U, E > rhs) throw ()
 
template<typename T , typename U , typename E >
T & operator>>= (T &lhs, SafeInt< U, E > rhs) throw ()
 
template<typename T , typename U , typename E >
T *& operator+= (T *&lhs, SafeInt< U, E > rhs)
 
template<typename T , typename U , typename E >
T *& operator-= (T *&lhs, SafeInt< U, E > rhs)
 
template<typename T , typename U , typename E >
T *& operator*= (T *lhs, SafeInt< U, E > rhs)
 
template<typename T , typename U , typename E >
T *& operator/= (T *lhs, SafeInt< U, E > rhs)
 
template<typename T , typename U , typename E >
T *& operator%= (T *lhs, SafeInt< U, E > rhs)
 
template<typename T , typename U , typename E >
T *& operator&= (T *lhs, SafeInt< U, E > rhs)
 
template<typename T , typename U , typename E >
T *& operator^= (T *lhs, SafeInt< U, E > rhs)
 
template<typename T , typename U , typename E >
T *& operator|= (T *lhs, SafeInt< U, E > rhs)
 
template<typename T , typename U , typename E >
T *& operator<<= (T *lhs, SafeInt< U, E > rhs)
 
template<typename T , typename U , typename E >
T *& operator>>= (T *lhs, SafeInt< U, E > rhs)
 
template<typename T , typename U , typename E >
SafeInt< U, E > operator<< (U lhs, SafeInt< T, E > bits) throw ()
 
template<typename T , typename U , typename E >
SafeInt< U, E > operator>> (U lhs, SafeInt< T, E > bits) throw ()
 
template<typename T , typename U , typename E >
SafeInt< T, E > operator& (U lhs, SafeInt< T, E > rhs) throw ()
 
template<typename T , typename U , typename E >
SafeInt< T, E > operator^ (U lhs, SafeInt< T, E > rhs) throw ()
 
template<typename T , typename U , typename E >
SafeInt< T, E > operator| (U lhs, SafeInt< T, E > rhs) throw ()
 

Enumeration Type Documentation

Enumerator
SafeIntNoError 
SafeIntArithmeticOverflow 
SafeIntDivideByZero 
262 {
263  SafeIntNoError = 0,
266 };
Definition: safeint.h:265
Definition: safeint.h:263

Function Documentation

template<typename T , typename U , typename E >
bool msl::utilities::operator!= ( lhs,
SafeInt< T, E >  rhs 
)
throw (
)
1296 {
1297  return !details::EqualityTest< T, U >::IsEquals( rhs, lhs );
1298 }
template<typename T , typename E >
bool msl::utilities::operator!= ( bool  lhs,
SafeInt< T, E >  rhs 
)
throw (
)
1302 {
1303  return ( (T)rhs == 0 ? false : true ) != lhs;
1304 }
template<typename T , typename U , typename E >
bool msl::utilities::operator!= ( SafeInt< T, E >  lhs,
SafeInt< U, E >  rhs 
)
throw (
)
1308 {
1309  return !details::EqualityTest< T, U >::IsEquals( lhs, rhs );
1310 }
template<typename T , typename U , typename E >
SafeInt< T, E > msl::utilities::operator% ( lhs,
SafeInt< T, E >  rhs 
)
1315 {
1316  // Value of return depends on sign of lhs
1317  // This one may not be safe - bounds check in constructor
1318  // if lhs is negative and rhs is unsigned, this will throw an exception.
1319 
1320  // Fast-track the simple case
1321  // same size and same sign
1322 #pragma warning(suppress:4127 6326)
1323  if( sizeof(T) == sizeof(U) && details::IntTraits< T >::isSigned == details::IntTraits< U >::isSigned )
1324  {
1325  if( rhs != 0 )
1326  {
1327  if( details::IntTraits< T >::isSigned && (T)rhs == -1 )
1328  return 0;
1329 
1330  return SafeInt< T, E >( (T)( lhs % (T)rhs ) );
1331  }
1332 
1333  E::SafeIntOnDivZero();
1334  }
1335 
1336  return SafeInt< T, E >( ( SafeInt< U, E >( lhs ) % (T)rhs ) );
1337 }
return(_PAIR_TYPE(_FwdIt)(_First, _First))
template<typename T , typename U , typename E >
T& msl::utilities::operator%= ( T &  lhs,
SafeInt< U, E >  rhs 
)
1476 {
1477  T ret( 0 );
1478  details::ModulusHelper< T, U, E >::Modulus( lhs, (U)rhs, ret );
1479  lhs = ret;
1480  return lhs;
1481 }
template<typename T , typename U , typename E >
T*& msl::utilities::operator%= ( T *  lhs,
SafeInt< U, E >  rhs 
)
1561 {
1562  static_assert( false, "SafeInt<T>: This operator explicitly not supported" );
1563  return lhs;
1564 }
template<typename T , typename U , typename E >
SafeInt< T, E > msl::utilities::operator& ( lhs,
SafeInt< T, E >  rhs 
)
throw (
)
1631 {
1632  return SafeInt< T, E >( details::BinaryAndHelper< T, U >::And( (T)rhs, lhs ) );
1633 }
template<typename T , typename U , typename E >
T& msl::utilities::operator&= ( T &  lhs,
SafeInt< U, E >  rhs 
)
throw (
)
1485 {
1486  lhs = details::BinaryAndHelper< T, U >::And( lhs, (U)rhs );
1487  return lhs;
1488 }
template<typename T , typename U , typename E >
T*& msl::utilities::operator&= ( T *  lhs,
SafeInt< U, E >  rhs 
)
1568 {
1569  static_assert( false, "SafeInt<T>: This operator explicitly not supported" );
1570  return lhs;
1571 }
template<typename T , typename U , typename E >
SafeInt< T, E > msl::utilities::operator* ( lhs,
SafeInt< T, E >  rhs 
)
1342 {
1343  T ret( 0 );
1344  details::MultiplicationHelper< T, U, E >::Multiply( (T)rhs, lhs, ret );
1345  return SafeInt< T, E >(ret);
1346 }
template<typename T , typename U , typename E >
T& msl::utilities::operator*= ( T &  lhs,
SafeInt< U, E >  rhs 
)
1458 {
1459  T ret( 0 );
1460  details::MultiplicationHelper< T, U, E >::Multiply( lhs, (U)rhs, ret );
1461  lhs = ret;
1462  return lhs;
1463 }
template<typename T , typename U , typename E >
T*& msl::utilities::operator*= ( T *  lhs,
SafeInt< U, E >  rhs 
)
1547 {
1548  static_assert( false, "SafeInt<T>: This operator explicitly not supported" );
1549  return lhs;
1550 }
template<typename T , typename U , typename E >
SafeInt< T, E > msl::utilities::operator+ ( lhs,
SafeInt< T, E >  rhs 
)
1419 {
1420  T ret( 0 );
1421  details::AdditionHelper< T, U, E >::Addition( (T)rhs, lhs, ret );
1422  return SafeInt< T, E >( ret );
1423 }
template<typename T , typename U , typename E >
T& msl::utilities::operator+= ( T &  lhs,
SafeInt< U, E >  rhs 
)
1440 {
1441  T ret( 0 );
1442  details::AdditionHelper< T, U, E >::Addition( lhs, (U)rhs, ret );
1443  lhs = ret;
1444  return lhs;
1445 }
template<typename T , typename U , typename E >
T*& msl::utilities::operator+= ( T *&  lhs,
SafeInt< U, E >  rhs 
)
1524 {
1525  // Cast the pointer to a number so we can do arithmetic
1526  SafeInt< uintptr_t, E > ptr_val = reinterpret_cast< uintptr_t >( lhs );
1527  // Check first that rhs is valid for the type of ptrdiff_t
1528  // and that multiplying by sizeof( T ) doesn't overflow a ptrdiff_t
1529  // Next, we need to add 2 SafeInts of different types, so unbox the ptr_diff
1530  // Finally, cast the number back to a pointer of the correct type
1531  lhs = reinterpret_cast< T* >( (uintptr_t)( ptr_val + (ptrdiff_t)( SafeInt< ptrdiff_t, E >( rhs ) * sizeof( T ) ) ) );
1532  return lhs;
1533 }
_W64 unsigned int uintptr_t
Definition: crtdefs.h:521
_W64 int ptrdiff_t
Definition: crtdefs.h:530
template<typename T , typename U , typename E >
SafeInt< T, E > msl::utilities::operator- ( lhs,
SafeInt< T, E >  rhs 
)
1428 {
1429  T ret( 0 );
1430  details::SubtractionHelper< U, T, E, details::SubtractionMethod2< U, T >::method >::Subtract( lhs, rhs.Ref(), ret );
1431 
1432  return SafeInt< T, E >( ret );
1433 }
template<typename T , typename U , typename E >
T& msl::utilities::operator-= ( T &  lhs,
SafeInt< U, E >  rhs 
)
1449 {
1450  T ret( 0 );
1451  details::SubtractionHelper< T, U, E >::Subtract( lhs, (U)rhs, ret );
1452  lhs = ret;
1453  return lhs;
1454 }
template<typename T , typename U , typename E >
T*& msl::utilities::operator-= ( T *&  lhs,
SafeInt< U, E >  rhs 
)
1537 {
1538  // Cast the pointer to a number so we can do arithmetic
1539  SafeInt< size_t, E > ptr_val = reinterpret_cast< uintptr_t >( lhs );
1540  // See above for comments
1541  lhs = reinterpret_cast< T* >( (uintptr_t)( ptr_val - (ptrdiff_t)( SafeInt< ptrdiff_t, E >( rhs ) * sizeof( T ) ) ) );
1542  return lhs;
1543 }
_W64 unsigned int uintptr_t
Definition: crtdefs.h:521
_W64 int ptrdiff_t
Definition: crtdefs.h:530
template<typename T , typename U , typename E >
SafeInt< T, E > msl::utilities::operator/ ( lhs,
SafeInt< T, E >  rhs 
)
1350 {
1351 #pragma warning(push)
1352 #pragma warning(disable: 4127 4146 4307 4310 6326)
1353  // Corner case - has to be handled seperately
1354  if( details::DivisionMethod< U, T >::method == details::DivisionState_UnsignedSigned )
1355  {
1356  if( (T)rhs > 0 )
1357  return SafeInt< T, E >( lhs/(T)rhs );
1358 
1359  // Now rhs is either negative, or zero
1360  if( (T)rhs != 0 )
1361  {
1362  if( sizeof( U ) >= 4 && sizeof( T ) <= sizeof( U ) )
1363  {
1364  // Problem case - normal casting behavior changes meaning
1365  // flip rhs to positive
1366  // any operator casts now do the right thing
1367  U tmp;
1368  if( sizeof(T) == 4 )
1369  tmp = lhs/(U)(unsigned __int32)( -(T)rhs );
1370  else
1371  tmp = lhs/(U)( -(T)rhs );
1372 
1373  if( tmp <= details::IntTraits< T >::maxInt )
1374  return SafeInt< T, E >( -( (T)tmp ) );
1375 
1376  // Corner case
1377  // Note - this warning happens because we're not using partial
1378  // template specialization in this case. For any real cases where
1379  // this block isn't optimized out, the warning won't be present.
1380  if( tmp == (U)details::IntTraits< T >::maxInt + 1 )
1381  return SafeInt< T, E >( details::IntTraits< T >::minInt );
1382 
1383  E::SafeIntOnOverflow();
1384  }
1385 
1386  return SafeInt< T, E >(lhs/(T)rhs);
1387  }
1388 
1389  E::SafeIntOnDivZero();
1390  } // method == DivisionState_UnsignedSigned
1391 
1392  if( details::SafeIntCompare< T, U >::isBothSigned )
1393  {
1394  if( lhs == details::IntTraits< U >::minInt && (T)rhs == -1 )
1395  {
1396  // corner case of a corner case - lhs = min int, rhs = -1,
1397  // but rhs is the return type, so in essence, we can return -lhs
1398  // if rhs is a larger type than lhs
1399  if( sizeof( U ) < sizeof( T ) )
1400  {
1401  return SafeInt< T, E >( (T)( -(T)details::IntTraits< U >::minInt ) );
1402  }
1403 
1404  // If rhs is smaller or the same size int, then -minInt won't work
1405  E::SafeIntOnOverflow();
1406  }
1407  }
1408 
1409  // Otherwise normal logic works with addition of bounds check when casting from U->T
1410  U ret;
1411  details::DivisionHelper< U, T, E >::Divide( lhs, (T)rhs, ret );
1412  return SafeInt< T, E >( ret );
1413 #pragma warning(pop)
1414 }
return(_PAIR_TYPE(_FwdIt)(_First, _First))
template<typename T , typename U , typename E >
T& msl::utilities::operator/= ( T &  lhs,
SafeInt< U, E >  rhs 
)
1467 {
1468  T ret( 0 );
1469  details::DivisionHelper< T, U, E >::Divide( lhs, (U)rhs, ret );
1470  lhs = ret;
1471  return lhs;
1472 }
template<typename T , typename U , typename E >
T*& msl::utilities::operator/= ( T *  lhs,
SafeInt< U, E >  rhs 
)
1554 {
1555  static_assert( false, "SafeInt<T>: This operator explicitly not supported" );
1556  return lhs;
1557 }
template<typename T , typename U , typename E >
bool msl::utilities::operator< ( lhs,
SafeInt< T, E >  rhs 
)
throw (
)
1224 {
1225  return details::GreaterThanTest< T, U >::GreaterThan( (T)rhs, lhs );
1226 }
template<typename T , typename U , typename E >
bool msl::utilities::operator< ( SafeInt< U, E >  lhs,
SafeInt< T, E >  rhs 
)
throw (
)
1230 {
1231  return details::GreaterThanTest< T, U >::GreaterThan( (T)rhs, (U)lhs );
1232 }
template<typename T , typename U , typename E >
SafeInt< U, E > msl::utilities::operator<< ( lhs,
SafeInt< T, E >  bits 
)
throw (
)
1607 {
1608  _SAFEINT_SHIFT_ASSERT( !details::IntTraits< T >::isSigned || (T)bits >= 0 );
1609  _SAFEINT_SHIFT_ASSERT( (T)bits < (int)details::IntTraits< U >::bitCount );
1610 
1611  return SafeInt< U, E >( (U)( lhs << (T)bits ) );
1612 }
#define _SAFEINT_SHIFT_ASSERT(x)
Definition: safeint.h:229
template<typename T , typename U , typename E >
T& msl::utilities::operator<<= ( T &  lhs,
SafeInt< U, E >  rhs 
)
throw (
)
1506 {
1507  lhs = (T)( SafeInt< T, E >( lhs ) << (U)rhs );
1508  return lhs;
1509 }
template<typename T , typename U , typename E >
T*& msl::utilities::operator<<= ( T *  lhs,
SafeInt< U, E >  rhs 
)
1589 {
1590  static_assert( false, "SafeInt<T>: This operator explicitly not supported" );
1591  return lhs;
1592 }
template<typename T , typename U , typename E >
bool msl::utilities::operator<= ( lhs,
SafeInt< T, E >  rhs 
)
throw (
)
1263 {
1264  return !details::GreaterThanTest< U, T >::GreaterThan( lhs, (T)rhs );
1265 }
template<typename T , typename U , typename E >
bool msl::utilities::operator<= ( SafeInt< T, E >  lhs,
SafeInt< U, E >  rhs 
)
throw (
)
1269 {
1270  return !details::GreaterThanTest< T, U >::GreaterThan( (T)lhs, (U)rhs );
1271 }
template<typename T , typename E >
bool msl::utilities::operator== ( bool  lhs,
SafeInt< T, E >  rhs 
)
throw (
)
1277 {
1278  return lhs == ( (T)rhs == 0 ? false : true );
1279 }
template<typename T , typename U , typename E >
bool msl::utilities::operator== ( lhs,
SafeInt< T, E >  rhs 
)
throw (
)
1283 {
1284  return details::EqualityTest< T, U >::IsEquals((T)rhs, lhs);
1285 }
template<typename T , typename U , typename E >
bool msl::utilities::operator== ( SafeInt< T, E >  lhs,
SafeInt< U, E >  rhs 
)
throw (
)
1289 {
1290  return details::EqualityTest< T, U >::IsEquals( (T)lhs, (U)rhs );
1291 }
template<typename T , typename U , typename E >
bool msl::utilities::operator> ( lhs,
SafeInt< T, E >  rhs 
)
throw (
)
1237 {
1238  return details::GreaterThanTest< U, T >::GreaterThan( lhs, (T)rhs );
1239 }
template<typename T , typename U , typename E >
bool msl::utilities::operator> ( SafeInt< T, E >  lhs,
SafeInt< U, E >  rhs 
)
throw (
)
1243 {
1244  return details::GreaterThanTest< T, U >::GreaterThan( (T)lhs, (U)rhs );
1245 }
template<typename T , typename U , typename E >
bool msl::utilities::operator>= ( lhs,
SafeInt< T, E >  rhs 
)
throw (
)
1250 {
1251  return !details::GreaterThanTest< T, U >::GreaterThan( (T)rhs, lhs );
1252 }
template<typename T , typename U , typename E >
bool msl::utilities::operator>= ( SafeInt< T, E >  lhs,
SafeInt< U, E >  rhs 
)
throw (
)
1256 {
1257  return !details::GreaterThanTest< U, T >::GreaterThan( (U)rhs, (T)lhs );
1258 }
template<typename T , typename U , typename E >
SafeInt< U, E > msl::utilities::operator>> ( lhs,
SafeInt< T, E >  bits 
)
throw (
)
1617 {
1618  _SAFEINT_SHIFT_ASSERT( !details::IntTraits< T >::isSigned || (T)bits >= 0 );
1619  _SAFEINT_SHIFT_ASSERT( (T)bits < (int)details::IntTraits< U >::bitCount );
1620 
1621  return SafeInt< U, E >( (U)( lhs >> (T)bits ) );
1622 }
#define _SAFEINT_SHIFT_ASSERT(x)
Definition: safeint.h:229
template<typename T , typename U , typename E >
T& msl::utilities::operator>>= ( T &  lhs,
SafeInt< U, E >  rhs 
)
throw (
)
1513 {
1514  lhs = (T)( SafeInt< T, E >( lhs ) >> (U)rhs );
1515  return lhs;
1516 }
template<typename T , typename U , typename E >
T*& msl::utilities::operator>>= ( T *  lhs,
SafeInt< U, E >  rhs 
)
1596 {
1597  static_assert( false, "SafeInt<T>: This operator explicitly not supported" );
1598  return lhs;
1599 }
template<typename T , typename U , typename E >
SafeInt< T, E > msl::utilities::operator^ ( lhs,
SafeInt< T, E >  rhs 
)
throw (
)
1638 {
1639  return SafeInt< T, E >(details::BinaryXorHelper< T, U >::Xor( (T)rhs, lhs ) );
1640 }
template<typename T , typename U , typename E >
T& msl::utilities::operator^= ( T &  lhs,
SafeInt< U, E >  rhs 
)
throw (
)
1492 {
1493  lhs = details::BinaryXorHelper< T, U >::Xor( lhs, (U)rhs );
1494  return lhs;
1495 }
template<typename T , typename U , typename E >
T*& msl::utilities::operator^= ( T *  lhs,
SafeInt< U, E >  rhs 
)
1575 {
1576  static_assert( false, "SafeInt<T>: This operator explicitly not supported" );
1577  return lhs;
1578 }
template<typename T , typename U , typename E >
SafeInt< T, E > msl::utilities::operator| ( lhs,
SafeInt< T, E >  rhs 
)
throw (
)
1645 {
1646  return SafeInt< T, E >( details::BinaryOrHelper< T, U >::Or( (T)rhs, lhs ) );
1647 }
template<typename T , typename U , typename E >
T& msl::utilities::operator|= ( T &  lhs,
SafeInt< U, E >  rhs 
)
throw (
)
1499 {
1500  lhs = details::BinaryOrHelper< T, U >::Or( lhs, (U)rhs );
1501  return lhs;
1502 }
template<typename T , typename U , typename E >
T*& msl::utilities::operator|= ( T *  lhs,
SafeInt< U, E >  rhs 
)
1582 {
1583  static_assert( false, "SafeInt<T>: This operator explicitly not supported" );
1584  return lhs;
1585 }
template<typename T , typename U >
bool msl::utilities::SafeAdd ( t,
u,
T &  result 
)
throw (
)
inline
390 {
391  return ( details::AdditionHelper< T, U,
392  details::SafeIntErrorPolicy_NoThrow >::Addition( t, u, result ) == SafeIntNoError );
393 }
Definition: safeint.h:263
template<typename T , typename U >
bool msl::utilities::SafeCast ( const T  From,
U &  To 
)
throw (
)
inline
327 {
328  return (details::SafeCastHelper< U, T,
329  details::SafeIntErrorPolicy_NoThrow >::Cast( From, To ) == SafeIntNoError);
330 }
Definition: safeint.h:263
template<typename T , typename U >
bool msl::utilities::SafeDivide ( t,
u,
T &  result 
)
throw (
)
inline
383 {
384  return ( details::DivisionHelper< T, U,
385  details::SafeIntErrorPolicy_NoThrow >::Divide( t, u, result ) == SafeIntNoError );
386 }
Definition: safeint.h:263
template<typename T , typename U >
bool msl::utilities::SafeEquals ( const T  t,
const U  u 
)
throw (
)
inline
334 {
335  return details::EqualityTest< T, U >::IsEquals( t, u );
336 }
template<typename T , typename U >
bool msl::utilities::SafeGreaterThan ( const T  t,
const U  u 
)
throw (
)
inline
346 {
347  return details::GreaterThanTest< T, U >::GreaterThan( t, u );
348 }
template<typename T , typename U >
bool msl::utilities::SafeGreaterThanEquals ( const T  t,
const U  u 
)
throw (
)
inline
352 {
353  return !details::GreaterThanTest< U, T >::GreaterThan( u, t );
354 }
template<typename T , typename U >
bool msl::utilities::SafeLessThan ( const T  t,
const U  u 
)
throw (
)
inline
358 {
359  return details::GreaterThanTest< U, T >::GreaterThan( u, t );
360 }
template<typename T , typename U >
bool msl::utilities::SafeLessThanEquals ( const T  t,
const U  u 
)
throw (
)
inline
364 {
365  return !details::GreaterThanTest< T, U >::GreaterThan( t, u );
366 }
template<typename T , typename U >
bool msl::utilities::SafeModulus ( const T &  t,
const U &  u,
T &  result 
)
throw (
)
inline
370 {
371  return ( details::ModulusHelper< T, U, details::SafeIntErrorPolicy_NoThrow >::Modulus( t, u, result ) == SafeIntNoError );
372 }
Definition: safeint.h:263
template<typename T , typename U >
bool msl::utilities::SafeMultiply ( t,
u,
T &  result 
)
throw (
)
inline
376 {
377  return ( details::MultiplicationHelper< T, U,
378  details::SafeIntErrorPolicy_NoThrow >::Multiply( t, u, result ) == SafeIntNoError );
379 }
Definition: safeint.h:263
template<typename T , typename U >
bool msl::utilities::SafeNotEquals ( const T  t,
const U  u 
)
throw (
)
inline
340 {
341  return !details::EqualityTest< T, U >::IsEquals( t, u );
342 }
template<typename T , typename U >
bool msl::utilities::SafeSubtract ( t,
u,
T &  result 
)
throw (
)
inline
397 {
398  return ( details::SubtractionHelper< T, U,
399  details::SafeIntErrorPolicy_NoThrow >::Subtract( t, u, result ) == SafeIntNoError );
400 }
Definition: safeint.h:263