79502572

Date: 2025-03-12 03:24:22
Score: 0.5
Natty:
Report link

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.

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: 許恩嘉