Why operator= returns reference not const reference
Posted
by outmind
on Stack Overflow
See other posts from Stack Overflow
or by outmind
Published on 2010-06-03T20:09:18Z
Indexed on
2010/06/03
20:14 UTC
Read the original article
Hit count: 165
c++
The original question is related to overloading operator= and I like to share my findings as it was nontrivial for me to find them. I cannot imagine reasonable example to use (a=b) as lvalue. With the help of IRC and google I've found the next article: http://msdn.microsoft.com/en-us/magazine/cc301415.aspx
it provides two examples.
(a=b)=c
f(T& );
f(a=b)
but both a bit not good, as first violate associativity and I believe that it is bad practice. The second one give me the same feeling. Could you provide more good examples why it should be non constant?
© Stack Overflow or respective owner