Boost logo

Boost :

From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2008-06-11 03:15:43


Hi,

In our system there are a lot of pointers to const objects flying around. I've
got several problems in this regard. They can be exhibited by the following
code snippet:
 
a.cpp :
class A{};

void boo1( A const* ) {}
void boo2( A* ) {}

A const* make_const_a() { return (A const*)0; }
A* make_non_const_a() { return (A*)0; }

std::vector<A const*>
make_vec()
{
    return std::vector<A const*>( 1 );
}

....

class_<A,boost::noncopyable>( "A", bp::no_init );

class_<std::vector<A const*> >( "AVec", bp::no_init )
    .def( vector_indexing_suite<std::vector<A const*> >() )
    ;

def( "boo", &boo1 );
def( "boo", &boo2 );
 
def( "make_const_a", &make_const_a,
return_value_policy<reference_existing_object>() );
def( "make_non_const_a", &make_non_const_a,
return_value_policy<reference_existing_object>() );

def( "make_vec", &make_v ec );
  
Problem I. Access to mutable func

Following python statement
mymodule.boo( mymodule.make_non_const_a() )

seems to call incorrect function boo

Problem II. Vector fails completely

Following python statements

vec = pytoolkit.make_vec();
for e in vec: pass

produce

TypeError: No to_python (by-value) converter found for C++ type: class A const *

Any advise?
 
Gennadiy


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk