Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-12-06 00:02:39


Daryle,

let's narrow this to where the partial specialization occurs:

----- Original Message -----

> // Function objects to find the best way of computing GCD or LCM
> template < typename T, bool IsSpecialized, bool IsSigned >
> struct gcd_optimal_evaluator_helper
> {
> T operator ()( T const &a, T const &b )
> {
> return gcd_euclidean( a, b );
> }
> };
>
> template < typename T >
> struct gcd_optimal_evaluator_helper< T, true, true >
> {
> T operator ()( T const &a, T const &b )
> {
> return gcd_integer( a, b );
> }
> };

The trick is to use "poor man's partial specialization". First break the
template into two parts:

// untested
template <bool IsSpecialized, bool IsSigned>
struct gcd_optimal_evaluator_helper_outer
{
    template <class T>
    struct inner
    {
          T operator ()( T const &a, T const &b )
          {
              return gcd_euclidean( a, b );
          }
    };
};

// now you can fully specialize:

template <>
struct gcd_optimal_evaluator_helper_outer<true,true>
{
    template <class T>
    struct inner
    {
          T operator ()( T const &a, T const &b )
          {
              return gcd_integer( a, b );
          }
    };
};

and finally:

template < typename T, bool IsSpecialized, bool IsSigned >
struct gcd_optimal_evaluator_helper
    : gcd_optimal_evaluator_helper_outer<IsSpecialized,IsSigned>
        ::BOOST_NESTED_TEMPLATE inner<T>
    {};

I'm sure you can apply the same transformation to
lcm_optimal_evaluator_helper. If you can get this to work with your
compiler, you stand a good chance that it'll work with MSVC6 too.

-Dave


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