[C++-sig] Re: Boost.Python << & >> bug

Niall Douglas s_sourceforge at nedprod.com
Tue Aug 5 00:54:19 CEST 2003


On 3 Aug 2003 at 23:10, David Abrahams wrote:

> >        FXStream& (FXStream::*pmf)(FXchar&) = &FXStream::operator<<;
> >
> >        ...
> >           .def('__lshift__', pmf, return_self());
> 
> Hmm, I could change those wrappers so that the "self" argument was
> required to be an lvalue.  That would preclude implicit conversions to
> the self type from being used, but it would allow the self object to
> be mutated by the call.  I doubt it would break any real code.
> Thoughts from the group?

Like it or not, most C++ programmers have never seen the spec and so 
wouldn't understand what you've just said. My copy is an extremely 
antiquated 1996 edition which doesn't have function try blocks etc. 
and while I've read through it several times, I'm still unclear!

If I /do/ read you right, wouldn't making self a lvalue preclude auto-
casting up to an inherited type? If so in my previous bug report, 
subclasses of FXId which use its FXStream << & >> overloads when 
passed as-is would surely no longer work?

Also, surely a rvalue can be mutated through calling a non-const 
method on it? Or does that mean it then becomes a lvalue? Jeesh, I 
don't know anymore ...

Cheers,
Niall





More information about the Cplusplus-sig mailing list