abs( unsigned_int<> )

This function is provided for "Completeness" as signed_int<> has a version and inbuilt unsigned will work with std::abs.

It doesn't do anything as an unsigned value is always > 0.

#include <iostream>
#include <ostream>
#include <cstdlib> /* for std::abs */

#include "imp/unsigned_int.hpp"


int main()
{
  using namespace imp;
  using namespace std;
  
  unsigned_int< 128 > u128("123456789123456789123456" );
      
  using std::abs;
  
  unsigned_int< 128 > a = abs( u128 );

  cout <<  a << '\n';
  
  if ( a != u128 )
  {
    cerr << "Arghhhhhhhh..........\n";
    return EXIT_FAILURE;
  }
  
  return EXIT_SUCCESS;
}

Test Result: gcc34 Passed, msvc80 Passed, msvc71 Passed

Warning

./gensrc/non-mf-func-abs-id-abs.cpp:17:
: 'const imp::unsigned_int_s::unsigned_int<N> &imp::unsigned_int_s::abs<128>(const imp::unsigned_int_s::unsigned_int<N> &)' : resolved overload was found by argument-dependent lookup
        with
        [
            N=128
        ]
../adl.hpp:117:
see declaration of 'imp::unsigned_int_s::abs'

Output

123456789123456789123456