Errrrm, that breaks <ctype> you know (Re: C question for you old guys ;-))
Errrrm, that breaks <ctype> you know (Re: C question for you old guys ;-))
- Subject: Errrrm, that breaks <ctype> you know (Re: C question for you old guys ;-))
- From: Alex Curylo <email@hidden>
- Date: Wed, 11 Jun 2003 11:56:09 -0700
on 6/11/03 10:29 AM, email@hidden at
email@hidden wrote:
>
> #define and &&
>
> #define or ||
>
#define not !
Ah, those are standard C++. See C.3.1 of your "C++ Programming Language".
>
> #define is ==
This, on the other hand, is unquestionably a programming error, at least in
the not-so-uncommon case of wishing to use the standard C++ language.
Let us consider the space counting function
static int count_spaces(const string& s, const locale& loc)
{
const ctype<char>& ct = use_facet<ctype<char>>(loc);
int i = 0;
for (string::const_iterator p = s.begin(); p != s.end(); ++p)
if (ct.is(ctype_base::space, *p)) ++i;
return i;
}
Now let us apply the #define in question to this code.
Error : identifier expected
UQuesa.cpp line 154 ==
Er, whoops!
So, although the general theory of mangling "==" may perchance be valid for
some people (although only those too incompetent to read the warnings the
compiler gives them, it seems to me) this particular mangulation, "is",
breaks standard C++ from <ctype> which appears to me at least to be a rather
conclusive argument against doing so. IMHO, YMMV, yadayadayada.
--
Alex Curylo -- email@hidden --
http://www.alexcurylo.com/
"We used to hate people; now we just make fun of them.
It's more effective that way." -- 'Dogma', KMFDM
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.