[pooma-dev] enums vs. static data members
James Crotinger
JimC at proximation.com
Fri Mar 23 21:15:07 UTC 2001
Not sure if this reply will work as outgoing mail has been problematic here
in the past, but I'll give it a try...
I hate using these enums because different compilers seem to
treat them differently. An alternative would be to define a
static bool "wildcard" in these classes, set it to "true" or "false",
and then pass that as the template argument. But as I recall,
there was some problem with the Metrowerks compiler that
made this not a viable option.
I guess I'd be surprised if Metrowerks had a problem with this - we use
exactly this sort of thing in ElementProperties. Moreover...
I guess I am wondering if that
problem still exists or whether it would be OK to overhaul
the Domain classes to use static data types instead of enums.
The one drawback to this approach that I see is you have to
add some compiled source file that initializes these static
variables. You can't just stick this in the class definition.
Yes you can. The compilers we're using have supported this for quite some
time. You just say:
template <class T>
struct Foo
{
static const bool wildcard = true;
};
On the other hand, if you think the aCC compiler is full of
it and there is nothing at all wrong with this code in the
Domain sources, please let me know that, too.
Whether aCC is full of it or not, I like the "static const" traits better
than enums. I was astonished recently when I tried this with VC++ and was
told that only virtual functions could be made abstract, and beside, you
could only use the value "0" in declaring an pure virtual function. But VC++
isn't a target here and I think everyone else does this right.
Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/pooma-dev/attachments/20010323/500dafb1/attachment.html>
More information about the pooma-dev
mailing list