
Liu Jin <cpp <at> vip.163.com> writes:
"Jim" == Jim Hyslop <jhyslop <at> dreampossible.ca> writes: [...] > I find a statement like 'ar & member1;' to be very > non-intuitive: how does bitwise-and relate to serialization?
> It seems to me that most sensible code guidelines admonish > against this kind of operator abuse (pardon my bluntness, but > that's what it is when you get down to it).
Then how does bitwise-shift relate to I/O (iostream), or arithmetic addition relate to string concatenation (string),
or modulo relate to formating strings (boost.format)? I haven't looked at Boost.format, but I suspect it's adopted from the well-known
I was waiting for someone to bring these up. They don't. The aforementioned coding guidelines often use these two overloads as prime examples of how *NOT* to overload operators. But, they have been in the language for so long that they are now part of the language's idiom. However, that does not make it "right" to perpetuate further operator overloads (note: I have not yet read Robert's reply in which he outlines the rationale behind the operator). printf formatter.
What's wrong when two irrelevant domains accidentally choose the same notation?
Let me turn this back at you: what's wrong with using a word instead of a symbol? Sure, using a symbol may save a few keystrokes of typing. But, code is _read_ far more often than it is written, so the few seconds you save in typing are more than offset by the several seconds' confusion experienced by each and every programmer the first time they see this new and unusual usage (my first thought, actually, was that it was a declaration, then I thought "address-of", and then finally clicked in to operator overloading). -- Jim