STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Static Public Member Functions | List of all members
msl::utilities::details::DivisionHelper< T, unsigned __int64, E, DivisionState_SignedUnsigned64 > Class Template Reference

#include <safeint_internal.h>

Static Public Member Functions

static SafeIntError Divide (const T &t, const unsigned __int64 &u, T &result)
 

Member Function Documentation

template<typename T , typename E >
static SafeIntError msl::utilities::details::DivisionHelper< T, unsigned __int64, E, DivisionState_SignedUnsigned64 >::Divide ( const T &  t,
const unsigned __int64 &  u,
T &  result 
)
inlinestatic
1606  {
1607  if( u == 0 )
1608  {
1609  E::SafeIntOnDivZero();
1610  return SafeIntDivideByZero;
1611  }
1612 
1613  if( u <= (unsigned __int64)IntTraits< T >::maxInt )
1614  {
1615  // Else u can safely be cast to T
1616 #pragma warning(suppress:4127)
1617  if( sizeof( T ) < sizeof( __int64 ) )
1618  result = (T)( (int)t/(int)u );
1619  else
1620  result = (T)((__int64)t/(__int64)u);
1621  }
1622  else // Corner case
1623  if( t == IntTraits< T >::minInt && u == (unsigned __int64)IntTraits< T >::minInt )
1624  {
1625  // Min int divided by its own magnitude is -1
1626  result = -1;
1627  }
1628  else
1629  {
1630  result = 0;
1631  }
1632  return SafeIntNoError;
1633  }
Definition: safeint.h:265
char int *typedef int(__CRTDECL *_CRT_REPORT_HOOKW)(int
Definition: crtdbg.h:45
Definition: safeint.h:263

The documentation for this class was generated from the following file: