I have a static member function lerp() inside my class template AnimCurve which I want to specialize for Quaternions, this way:
template<>
inline Quatf AnimCurve<Quatf>::lerp(
const Quatf& start,
const Quatf& end,
float time
)
{
return start.slerp(time, end);
}
However, this is not generic enough because one may also use Quatd. Is it possible to write a function which would work for both, since both Quatf and Quatd are type definitions of Quaternion<T>?
Here is the current definition of AnimCurve:
template< typename T >
class AnimCurve {
public:
AnimCurve() {}
void addKeyframe(float time, T value);
T getvalue(float time) const;
private:
static inline T lerp( const T& start, const T& end, float time );
std::map<float, T> mKeyframes;
};
Is it possible to write a function which would work for both, since both Quatf and Quatd are type definitions of Quaternion?
If you want to specialize your lerp algorithm for exactly those two instantiations of the Quaternion class template, and no other instantiations, then no, you have to explicitly specialize both of them: once for AnimCurve<Quatf> and once for AnimCurve<Quatd>.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With