Re: strange looking ambiguity with type cast
Re: strange looking ambiguity with type cast
- Subject: Re: strange looking ambiguity with type cast
- From: GoochRules! <email@hidden>
- Date: Wed, 11 Feb 2004 17:08:51 -0700
On Feb 11, 2004, at 3:13 PM, jean-frangois gauthier wrote:
a couple of points about this.
i dont think that the conversion method returns a reference; if it
did, then calling _b. operator a () would fail to compile as well.
uh... why? As I know it, it is generally good practice to return/pass
references (except to local object, of course -- which we don't have in
this case) to avoid a spurious copy constructor call for the temporary.
moreover, commenting out the declaration for the other conversion
operator (operator int ()), the code compiles fine. so im starting to
think that its a bug in gcc. the reason im worrying about this at
all is that id rather not modify loads of code just for xcode-gcc if
im not sure why im doing it.
Point well taken, but until another argument is presented, I'd say its
a bug in your other compilers (or at least, another way of interpreting
the standard, but I'd say one way or another its a bug somewhere).
Another thing to try is to declare a::a(int) as 'explicit' (class a {
explicit a(int); ... };). This might implicitly force b:operator a()
to be called rather than b:operator int(), thus removing the
ambiguousness.
I think the real issue is what you **WANT** to happen -- do you want an
'a' created from an int or from a 'b'?
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.