You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C++] Support optional additional arguments for inline visit functions #33607
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:
classExampleVisitor {
public:template <typename T>
Status Visit(const T& arr) {
/// Do stuff and save result to output_;returnStatus::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:
classExampleVisitorWithArg {
public:template <typename T>
Status Visit(const T& arr, std::shared_ptr<Array>* output) {
/// Do stuff and save result to output directly;returnStatus::OK();
}
};
ExampleVisitorWithArg visitor;
RETURN_NOT_OK(VisitArrayInline(*arr, &visitor, &output));
Activity
apacheGH-33607: [C++] Support optional additional arguments for inlin…
GH-33607: [C++] Support optional additional arguments for inline visi…
pitrou commentedon Jan 16, 2023
Issue resolved by pull request 33608
#33608