[C++-sig] return_internal_ref trouble (gcc341)

Neal D. Becker ndbecker2 at verizon.net
Wed Sep 22 22:07:13 CEST 2004


This is the first time I tried return_internal_reference.  I noticed that in
gcc-3.4.1, complex has been changed so that real() and imag() return a ref
(or const ref).  Hurray!  But then what's wrong here:

#include <boost/python/class.hpp>
#include <boost/python/init.hpp>
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <boost/python/return_arg.hpp>
#include <complex>
#include <boost/python/return_internal_reference.hpp>

using namespace boost::python;

BOOST_PYTHON_MODULE(c)
{    
  typedef std::complex<double> Complex;

  class_<Complex>("whatever")
    .def ("real", (double&(Complex::*)())(&Complex::real),
return_internal_reference<>())
    ;
}

g++ -c -I /usr/local/src/boost.cvs c.cc -I /usr/include/python2.3
/usr/local/src/boost.cvs/boost/python/object/make_instance.hpp: In static
member function `static PyObject*
boost::python::objects::make_instance_impl<T, Holder,
Derived>::execute(Arg&) [with Arg = double*, T = double, Holder =
boost::python::objects::pointer_holder<double*, double>, Derived =
boost::python::objects::make_ptr_instance<double,
boost::python::objects::pointer_holder<double*, double> >]':
/usr/local/src/boost.cvs/boost/python/to_python_indirect.hpp:96:  
instantiated from `static PyObject*
boost::python::detail::make_reference_holder::execute(T*) [with T =
double]'
/usr/local/src/boost.cvs/boost/python/to_python_indirect.hpp:60:  
instantiated from `PyObject* boost::python::to_python_indirect<T,
MakeHolder>::execute(const U&, mpl_::false_) const [with U = double, T =
double&, MakeHolder = boost::python::detail::make_reference_holder]'
/usr/local/src/boost.cvs/boost/python/to_python_indirect.hpp:37:  
instantiated from `PyObject* boost::python::to_python_indirect<T,
MakeHolder>::operator()(const U&) const [with U = double, T = double&,
MakeHolder = boost::python::detail::make_reference_holder]'
/usr/local/src/boost.cvs/boost/python/detail/invoke.hpp:88:   instantiated
from `PyObject*
boost::python::detail::invoke(boost::python::detail::invoke_tag_< false, 
true>, const RC&, F&, TC&) [with RC =
boost::python::to_python_indirect<double&,
boost::python::detail::make_reference_holder>, F =
double&(std::complex<double>::*)(), TC =
boost::python::arg_from_python<init_module_c()::Complex&>]'
/usr/local/src/boost.cvs/boost/python/detail/caller.hpp:199:   instantiated
from `PyObject* boost::python::detail::caller_arity<1u>::impl<F, Policies,
Sig>::operator()(PyObject*, PyObject*) [with F =
double&(std::complex<double>::*)(), Policies =
boost::python::return_internal_reference<1u,
boost::python::default_call_policies>, Sig = boost::mpl::vector2<double&,
init_module_c()::Complex&>]'
/usr/local/src/boost.cvs/boost/python/object/py_function.hpp:38:  
instantiated from `PyObject*
boost::python::objects::caller_py_function_impl<Caller>::operator(
(PyObject*, PyObject*) [with Caller =
boost::python::detail::caller<double&(std::complex<double>::*)(),
boost::python::return_internal_reference<1u,
boost::python::default_call_policies>, boost::mpl::vector2<double&,
init_module_c()::Complex&> >]'
c.cc:937:   instantiated from here
/usr/local/src/boost.cvs/boost/python/object/make_instance.hpp:24: error:
invalid application of `sizeof' to incomplete type
`boost::STATIC_ASSERTION_FAILURE< false>' 





More information about the Cplusplus-sig mailing list