js8544 opened a new issue, #33607:
URL: https://github.com/apache/arrow/issues/33607
### Describe the enhancement requested
Sometimes we need extra arguments for the `Visit` function, 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:
```cpp
class ExampleVisitor {
public:
template <typename T>
Status Visit(const T& arr) {
/// Do stuff and save result to output_;
return Status::OK();
}
std::shared_ptr<Array> GetOutput() { return output_; }
private:
std::shared_ptr<Array> output_;
};
ExampleVisitor visitor;
RETURN_NOT_OK(VisitArrayInline(*arr, &visitor));
*output = visitor.GetOutput();
```
It will be more convenient to write a Visitor if the VisitArrayInline
function supports additional args for the `Visit` method:
```cpp
class ExampleVisitorWithArg {
public:
template <typename T>
Status Visit(const T& arr, std::shared_ptr<Array>* output) {
/// Do stuff and save result to output directly;
return Status::OK();
}
};
ExampleVisitorWithArg visitor;
RETURN_NOT_OK(VisitArrayInline(*arr, &visitor, &output));
```
### Component(s)
C++
--
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]