Difficult template specialization

N

Noah Roberts

template < typename MU_TYPE, typename Y_TYPE >
class linear_interpolator : public interpolation_function<MU_TYPE,
Y_TYPE>
{
struct impl : public interpolation_function<MU_TYPE, Y_TYPE>::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_ptr<typename
interpolation_function<MU_TYPE, Y_TYPE>::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"?
 
N

Noah Roberts

I'd still be interested in hearing an answer to the problem below. I
worked around it in the production code I was working on, but I'd like
to know how to accomplish this next time I run into the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,186
Messages
2,570,998
Members
47,587
Latest member
JohnetteTa

Latest Threads

Top