[SERVER-47825] Use std::bind only when necessary (roughly never) Created: 28/Apr/20  Updated: 29/Oct/23  Resolved: 28/Apr/20

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.7.0

Type: Improvement Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-32070 Remove stdx::bind (and others from fu... Closed
Backwards Compatibility: Fully Compatible
Sprint: Service arch 2020-05-04
Participants:

 Description   

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.



 Comments   
Comment by Githook User [ 28/Apr/20 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-47825 convert std::bind -> lambda
Branch: master
https://github.com/mongodb/mongo/commit/03b43254df01f55db7be795c1c41725016f68245

Comment by Billy Donahue [ 28/Apr/20 ]

CR http://mongodbcr.appspot.com/595870002

Generated at Thu Feb 08 05:15:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.