Widening Conversion

unsigned_int<>'s templated convertion operator allows it to do widening conversion's (like: unsigned short -> unsigned long). It also does narrowing conversion's too, but we don't get a compiler loss of precision warning, as we might with the inbuilt unsigned types.

#include "imp/unsigned_int.hpp"

using imp::unsigned_int;

unsigned_int< 256 > widen_it( unsigned_int< 256 > a )
{
  return a;
}
unsigned_int< 128 > narrow_it( unsigned_int< 128 > a )
{
  return a;
}

int main()
{
  unsigned_int< 128 > a( "123456789123456789123456789" );
  unsigned_int< 256 > b = a;

  b = widen_it( a );
  a = narrow_it( b );
}

Test Result: gcc34 Passed, msvc80 Passed, msvc71 Passed