[C++-sig] Re: member function template question.
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Thu Feb 19 23:01:22 CET 2004
--- David Abrahams <dave at boost-consulting.com> wrote:
> "Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com> writes:
> > Your example has several layers of complexity. I believe the main trick you
> > need to know is how to use a cast to tell the compiler what you want. E.g.:
> > template <typename FloatType>
> > bool
> > is_positive_definite(
> > vec3<FloatType> const& eigenvalues,
> > FloatType const& tolerance);
> > def("is_positive_definite",
> > (bool(*)(vec3<double> const&, double const&)) is_positive_definite);
> > This is a bit cumbersome but somehow you have to define which FloatType you
> > want to use since you are crossing the boundary between compile-time
> > polymorphism and runtime polymorphism.
> That won't work because is_positive_definite is a template, not a
> function. You can't cast templates.
I agree that the other solution is better, but the code above does in fact work
with all compilers that we are using!
Are they all wrong?
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
More information about the Cplusplus-sig