[C++-sig] make_getter problem

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Tue May 20 09:43:44 CEST 2003


The code below comiles and works as expected with Boost 1.30.0, but fails to
compile with the current CVS state (see attached error message) unless the
add_property line is commented out. What could be wrong?
Thanks,
        Ralf

#include <boost/python/module.hpp>
#include <boost/python/class.hpp>

namespace sandbx { namespace {

  struct trivial
  {
    trivial() : value(123) {}
    double value;
  };

  void init_module()
  {
    using namespace boost::python;
    class_<trivial>("trivial")
      .add_property("property", make_getter(&trivial::value,
return_value_policy<return_by_value>()))
      .def_readonly("readonly", &trivial::value)
    ;
  }

}} // namespace sandbx::<anonymous>

BOOST_PYTHON_MODULE(make_getter)
{
  sandbx::init_module();
}


Output of gcc 3.2 (similar with gcc 3.3):

g++ -fPIC -ftemplate-depth-120 -w -O0 -fno-inline -DBOOST_PYTHON_MAX_BASES=2
-I/net/cci/rwgk/hot/sandbx/include -I/net/cci/rwgk/hot/boost
-I/usr/include/python2.2 -c -o sandbx/debug/make_getter_module.os
/net/cci/rwgk/hot/sandbx/debug/make_getter_module.cpp
/net/cci/rwgk/hot/sandbx/debug/make_getter_module.cpp: In function `void 
   sandbx::<unnamed>::init_module()':
/net/cci/rwgk/hot/sandbx/debug/make_getter_module.cpp:16: could not convert `
   &sandbx::<unnamed>::trivial::value' to `double 
   sandbx::<unnamed>::trivial::*&'
/net/cci/rwgk/hot/boost/boost/python/data_members.hpp:219: in passing argument 
   1 of `boost::python::api::object boost::python::make_getter(D&, const 
   Policies&) [with D = double sandbx::<unnamed>::trivial::*, Policies = 
   boost::python::return_value_policy<boost::python::return_by_value, 
   boost::python::default_call_policies>]'


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com




More information about the Cplusplus-sig mailing list