• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: strange looking ambiguity with type cast
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: strange looking ambiguity with type cast
      • From: jean-françois gauthier <email@hidden>
References: 
 >strange looking ambiguity with type cast (From: jean-françois gauthier <email@hidden>)
 >Re: strange looking ambiguity with type cast (From: GoochRules! <email@hidden>)
 >Re: strange looking ambiguity with type cast (From: jean-françois gauthier <email@hidden>)
 >Re: strange looking ambiguity with type cast (From: GoochRules! <email@hidden>)
 >Re: strange looking ambiguity with type cast (From: jean-françois gauthier <email@hidden>)

  • Prev by Date: Using Project References
  • Next by Date: How to create folders in xcode builds?
  • Previous by thread: Re: strange looking ambiguity with type cast
  • Next by thread: Re: strange looking ambiguity with type cast
  • Index(es):
    • Date
    • Thread