Repository navigation
GH-33607: [C++] Support optional additional arguments for inline visit functions - #33608
Conversation
…e visit functions
|
|
| internal::checked_cast<const typename TypeTraits<TYPE_CLASS##Type>::ArrayType&>( \ | ||
| array)); | ||
| array), \ | ||
| args...); |
There was a problem hiding this comment.
Wouldn't it be better to use something like std::forward<decltype(args)>?
There was a problem hiding this comment.
Definitely! Changed to std::forward
|
Ok, is it possible to exploit this new possibility in some select places? It will validate that it works and also show the benefits. (you can of course grep through the codebase to find candidates) |
| break; | ||
| } | ||
| return std::forward<VISITOR>(visitor)(type); | ||
| return std::forward<VISITOR>(visitor)(type, args...); |
There was a problem hiding this comment.
Should forward here and below as well.
Good point. I've applied the new |
|
Benchmark runs are scheduled for baseline = 4d9228f and contender = 4b48ecc. 4b48ecc is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Related issue number -------------------- See also: - Homebrew/homebrew-core#129859 - apache/arrow#33608 - apache/arrow#33641 Signed-off-by: Tao He <[email protected]>
Which issue does this PR close?
Closes #33607
Rationale for this change
Sometimes we need extra arguments for the
Visitfunction, the most common of which is output parameters to save the result. For now, we need to have a member variable and a member function to get the result:It will be more convenient to write a Visitor if the VisitArrayInline function supports additional args for the
Visitmethod:Are these changes tested?
Not sure if we need to explicitly test this feature, since no runtime behavior is changed. The existing tests all pass.
Are there any user-facing changes?
There is a small chance, like in diff.cc:402,
VisitTypeInlineis declared as a friend function. The declaration needs to be changed. But I am not sure if any outside user would do this.