Re: Understanting assignments
On 8/25/2010 3:52 PM, Christian Hackl wrote:
Pete Becker ha scritto:
Oh, I see: this is the = instead of == typo. Easily caught by unit tests.
If it's a library used by someone else, then your own unit tests cannot
catch the typo.
I'm quite surprised that such a harmless [*] hint, backed by a
recommendation in of the most recommended C++ books, would cause so much
discussion on the grounds that it's not important enough :)
[*] except of the problem with move semantics, which I had not been
aware of before
When I encounter code
SomeType const function(arguments...);
then the first thing that springs into my mind is, "it's a typo and the
implementor forgot to add either * or & before the function name..." It
is idiomatic to see
SomeType function(arguments...);
or
SomeType const& function(arguments...);
The recommendations to write anything different require (in my book
anyway) that the reason better be important. Harmless hint? No, it's a
step away from very common idioms, you see.
V
--
I do not respond to top-posted replies, please don't ask