Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2001-05-13 12:09:42


Could anyone come up with a testing strategy for the following class
templates? They would go in <boost/integer.hpp> and share the same
test/example file.

//=========================================================================
  // integer templates specifying extreme value ----------------------//

  // signed
  template< long MaxValue > // maximum value to require support
  struct int_max_value_t
  {
      typedef typename int_least_helper
        <
          (MaxValue <= integer_traits<long>::const_max) +
          (MaxValue <= integer_traits<int>::const_max) +
          (MaxValue <= integer_traits<short>::const_max) +
          (MaxValue <= integer_traits<signed char>::const_max)
>::least least;
      typedef typename int_fast_t<least>::fast fast;
  };

  template< long MinValue > // minimum value to require support
  struct int_min_value_t
  {
      typedef typename int_least_helper
        <
          (MinValue >= integer_traits<long>::const_min) +
          (MinValue >= integer_traits<int>::const_min) +
          (MinValue >= integer_traits<short>::const_min) +
          (MinValue >= integer_traits<signed char>::const_min)
>::least least;
      typedef typename int_fast_t<least>::fast fast;
  };

  // unsigned
  template< unsigned long Value > // maximum value to require support
  struct uint_value_t
  {
      typedef typename int_least_helper
        <
          5 +
          (Value <= integer_traits<unsigned long>::const_max) +
          (Value <= integer_traits<unsigned int>::const_max) +
          (Value <= integer_traits<unsigned short>::const_max) +
          (Value <= integer_traits<unsigned char>::const_max)
>::least least;
      typedef typename int_fast_t<least>::fast fast;
  };
//=========================================================================

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com

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