[C++] rvalue lhs cannot be moved into returned value in Status::operator&
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 91
Description
### Describe the enhancement requested
https://github.com/apache/arrow/blob/a0d0ecee71b99b45f2c1b269c70033d39b982d00/cpp/src/arrow/status.h#L160-L161
Currently there are two overloads for `Status::operator&` to achieve "reference forwarding", but only for the rhs (i.e. `const Status& s` or `Status&& s`), the reference type of lhs value (i.e. `*this`) cannot be forwarded. e.g.
```c++
Status v = ...;
Status f(/* some parameters */);
Status g(/* some parameters */);
auto v1 = v & f(); // OK! the rhs rvalue can be moved into result
auto v2 = f() & v; // Ooops, the lhs rvalue cannot be moved into result
auto v3 = f() & g(); // Ooops, same as above
```
We can add more overloads to forward reference of lhs for better performance.
### Component(s)
C++
Contributor guide
Assessment
This issue has not been assessed yet.