apache / apache/arrow

[C++] rvalue lhs cannot be moved into returned value in Status::operator&

Open
#34,001 1 comment 0 reactions 1 assignee Claimed by @PragmaTwice View on GitHub
Component: C++ Type: enhancement
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.