This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Problem with overloaded function selection
- From: bjorn rohde jensen <bjensen at fastmail dot fm>
- To: Andrey Pozdeev <AndreyPozdeev at rambler dot ru>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 12 Aug 2002 16:01:35 +0200
- Subject: Re: Problem with overloaded function selection
- References: <3D578A07.AA20189@mb1.rambler.ru>
- Reply-to: bjensen at fastmail dot fm
Hi Andrey,
The conversions
> operator double() {return 0L;};
> operator int() { return 0; };
are equally poor, as one level of user defined
conversions and one level of default conversions
are required to match
> void test(char){};
Having both conversions causes neither to be
considered, which means that
> operator A() { return A();};
is the only choice.
Removing either of
> operator double() {return 0L;};
> operator int() { return 0; };
makes the call
> test(b);
ambiguous, since
> void test(char){};
is a candidate through one level of user defined
conversions and one level of default conversions
and
> void test(A){};
is a candidate through one level of user defined
conversions.
I guess, one will have to look in the specs to
see, who is right in this matter. My gut feeling
is, that it gcc is right. Conversions and function
overloading seem pretty othogonal to me. Why should
two conversions be worse than one conversion in matching
an overloaded function??
Yours sincerely,
Bjorn