After programming in C++ for about 4/5ths of the time that it has been in existence, you would think I would stop making this mistake:
extern int foo(std::string &); . . . void bar (void) { string s, t; . . . int i = foo(s + t); }
The mistake, of course, is that a non-const reference (whether a formal parameter or not) cannot be bound to a temporary object, nor any other rvalue. On a fifty-fifty cocktail of intant-rewrite-in-a-can and Homer-Simpson-doh, I hastily rearrange to the code to say:
void bar (void) { string s, t, st; . . . st = s + t; int i = foo(st); }
No longer. Instead, the signature of foo() can be rephrased as:
extern int foo(std::string &&);
which will allow foo to bind to the temporary created by concatenating s and t.