• 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: Ambiguous conversions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ambiguous conversions


  • Subject: Re: Ambiguous conversions
  • From: Adin Hunter Baber <email@hidden>
  • Date: Fri, 23 Jun 2006 13:30:06 -0500


On 2006 Jun 23, at 12:33 PM, Mark Wagner wrote:

It's not the constant that's the problem. Here's a code sample that demonstrates what's going on:

class MString
{
	public:
	        MString( const char* str , long length );

		operator const char*( void ) const;
		operator const wchar_t* (void ) const;
		operator const unsigned char*( void ) const;
	        const wchar_t&    operator[]( long index ) const;
};

int main(void)
{
	MString str("test", 5);
	return str[2];         // <-- Error occurs here
}

Is there any way to fix this, preferably without removing the
typecasts from the class, and without changing the 1,800 lines of code
where the error is occuring?  Say, with a minor tweak to the class, or
by telling the compiler to go back to its old behavior?


I ran into this problem recently. The only way I found to solve it was by making the parameter for operator [] an int.



Adin Hunter Baber email@hidden

"Theory and practice are the same in theory, but different in practice."


_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Ambiguous conversions (From: "Mark Wagner" <email@hidden>)
 >Re: Ambiguous conversions (From: Laurence Harris <email@hidden>)
 >Re: Ambiguous conversions (From: "Mark Wagner" <email@hidden>)

  • Prev by Date: RE: Ambiguous conversions
  • Next by Date: Re: Ambiguous conversions
  • Previous by thread: Re: Ambiguous conversions
  • Next by thread: Re: Ambiguous conversions
  • Index(es):
    • Date
    • Thread