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

Make `StatusWith` accept types with implicit conversion semantics.

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.1.4
    • Component/s: None
    • Labels:
      None

      Description

      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" ); }

      ```

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: