In article <11**********************@f14g2000cwb.googlegroups .com>,
puzzlecracker <ir*********@gmail.com> wrote:
is it possible to call nonconst member function on an unnamed temprary?
ex:
class String{
public:
void doSomething();
};
String createString();
createString().doSomething();
is it ok?
Yes.
Section 3.10 paragraph 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.
Section 3.10 paragraph 10:
An lvalue for an object is necessary in order to modify the object
except that an rvalue of class type can also be used to modify its
referent under certain circumstances. [Example: a member function
called for an object (9.3) can modify the object.]
(Section 9.3 refers to member functions.)
--
Mark Ping
em****@soda.CSUA.Berkeley.EDU