Skip to content

Instantly share code, notes, and snippets.

@foobit
Created February 28, 2014 00:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foobit/9262501 to your computer and use it in GitHub Desktop.
Save foobit/9262501 to your computer and use it in GitHub Desktop.
std::vector<std::string>
sorted(std::vector<std::string> names)
{
std::sort(names);
return names;
}
// names is an lvalue; a copy is required so we don't modify names
std::vector<std::string> sorted_names1 = sorted( names );
// get_names() is an rvalue expression; we can omit the copy!
std::vector<std::string> sorted_names2 = sorted( get_names() );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment