westonpace commented on code in PR #33912:
URL: https://github.com/apache/arrow/pull/33912#discussion_r1091309848
##########
cpp/src/arrow/result.h:
##########
@@ -371,7 +371,7 @@ class [[nodiscard]] Result : public
util::EqualityComparable<Result<T>> {
if (ok()) {
Review Comment:
> Proof that it works as intended: https://godbolt.org/z/5c17zjG89
I'm a little confused. In this example I get:
```
function &:
copy
copy
function && (with std::move):
move
move
```
If I change to `G&&` I get:
```
function &:
function && (with std::move):
```
It seems the version without the moves (and especially without the copies)
would be preferred.
Also, if your generator is stateful (e.g. a generator object that returns
the next id in a sequence) then it would make a big difference if you use & or
&&.
I agree, in this case, it seems rather unlikely that someone is going to be
passing in a stateful (or complex to copy, can't be inlined) generator.
Still, I don't think there is any penalty to the &&. And the standard [does
sometimes pass functions by forwarding
reference](https://en.cppreference.com/w/cpp/utility/functional/invoke).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]