Motivation:
I have a function
func(const string& s);
{
//...
}
of course this wont work:
func("hello" + " " + "world");
this solves that problem:
func(string&& s);
Is there a way to write func so that it automagically works with both r-value refs and l-value refs?
Rvalues bind to const lvalue refs with no problem. The problem with your code lies in types. You need at least one
std::stringfor the overloaded operator+ to be used.