If I have a function that returns an STL container, do I get a copy of the entire contents of the standard container?
eg. It:
void Foo( std::vector< std::string >* string_list );
better than that:
std::vector< std::string > Foo();
It doesn't matter what is in the container? For example, it will return the container as follows:
struct buzz { int a; char b; float c; } std::map< int, buzz > Foo();
will be a more expensive operation than this:
std::map< int, int > Foo();
Thanks PaulH
Edit: This is with C ++ 03. The C ++ 0x solution is unfortunately unacceptable.
Edit2: I am using the Microsoft Visual Studio 2008 compiler.
Paulh source share