[C++-sig] Re: Boost.Python << & >> bug
David Abrahams
dave at boost-consulting.com
Tue Aug 5 05:21:54 CEST 2003
"Niall Douglas" <s_sourceforge at nedprod.com> writes:
> 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!
Err, lvalue and rvalue are much older concepts than 1996. They come
from 'C'.
> If I /do/ read you right, wouldn't making self a lvalue preclude
> auto- casting up to an inherited type?
No, the opposite.
> If so in my previous bug report, subclasses of FXId which use its
> FXStream << & >> overloads when passed as-is would surely no longer
> work?
The opposite.
> Also, surely a rvalue can be mutated through calling a non-const
> method on it?
Absolutely not. C++ doesn't let you bind rvalues to non-const
references.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list