On Wednesday 29 April 2009 12:47:04 Joern Rennecke wrote:
Something which I miss in C++ is a way to declare that a function uses
an integral type to pass an enum value (in arguments or return value),
and then at function definition time only check that the integral type
is sufficently large to hold the enum, and then for type checking purposes
treat the parameter / return value as if it had been declared as this enum.

Esben Mose Hansen wrote:
This is exactly N2764, which should be part of C++0x --- at least it seems to be in the draft around p.149. But not part of gcc 4.4. unfortunately.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf

That is closely related, but it's not quite the same.
For a multi-targeted gcc, we'd want generic code to operate on
integral types that correspond to enum values defined by the
various targets - but these will define these enums differently.
If the generic code was in a library, and compilers for the
different targets were built separately, then N2764 would work.
However, when linking multiple targets together, enums with
the same name for different targets are different types, so
they can't all be the same type as the type used by the
generic code.
This is why I would like the generic code to use a separate type
which is assignment-compatible with any of these enums if the enums
definition is visible.

Reply via email to