Re: Libstdc++ problems
Re: Libstdc++ problems
- Subject: Re: Libstdc++ problems
- From: "E. Wing" <email@hidden>
- Date: Mon, 26 Feb 2007 12:13:25 -0800
I'm not sure I fully understand your description, but some things alarm me.
First, c_str() is supposed to return the 'C' string representation of
your std::string. I don't think you are supposed to make any
assumptions about its address because you cannot make any assumptions
about how the std::string is stored. The C++ library implementation
can implement a string any way it wants and you expected to treat is
as a black box. It might use '\0' terminators, it might not. For all
you know, it might store all the characters backwards or has some
convoluted system of storing characters in ascii order and uses maps
and indexes to reorder things on the fly.
Second, c_str() returns const char*, not char*. This means you
shouldn't be trying to modify it. If you're trying to modify const
data, you're asking for trouble. If you're trying to set a std::string
by directly manipulating it's char* representation, you will probably
fail. If you do succeed, I wouldn't expect it to be portable.
What kind of exceptions are you getting with substr and replace? Are
they out of range exceptions? They are supposed to throw those if you
specify an invalid range. And maybe you broke things by doing the bad
things mentioned above.
-Eric
_______________________________________________
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