[C++-sig] template constructor problem
Ralf W. Grosse-Kunstleve
rwgk at cci.lbl.gov
Sun Jan 20 01:31:35 CET 2002
> template <typename ValueType>
> struct stats
> {
> //template <typename VectorType> stats(const VectorType& vec) {
> stats(const std::vector<float>& vec) {
----------^^^^^^^^^^^^^^^^^^^^^^^^^
> py_stats.def(boost::python::constructor<std::vector<float>&>());
--------------------------------------------^^^^^^^^^^^^^^^^^^^
> I've begun writing "Foo const&" instead of "const Foo&" because the const
> seems to get lost in the second case. Also, it's more consistent with
> pointer notation, e.g. Foo* const.
Ah, sorry for the little glitch. However, the extra const does
not make a difference, no matter where I put the const (const Foo&
or Foo const&). The cxx 6.2 error message is:
cxx: Error: template_constructor.cpp, line 20: #304 no instance of function
template "vector_min" matches the argument list
argument types are: (const
boost::python::detail::reference_parameter<boost::python:
:detail::parameter_traits<const std::vector<float,
std::allocator<float>> &>::const_reference>)
The (almost identical) code is again attached. Isn't the problem
that the compiler does not deduce T const& but
boost::python::detail::reference_parameter<...<...>::const_reference>,
and that reference_parameter does not have a ::value_type?
Thanks,
Ralf
More information about the Cplusplus-sig
mailing list