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
// This file has been generated by Py++.
#include "boost/python.hpp"
#include "boost/python/suite/indexing/vector_indexing_suite.hpp"
#include "test.h"
namespace bp = boost::python;
BOOST_PYTHON_MODULE(test){
{ //::std::vector< JobPropertyWrapper >
typedef bp::class_< std::vector< JobPropertyWrapper > > vector_less__JobPropertyWrapper__greater__exposer_t;
vector_less__JobPropertyWrapper__greater__exposer_t vector_less__JobPropertyWrapper__greater__exposer = vector_less__JobPropertyWrapper__greater__exposer_t( "vector_less__JobPropertyWrapper__greater_" );
bp::scope vector_less__JobPropertyWrapper__greater__scope( vector_less__JobPropertyWrapper__greater__exposer );
//WARNING: the next line of code will not compile, because "::JobPropertyWrapper" does not have operator== !
vector_less__JobPropertyWrapper__greater__exposer.def( bp::vector_indexing_suite< ::std::vector< JobPropertyWrapper > >() );
}
bp::class_< JobPropertyWrapper, boost::noncopyable >( "JobPropertyWrapper" );
bp::class_< classA >( "classA" )
.def(
"fun"
, (void ( ::classA::* )( ::std::vector< JobPropertyWrapper > const & ) )( &::classA::fun )
, ( bp::arg("v") ) );
{ //::main
typedef int ( *main_function_type )( );
bp::def(
"main"
, main_function_type( &::main ) );
}
}
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig