[C++-sig] make_constructor strangeness

Neal Becker ndbecker2 at verizon.net
Thu Nov 18 03:53:29 CET 2004

I noticed that the following didn't work:

    .def("__init__", make_constructor(vector_from_object<value_type>))

where size_type is some size (probably size_t), value_type could be double
or std::complex<double>, and vector_from_object has sig:
template<typename T>
inline vector<T>* vector_from_object (object& newobject) {
It seems if I try to construct an object using an argument of type int, the
init<size_type> is being ignored (silently), and the call goes to

I guess you can't dispatch an overload to a function that takes "object". 
Problem is, it seems to act unpredictably, and fails silently.

Unpredictably, because I used the same code for the case where value_type
was double, and also when it was std::complex<double>, and the two acted
differently.  The complex called with an int did call the first
constructor, while the double one called the second.  AFAICT, there were no
other significant differences between the two cases.

More information about the Cplusplus-sig mailing list