Boost logo

Boost :

From: Gavin Collings (gcollings_at_[hidden])
Date: 2000-02-22 11:44:29


>
> Gavin, sorry to be so dense, but when you said "done it manually"
> what do you mean? How did you do it?
>
> Or more to the point, is there a reasonable workaround for VC++ ?

I actually meant forgetting about templates and laboriously writing out
each function - like runtestbool( "bool" ) etc. But I've just tried
adding a dummy argument and relying on argument deduction rather than
explicit specification of the template parameter - that works too.

Gavin.

  template<class T>
  void runtest( T t, const std::string & type)
  {
    typedef boost::integer_traits<T> traits;
    std::cout << "Checking " << type
              << "; min is " << traits::min()
              << ", max is " << traits::max()
              << std::endl;
    assert(traits::is_specialized);
    assert(traits::is_integer);
    assert(traits::is_integral);
    assert(traits::const_min == traits::min());
    assert(traits::const_max == traits::max());
  }

  ...

  typedef signed char schar;
  typedef unsigned char uchar;
  typedef unsigned short ushort;
  typedef unsigned int uint;
  typedef unsigned long ulong;

  runtest( bool(), "bool");
  runtest( char(), "char");
  runtest( schar(), "signed char");
  runtest( uchar(), "unsigned char");
  runtest( short(), "short");
  runtest( ushort(), "unsigned short");
  runtest( int(), "int");
  runtest( uint(), "unsigned int");
  runtest( long(), "long");
  runtest( ulong(), "unsigned long");


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk