[C++-sig] Raw constructor (i.e. combination of make_constructor and raw_function)

Hans Meine hans_meine at gmx.net
Mon Aug 22 00:02:07 CEST 2005


Hi!

I guess I am not the first one trying to do this, but the closest discussion I 
could find did not solve this topic:
http://mail.python.org/pipermail/c++-sig/2005-June/008959.html

I am trying to do something like 

    python::class_<MyVector>("PythonVector", python::no_init)
        .def("__init__", python::raw_function(&createVector, 1));

But this gives the vector as first element of the args tuple to 
createVector().  Now, my createVector looks like this:

MyVector createVector(const python::tuple &args, const python::dict &)
{
    int size = python::len(args);
    MyVector result(size);
    for(int i=0; i<size; ++i)
        result[i] = python::extract<double>(args[i])();
    return result;
}

Is there a way to combine the functionality of raw_function and 
make_constructor?  (I even tried staticmethod("__init__") ;-) )

-- 
Ciao, /  /                                                    .o.
     /--/                                                     ..o
    /  / ANS                                                  ooo



More information about the Cplusplus-sig mailing list