Boost logo

Boost :

From: Xavier Warin (xavier.warin_at_[hidden])
Date: 2001-04-09 07:39:28

David Abrahams wrote:

> Your code looks correct to me, except for that your world constructor takes
> Data by value and you specified in initriskneut that it was passed by
> const&.
> Regards,
> Dave

Sorry Dave !

I made a mistake while picking up pieces for the mail. So the world
constructor takes Data by reference (for example)

class Data {
private :
  const double w ;
public :
  Data( double v ) : w(v) {} ;
  ~Data() {}
} ;

class world
  const double tu ;
public :
  world( Data & data, double ti) :tu(ti) {};

extern "C"
void initriskneut()
    // Create an object representing this extension module.
    python::module_builder this_module("alltest");

    // Create the Python type object
    boost::python::class_builder< Data > Data_class(this_module, "Data" );
    Data_class.def(boost::python::constructor< double >());

    // Create the Python type object for our extension class world
    boost::python::class_builder<world> world_mod(this_module, "world");
    // constructor
    // How to define the mapping Between the Data python object (created via
BPL) and the
    // a Data C++ object to give to the constructor
    world_mod(boost::python::constructor< Data & , double >());
    boost::python::handle_exception(); // Deal with the exception for Python

I get the following error with GCC :
../BPL_NEW/ In function `void initriskneut(...)':
../BPL_NEW/ no match for call to
>) (boost::python::constructor<Data


I get the following error with KCC
"../BPL_NEW/", line 40: error: expression must have (pointer-to-)
          function type
      world_mod(boost::python::constructor< Data & , double >());

This only happens while using Data in a contructor of a second class. No
problem if the Data object is used as an input for a function.
I though that i missed something (that i had to do something more for the
mapping). Could you confirm that it should work
(for me it shouldn't : a link is missing...)
Best regards


Boost list run by bdawes at, gregod at, cpdaniel at, john at