[C++-sig] Re: problem with overloaded address operator

Fred Houben qhf at oce.nl
Mon Dec 6 15:50:42 CET 2004


----- Original Message ----- 
From: "David Abrahams" <dave at boost-consulting.com>
To: <c++-sig at python.org>
Sent: Friday, November 26, 2004 5:12 PM
Subject: [C++-sig] Re: problem with overloaded address operator


> "Fred Houben" <qhf at oce.nl> writes:
>
> > I solved the problem by editing pointer_holder.hpp. Replacing Value*
> > p = &*this->m_p; with boost::addressof(*this->m_p);.
>
> That's exactly the right fix.
>
> > This way I avoid using the address operator. This works fine, but
> > maybe there's something I'm missing here, any input is welcome.
>
> You didn't miss anything.
>
> > I'm forced to uses boost.python for now 1.30.2, but is this problem
> > solved in other releases?
>
> It is not.  If you'd like to do a survey of the current CVS for uses
> of operator& and submit a patch that replaces all of them, I'd be
> happy to apply it, though.
>
> -- 
> Dave Abrahams
> Boost Consulting
> http://www.boost-consulting.com
>
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
>

I've downloaded the latest version of boost.python from the cvs server.
It seems that the problem of overloaded address operators shifts from
pointer_holder.hpp( v1.30.2) to to_python_indirect.hpp (latest cvs).
Replacing U* const p = &const_cast<U&>(x) with U* const p =
const_cast<U*>(boost::addressof(x)) fixes the problem.
I'm really not that familiar with the boost.python library, but this seems
the only change needed.
If someone can point out other possible problems with overloaded address
operators in boost.python, let me know.

I've included the patched to_python_indirect.hpp.

Fred Houben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pointer_holder.hpp
Type: application/octet-stream
Size: 5254 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20041206/12d1814c/attachment.obj>


More information about the Cplusplus-sig mailing list