[C++-sig] Pyplusplus: Exporting arrays of non-copyable type?

Haridev, Meghana mharidev at qualcomm.com
Fri Aug 4 03:14:05 CEST 2006


Hi Folks,

 

I'm using pyplusplus to generate boost.python wrappers for the following
piece of C++ code:

------------------------------------------------------------------------
-----------

//test.cpp

 

class Base {

protected:

    Base() { }

private:

   // Copy constructor and assignment operator should not

   // be used.

   Base(const Base&);

   const Base& operator=(const Base&);

};

 

class Derv: public Base {

public:

   int x;

};

 

class Test: public Base {

public:

    Derv dataArray[20];

};

------------------------------------------------------------------------
-------------

 

In class Test, the dataArray if of type Derv which is a non-copyable
type (because of private copy constructor and assignment operator of
Base class). In other words, this is not allowed:

 

>> obj = Test()

>> obj.dataArray[0] = Derv() #Not allowed

 

But the pyplusplus generated code (register_array_1() in
__array_1.pypp.hpp) exposes a set_item method for the data array though
it's type is non-copyable and hence the code does not compile with the
following error message:

------------------------------------------------------------------------
-------------

test.cpp:8: error: 'const Base& Base::operator=(const Base&)' is private

test.cpp:11: error: within this context

__array_1.pypp.hpp: In member function 'void
pyplusplus::containers::static_sized::array_1_t<TItemType,
size>::set_item(long unsigned int, typename boost::call_traits<const
TItemType>::param_type) [with TItemType = Derv, long unsigned int size =
20ul]':

__array_1.pypp.hpp:73: warning: synthesized method 'Derv&
Derv::operator=(const Derv&)' first required here

------------------------------------------------------------------------
-------------

 

Please see attached source/generated files.

 

Is there any way I can make pyplusplus to NOT generate the set_item
method for arrays of non-copyable type? (maybe by setting some flag?)

 

Thanks,

-Meghana.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060803/e76f561f/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.cpp
Type: application/octet-stream
Size: 300 bytes
Desc: test.cpp
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060803/e76f561f/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: generate_code.py
Type: application/octet-stream
Size: 1066 bytes
Desc: generate_code.py
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060803/e76f561f/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PYPP_YMI.cpp
Type: application/octet-stream
Size: 1591 bytes
Desc: PYPP_YMI.cpp
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060803/e76f561f/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: __array_1.pypp.hpp
Type: application/octet-stream
Size: 3149 bytes
Desc: __array_1.pypp.hpp
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060803/e76f561f/attachment-0003.obj>


More information about the Cplusplus-sig mailing list