Assignment operators

Web Site  Methods

 
Str::operator =
 

const Str& operator=(const Str& source)
const Str& operator=(const STRACHAR* s)

Copy the value of source into the string object, replacing any previous data there.

Copying one Str object to another is a very fast operation (see  instance sharing); copying a C string involves that the actual data bytes be copied. The exception is when using the library in a thread-safe environment and copying a Str instance created on one thread into another; this will cause full copy (no reference counting is involved).  This further reduces the potential of difficult-to-find bugs in multithreaded programs writing to strings on different threads.

If using the STRACHAR version in a Unicode build, a conversion will automatically occur at runtime.  To prevent this, use the STRWCHAR assignment instead.  The compiler will automatically choose the proper overload depending on your source string datatype.

 
 
Str::operator =
 

const Str& operator=(const STRWCHAR* s)

Available only on platforms supporting Unicode

const Str& operator=(const CString& s)

Only available when compiling an MFC project

Copy the value of source into the string object, replacing any previous data there.  If using the STRWCHAR version in an ANSI build, a conversion will automatically occur at runtime.

 

See also: Constructors & utility