[QUOTE="BartC"]\nEither it makes a copy of the contents of a string, or it doesn't. If not,\nthen it doesn't do the same thing as the following C code. If it does copy,\nand is still nearly as fast as returning a pointer, then how does it do\nthat?[/QUOTE]\n\nReturn value optimisation (RVO). The copy goes directly into the return\nvalue location to avoid creating (and copying) a temporary object. This\nhandy little compiler trick makes returning non-trivial objects from\nfunctions efficient.