• 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: David Dunham <email@hidden>
  • Date: Fri, 23 Jun 2006 11:33:21 -0700


On 23 Jun 2006, at 10:33, 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?

My guess is: why does this take char, but return wchar_t? Could you add const char& operator[]( long index ) const;

------------
David Dunham email@hidden http://www.pensee.com/dunham/
"No matter how far you have gone on a wrong road, turn back." - Turkish proverb


_______________________________________________
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: Guard Malloc not working
  • Previous by thread: Re: Ambiguous conversions
  • Next by thread: XCode not universal binary yet?
  • Index(es):
    • Date
    • Thread