Karol Szkudlarek <karol@mikronika.com.pl> writes:
Eljay Love-Jensen wrote:
Hi Karo,
Add this to your class A:
int foo(Items const&)
{
std::cerr << "A::Items\n";
return 0;
}
HTH,
--Eljay
Hi!
I can't use you solution in my code because in real example I have
little different sitiuation.
In my second test case I try to explain more precisely my real
case. Look at the following code:
// SECOND_CASE
typedef int my_int;
class ALibraryClass
{
public:
int foo(const my_int&)
{
return 0;
}
int foo(const bool&)
{
return 0;
}
};
class BClientClass
{
public:
enum Items
{
item1=1000,
item2=2000
};
void test()
{
ALibraryClass a;
a.foo(BClientClass::item1);
This should select A::foo(const my_int&) unambigously; enum to int is
a promotion (see 4.5) while enum to bool is a conversion (4.12)
and a promotion is a better match than conversion, (13.3.3.2/4).
}
};
int main()
{
BClientClass b;
b.test();
return 0;
}
In class ALibraryClass I can't define int foo(Items const&)
because I know nothing about enum Items from client class BClientClass.
Generally I would like to know why this program compiles fine (gcc 3.3.3)
under Debian but does not compile under Suse (gcc 3.3.3). Is it possible
such a difference in compiling results with the same versions of
compiler?
You aren't really using the same compiler versions. For reasons known
only to those who build distros, nearly every linux distro (and
each BSD too!) maintains its own set of patches for gcc; what
SUSE calls GCC 3.3.3 is actually a SUSE-special derivative of FSF
GCC 3.3.3, what debian calls GCC 3.3.3 is a debian-special
derivative of FSF GCC 3.3.3, and they are not really the same -
only mostly the same. Most of the time, you won't run into the
differences, but sometimes ...
FWIW, FSF GCC 3.3.3 and 3.4 like it, FBSD GCC 2.95.3 and 3.3.3 like
it, and slackware-9.0 GCC 3.2.2 like it. I think you should report
a bug to SUSE.