Re: Understanting assignments
On 8/25/2010 4:48 PM, ?? Tiib wrote:
On 25 aug, 22:52, Christian Hackl<ha...@sbox.tugraz.at> 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
Sorry, i do not care really about issue itself, up to designer of
interface and its contract IMO. Just particular detail makes me
wonder... how does it compile? for example:
Matrix a, b, c;
if ( ( a * b ) = c )
{
// blah-blah
}
It should say you cannot convert a Matrix to bool. Or is there some
safe bool? What does it indicate? if ( a ) sounds similarily
nonsensical about Matrix.
Somebody might design the class that calculates some kind of
characteristic of the matrix to be used in shortcuts like those. I am
not advocating it, but don't dismiss it simply because you're not going
to use it. Correctness of the interface is in the eye of the beholder.
Of course, just like with other things, implicit conversions are
dangerous and better avoided, blah blah... All falls into the style
category, as far as I'm concerned.
V
--
I do not respond to top-posted replies, please don't ask