[C++-sig] template constructor problem
David Abrahams
david.abrahams at rcn.com
Sat Jan 19 17:03:38 CET 2002
----- Original Message -----
From: "Ralf W. Grosse-Kunstleve" <rwgk at cci.lbl.gov>
> template <typename ValueType>
> struct stats
> {
> file://template <typename VectorType> stats(const VectorType& vec) {
> stats(const std::vector<float>& vec) {
----------^^^^^^^^^^^^^^^^^^^^^^^^^
> m_min = vector_min(vec);
> }
> ValueType m_min;
> };
>
> BOOST_PYTHON_MODULE_INIT(template_constructor)
> {
> boost::python::module_builder this_module("template_constructor");
>
> boost::python::class_builder<std::vector<float> > py_svf(this_module,
"svf");
> py_svf.def(boost::python::constructor<>());
>
> boost::python::class_builder<stats<float> > py_stats(this_module,
"stats");
> 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.
-Dave
More information about the Cplusplus-sig
mailing list