boost-python: exposing constructor with an array of other class as argument

Ester Lopez ester.lopezberga at gmail.com
Tue Jan 28 12:32:11 EST 2014


Hello there,

I have two different classes that I want to expose using boost-python,
but the constructor of the second class takes and array of the first
one as argument and I can't figure out how to do it.

This is the definition of the classes:

    class INT96{
    public:
        uint64_t value[3];
        INT96(){};
        INT96(uint64_t x0, uint64_t x1, uint64_t x2);
        ...
    };
    template <unsigned k>
    class Xi_CW{
        protected:
            INT96 A[k];
        public:
            Xi_CW(INT96 (&A)[k]);
            ...
    };

And my attempt to expose them using boost-python:

    using namespace boost::python;
    typedef Xi_CW<4> Xi_CW4;
    BOOST_PYTHON_MODULE(xis)
    {
        class_<INT96>("INT96", init<double,double,double>())
            [...]
        ;
        class_<Xi_CW4>("Xi_CW4", init<INT96[4]>())
            [...]
        ;
    }

Which results in a "no known conversion error". I've tried several
other possibilities but so far no luck...

Any idea how should I do it? Thanks

Ester



More information about the Python-list mailing list