|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - enum: integral promotions
#include <stdio.h>
struct A
{
void f(int a)
{
printf("f(int)\n");
}
void f(unsigned int a)
{
printf("f(unsigned int)\n");
}
void f(long a)
{
printf("f(long)\n");
}
};
int main()
{
A a;
enum SignedEnum
{
SENUM_1 = 0,
SENUM_2 = 1
};
enum UnsignedEnum
{
UENUM_1 = 0,
UENUM_2 = 0x80000000
};
a.f(SENUM_1);
// Error: ambiguous reference to symbol
// Had: A::f(int )
// and: A::f(long )
a.f(SENUM_2);
// Error: ambiguous reference to symbol
// Had: A::f(int )
// and: A::f(long )
a.f(UENUM_1);
// Error: ambiguous reference to symbol
// Had: A::f(int )
// and: A::f(long )
a.f(UENUM_2);
// Error: ambiguous reference to symbol
// Had: A::f(int )
// and: A::f(long )
return 0;
}
The expected output is:
f(int)
f(int)
f(unsigned int)
f(unsigned int)
See 4.5 Integral promotions [conv.prom], paragraph 2.
It's low priority - just a bit annoying when using IOStreams and enums.
bye, Christof
--
http://cmeerw.org JID: cmeerw jabber.at
mailto cmeerw at web.de
...and what have you contributed to the Net?
Mar 23 2003
|