Group: comp.lang.c++
From: Noah Roberts
Date: Thursday, November 29, 2007 12:57 PM
Subject: Difficult template specialization


template < typename MU_TYPE, typename Y_TYPE >
class linear_interpolator : public interpolation_functionY_TYPE>
{
struct impl : public interpolation_function::impl
{
Y_TYPE interpolate(Y_TYPE y0, Y_TYPE y1, MU_TYPE mu) const
{
return y0 * (1 - mu) + y1 * mu;
}
};
public:
linear_interpolator() :
interpolation_function(boost::shared_ptrinterpolation_function::impl>(new impl)) {}
};

I want to specialize the interpolate function for boost::quantity. Here
is my attempt:


template < typename MU_UNIT, typename MU_TYPE, typename Y_TYPE >
Y_TYPE linear_interpolator< boost::units::quantity< MU_UNIT,
MU_TYPE >, Y_TYPE>::impl::interpolate(Y_TYPE y0, Y_TYPE y1,
boost::units::quantity< MU_UNIT, MU_TYPE > mu)
{
return y0 * ( (1.0 * MU_UNIT()) - mu) + y1 * mu;
}

The compiler complains that it is unable to match a function definition
to an existing declaration. How can I accomplish what I desire, or is
it impossible and I need to declare a complete specialization for one of
the linear_interpolator template or it's internal "impl"?