Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-7086

[C++] Provide a wrapper for invoking factories to produce a Result

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 0.15.1
    • 0.16.0
    • C++
    • None

    Description

      There is a proliferation of code like:

      Result<int> SafeAdd(int a, int b) {
        int out;
        RETURN_NOT_OK(SafeAdd(a, b, &out));
        return out;
      }
      

      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:

      Result<int> SafeAdd(int a, int b) {
        return RESULT_INVOKE(SafeAdd, a, b);
      }
      

      This will probably have to be a macro; otherwise the return type can be inferred but only when the function is not overloaded

      Attachments

        Activity

          People

            bkietz Ben Kietzman
            bkietz Ben Kietzman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: