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

AsyncTry-until condition should have to take its input by const reference

    XMLWordPrintable

    Details

      Description

      I was helping diagnose a confusing situation yesterday where someone had something like this:

      AsyncTry([] { return SomeMoveOnlyType(); })
          .until([] (StatusWith<SomeMoveOnlyType> swType) { 
              return false; 
          })
          .on(executor, CancelationToken::uncancelable());
      

      It fails to compile because the lambda passed to 'until' is called with an lvalue, so it tries to copy the move-only type and fails to. Furthermore, it has to pass it as an lvalue because it still needs to use it later, so moving it into the condition isn't an option.

      These compiler errors are kind of cryptic. If we added a static assertion to ensure that the condition passed to 'until' had to take a const ref, then we could avoid this situation by emitting an easy to diagnose compiler error.

        Attachments

          Activity

            People

            Assignee:
            backlog-server-servicearch Backlog - Service Architecture
            Reporter:
            matthew.saltz Matthew Saltz
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: