Subject: Re: [boost] [operators] The future of Boost.Operators
From: Marc Glisse (marc.glisse_at_[hidden])
Date: 2013-04-25 14:03:26
On Thu, 25 Apr 2013, Jeffrey Lee Hellrung, Jr. wrote:
>>> T& a = b + c;
>>> you'll get a compiler error with (A) or (B) and a runtime error with (C).
>> Er, no. That might be true with Microsoft's compiler and its extra
>> "features", but regular compilers will complain:
>> error: invalid initialization of non-const reference of type 'T&' from an
>> rvalue of type 'T'
> Are you sure we're talking about the same thing? This looks like the kind
> of error that (A) or (B) would produce; would not (C) say something like
> invalid initialization of non-const reference of type 'T&' from type 'T&&'
> I swear I just tried a T& y = static_cast<T&&>(x) on gcc and finding it
> compiled fine.
I just tried to compile this program with g++ -std=c++0x -Wall -c test.cc
for versions of gcc: 4.4, 4.6, 4.7, and 4.9 and they all rejected it with
pretty much the same error message. I don't understand what the difference
can be with your tests :-(
And for the record, clang++'s error message:
error: non-const lvalue reference to type 'A' cannot bind to a temporary
of type 'A'
-- Marc Glisse
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk