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

Use std::bind only when necessary (roughly never)

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.7.0
    • Affects Version/s: None
    • Component/s: Internal Code
    • None
    • Fully Compatible
    • Service arch 2020-05-04

      std::bind has some special behavior that can kick in at surprising times.

      1. It has a special case interaction with std::reference_wrapper.
      2. It has a special case interaction when bind expressions are bound to each other.
      3. It can silently ignore trailing arguments.

      An analysis of the problems here: https://abseil.io/tips/108

      Unless you need behaviors 1 or 2, you're better off with a polymorphic lambda.

      Replace std::bind in all other cases (only 2 files), so we don't get used to seeing it in the codebase. A previous sweep (SERVER-32070) eliminated previous calls.

            Assignee:
            billy.donahue@mongodb.com Billy Donahue
            Reporter:
            billy.donahue@mongodb.com Billy Donahue
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: