Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-37360

Make `StatusWith` accept types with implicit conversion semantics.

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.4
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • Service Arch 2018-10-08

      Use the enable-if for non-explicit constructors trick that `std::optional` uses to make `std::optional< std::unique_ptr< Base > >` accept `std::unique_ptr< Derived >` implicitly.

      This will permit things like this, among others:

      ```
      StatusWith< boost::optional< std::unique_ptr< Base > > >
      function()

      {   if( condition1() ) return boost::none;   if( condition2() ) return std::make_unique< Derived >();   if( condition3() ) return nullptr;   return Status( ErrorCodes::SomethingFailed, "Something is broken" ); }

      ```

            Assignee:
            adam.martin@mongodb.com ADAM Martin (Inactive)
            Reporter:
            adam.martin@mongodb.com ADAM Martin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: