stl `bind` gotcha

Alec Jacobson

December 31, 2013

weblog/

I got burned again by naming a function in c++ bind and then while using the std namespace accidentally calling std::bind instead of my bind. The problem is that std::bind seems to be templated and defined so that it takes any number of any possible type of argument. Therefor it will always compile the arguments meant for my bind function.

One solution would be to avoid naming functions already taken by stl. Instead I'm just ensuring my function is found by calling it using the global namespace ::bind.