Boost logo

Boost Users :

From: Stephen Hewitt (shewitt.au_at_[hidden])
Date: 2006-08-08 08:27:39


I find the C++ standard a bit like reading a legal document (and I'm no lawyer)
but the following is from ISO 14882:

3.10/5:
 "The result of calling a function that does not return a reference is an
rvalue. User defined operators are functions, and whether such operators expect
or yield lvalues is determined by their parameter and return types."

8.5.3/5 (extract):
 "Otherwise, the reference shall be a non-volatile const type (i.e., cvl shall
be const)."

8.5.3/5 is a little complicated however and I've only quoted a small portion of
it; some careful reading is probably in order. The behaviour you seem to be
referring to when you say, "the compiler writer has the option of using a copy
operation to implement it", is a sub-point of the point in my quote and thus I
think it only applies if the reference is const. Again I feel I need to point
out that I found this part of the standard more than a little confusing. There
are a number of places in the standard which refer to the binding of non-const
references to temporaries and refer to it as an error.

 
I find further evidence for my assertion in the following links:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1690.html -
The whole purpose of this proposal is to address the fact that rvalues can not
be bound to non-const references.

http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm -
Describes the "Forwarding Problem".

 

Regards,

 Steve

PS: Sorry if this is a re-post but I had a little trouble figuring out how to
reply.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net