On 20.03.2010 19:12, Roman Yakovenko wrote:
On Fri, Mar 19, 2010 at 6:42 PM, Maciej Sitarz<macieksit...@wp.pl>  wrote:

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.

I could be wring, but if I remember right, you can not use such
classes with Boost.Python indexing suite. I suggest you to switch to
the indexing suite that comes with Py++:
http://language-binding.net/pyplusplus/documentation/containers.html .
I am pretty sure it will work out of the box. You will not have to
specify "noncopyable=True".

I tried indexing_suite_version=2 but the problem is still the same.

Difference in generated code with noncopyable set and not set:
--- generated_idx2.cpp  2010-03-20 19:58:42.611632788 +0100
+++ generated_idx2_noncopyable.cpp      2010-03-20 20:00:39.494986097 +0100
@@ -40,7 +40,7 @@ BOOST_PYTHON_MODULE(test){
vector_less__JobPropertyWrapper__greater__exposer.def( bp::indexing::vector_suite< std::vector< JobPropertyWrapper > >() );
     }

-    bp::class_< JobPropertyWrapper >( "JobPropertyWrapper" );
+ bp::class_< JobPropertyWrapper, boost::noncopyable >( "JobPropertyWrapper" );

The compile errors are still the same:
generated.cpp:40:   instantiated from here
test.h:6: error: 'JobPropertyWrapper& JobPropertyWrapper::operator=(const JobPropertyWrapper&)' is protected

I attached the generated file with this mail.

--
Maciek Sitarz
// This file has been generated by Py++.

#include "boost/python.hpp"

#include "indexing_suite/value_traits.hpp"

#include "indexing_suite/container_suite.hpp"

#include "indexing_suite/vector.hpp"

#include "test.h"

namespace bp = boost::python;

namespace boost { namespace python { namespace indexing {

template<>
struct value_traits< JobPropertyWrapper >{

    static bool const equality_comparable = false;
    

    static bool const less_than_comparable = false;
    

    template<typename PythonClass, typename Policy>
    static void visit_container_class(PythonClass &, Policy const &){
        
    }

};

}/*indexing*/ } /*python*/ } /*boost*/

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 );
        vector_less__JobPropertyWrapper__greater__exposer.def( bp::indexing::vector_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

Reply via email to