You can't pass a temporary value to a non-const reference T&
.
If you can't use a constant reference const T&
because you need T
to be modifiable, then you can simply add an overload that passes by value:
void bar(Foo& f);
void bar(Foo f){
bar(f);
}
Then let copy elision do its thing.