Re: std:string assignments
Erik wrote:
I'd like to move to nicer strings. In order to keep platform/compiler
independence I consider std:string as the replacement. While googling
I managed to read some warnings about std:string not being thread safe
AFAIK, none of standard classes are. C++ has no concept of 'thread'.
As to any particular implementation, you would have to ask in another
newsgroup, the one dedicated to that implementation.
(any shared memory is not without a lock, is it?). I wonder about
assignment - does it copy the buffer or the pointer?
Unknown. Implemenation-specific.
I managed to find
only one document which explicitly warned about
"implementation-specific issues" where any reference to the memory
makes the buffer unique. Any other problems on moderns compilers?
Plenty. What exactly are you interested in?
I checked the following assignment on Borland C++ Builder:
string s1 = "abc";
string s2 = s1;
cerr << (int)s1.c_str() << ' ' << (int)s2.c_str();
s1.c_str() and s2.c_str() show different addresses. I wonder whether
the assignment or c_str() copied the buffer.
Ask in 'borland.public.cppbuilder.language'.
If I return a string from a function, would it return a pointer or
would copy the buffer (copy constructor).
It would return an object. The object would be a temporary created
using copy semantics (copy-constructed).
Should I abandon my own string buffer at all knowing it works?
Use what works.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask