|
-
May 6th, 2008, 12:19 PM
#5
Re: String conversion
 Originally Posted by PredicateNormative
I'm not convinced.
As long as you're accessing through the iterator you're ok. Of course it will end up being a char* and of course the underlying buffer of the string is changed, you are changing the string. The only problem you have is when you change the underlying buffer outside of the string's interface. Here you are doing it through iterators, which are part of the interface and therefore safe.
The string class has an operator[] as part of it's interface. Do you also believe this is unsafe:
Code:
std::string greeting("Hello World");
greeting[0] = "J";
What about this:
Code:
greeting = "Goodbye";
Each of these things is just changing the string through its interface, and all are perfectly safe and acceptable.
Last edited by jlou; May 6th, 2008 at 12:22 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|