[ https://issues.apache.org/jira/browse/ARROW-7086?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16975912#comment-16975912 ]
Micah Kornfield commented on ARROW-7086: ---------------------------------------- This seems like potentially the wrong direction to encourage implementations. I think we should provide the real implementation in the Result<> function and if necessary provide a macro to replace the output value function. e.g. the boiler plate if we want to eliminate it should be: {{Status SafeAdd(a, b, int* out) {}}{{ }} {{ ASSIGN_OR_RETURN(auto out, SafeAdd(a, b));}} {{ return Status::OK(); }} It seems like this could be accomplished with template magic but might be OK just as is (or with a template). > [C++] Provide a wrapper for invoking factories to produce a Result > ------------------------------------------------------------------ > > Key: ARROW-7086 > URL: https://issues.apache.org/jira/browse/ARROW-7086 > Project: Apache Arrow > Issue Type: Improvement > Components: C++ > Affects Versions: 0.15.1 > Reporter: Ben Kietzman > Assignee: Ben Kietzman > Priority: Major > Fix For: 1.0.0 > > > There is a proliferation of code like: > {code} > Result<int> SafeAdd(int a, int b) { > int out; > RETURN_NOT_OK(SafeAdd(a, b, &out)); > return out; > } > {code} > Ideally, this should be resolved by moving the implementation of SafeAdd into > the Result returning overload then using {{Result::Value}} in the Status > returning function. In cases where this is inconvenient, it'd be helpful to > have an adapter for doing this more efficiently: > {code} > Result<int> SafeAdd(int a, int b) { > return RESULT_INVOKE(SafeAdd, a, b); > } > {code} > This will probably have to be a macro; otherwise the return type can be > inferred but only when the function is not overloaded -- This message was sent by Atlassian Jira (v8.3.4#803005)