[C++-sig] Py++ module for code with protected operator=
Maciej Sitarz
macieksitarz at wp.pl
Fri Mar 19 17:42:40 CET 2010
Hi all,
I want to create python module for class that has protected operator=.
That class placed in std::vector and code generated by Py++ uses that
operator.
Simple example...
*****
The c++ code:
#include <vector>
class JobPropertyWrapper {
protected:
JobPropertyWrapper& operator=( const
JobPropertyWrapper& aProp ) throw () { return *this; }
};
class classA {
public:
void fun( const std::vector<JobPropertyWrapper>& v) { }
};
int main() {
classA c;
c.fun( std::vector<JobPropertyWrapper>() );
return 1;
}
******
Py++ script:
mb = module_builder.module_builder_t( ... )
mb.class_( 'JobPropertyWrapper' ).noncopyable = True
mb.build_code_creator( module_name='test' )
******
The compile error(part of it):
test.h:6: error: 'JobPropertyWrapper&
JobPropertyWrapper::operator=(const JobPropertyWrapper&)' is protected
/usr/include/boost/python/suite/indexing/vector_indexing_suite.hpp:91:
error: within this context
test.h: In member function 'void std::vector<_Tp,
_Alloc>::_M_insert_aux(__gnu_cxx::__normal_iterator<typename
std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer,
std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = JobPropertyWrapper,
_Alloc = std::allocator<JobPropertyWrapper>]':
As you can see i tried to inform py++ that the class is 'noncopyable'
but that didn't do the trick.
I attached the generated code.
There's also some problem with operator== not existing, which I also
didn't know how to fix.
Thanks in advance
--
Maciek Sitarz
--
Maciek Sitarz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: generated_True.cpp
Type: text/x-c++src
Size: 1434 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20100319/75f309cc/attachment.cpp>
More information about the Cplusplus-sig
mailing list