Removing Old functional Stuff

In this lessons we will look at some removeed functions.

Functions like bind1st()/bind2nd()/mem_fun(), … were introduced in the C++98-era and are not needed now as you can apply a lambda. What’s more, the functions were not updated to handle perfect forwarding, decltype and other techniques from C++11. Thus it’s best not to use them in modern code.

Removed functions:

  • unary_function()/pointer_to_unary_function()
  • binary_function()/pointer_to_binary_function()
  • bind1st()/binder1st
  • bind2nd()/binder2nd
  • ptr_fun()
  • mem_fun()
  • mem_fun_ref()

For example to replace bind1st/bind2nd you can use lambdas or std::bind (available since C++11) or std::bind_front that should be available since C++20.

Get hands-on with 1200+ tech skills courses.