C++98’s function binders, bind1st
and bind2nd
, were superseded in capabilities by Boost’s introduction of bind
in 2001. Boost.Bind was the basis for TR1’s bind
, and that was the basis for C++11’s bind
. But C++11 has lambda expressions, and lambdas can do much of what bind
does, plus more. In addition, lambdas avoid bind
idiosyncrasies such as prefix notation and the use of placeholders like _1
and _2
. Alas, there are things that C++11’s bind
can do that lambdas can’t do, so the need for bind
lives on. C++14, however, further strengthens lambdas, and I believe the time has finally come to bury bind
.
This talk compares lambdas and bind
, in both C++11 and C++14, in the areas of readability, expressiveness, and efficiency. My conclusion is that once C++14 lambda support becomes available, there’s no case to be made for bind
.
Scott