[C++-sig] more on why does this produce a dangling reference?

FLETCHER, Shayne, FM Shayne.FLETCHER at rbos.com
Tue Mar 4 19:21:42 CET 2003


Dear All:

Further to my earlier posting today
http://mail.python.org/pipermail/c++-sig/2003-March/003504.html, I have
found one way that seems to produce the required behaviour:

  period const& rate_impl_wrapper::get_floating_frequency() const
  {
    boost::python::object obj(
      boost::python::call_method(m_self
      ,"get_floating_frequency"
      , (boost::type<boost::python::object>*)0));
    return boost::python::extract<period const&>(obj)();
  }

This approach no longer gives rise to a dangling reference error and it
appears to work, but, since obj refcnt is 1, surely this code is returning a
reference to a temporary?

- Shayne.


********************************************************************
      Visit our Internet site at http://www.rbsmarkets.com

This e-mail is intended only for the addressee named above.
As this e-mail may contain confidential or privileged information,
if you are not the named addressee, you are not authorised to
retain, read, copy or disseminate this message or any part of it.
The Royal Bank of Scotland plc is registered in Scotland No 90312
Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB
             Regulated by the Financial Services Authority
********************************************************************




More information about the Cplusplus-sig mailing list