copy construktor problem by extending python with c++ using boost python lib

stefan kusch stefan2k1de at yahoo.de
Mon Apr 23 03:25:06 EDT 2001


hello...
I want to embed and extend python with a c++ module using 
the boost python library.

I created a simple class with a constructor and a copy constructor.
The problem is that the boost library don't accept the copy
constructor and the 
compiler (VC60, SP4) returns the following error:

example1.cpp
..\..\..\..\boost/python/detail/extension_class.hpp(178) : 
  error C2664: '__thiscall
boost::python::detail::instance_value_holder<
    class mein::CObRegistry,class
boost::python::detail::held_instance<
    class mein::CObRegistry>
>::boost::python::detail::instance_value_holder<
    class mein::CObRegistry,class
boost::python::detail::held_instance<
    class mein::CObRegistry> >(class
boost::python::detail::extension_instance *,
                               class mein::CObRegistry)' : 
    Conversion of parameters 2 from 'const class mein::CObRegistry' in

    'class mein::CObRegistry' not possible
    No copy constructor for class 'mein::CObRegistry' available
    

What is going wrong?

my systemconfiguration : win2000, VC60 SP4, python20, boost 1.21.1 .

Thanks for all answers.
Stefan


------------example code fragments---------------


...
#include <boost/python/class_builder.hpp>
namespace python = boost::python;


namespace mein{ // Avoid cluttering the global namespace.

class A 
{
	A();
	A(A &a);
...
};


A::A()
{
	cout << "A construktor" << endl;
}

A::A(A &a)//copy constructor
{
  cout << "A copy construktor\n";
...
}

}

using namespace mein;

#include <boost/python/class_builder.hpp>
namespace python = boost::python;

initgetting_started1()
{
  try
  {
    // Create an object representing this extension module.
    python::module_builder this_module("getting_started1");
    // Create the Python type object for our extension class.
    python::class_builder<A> A_class(this_module, "A");
//Add the __init_-function
    A_class.def(python::constructor< >());
...
  }
  catch(...)
  {
    python::handle_exception(); // Deal with the exception for Python
  }
}






More information about the Python-list mailing list