[C++-sig] Re: member function template question.

David Abrahams dave at boost-consulting.com
Thu Feb 19 21:31:25 CET 2004

"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.

You can only wrap a particular *instantiation* of a function template.
I suggest picking a FloatType (probably double), and wrapping


Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list