(c++11) Why can std::bind be used without the std namespace prefix?

Michael Haubenwallner michael.haubenwallner@ssi-schaefer.com
Thu May 16 15:15:00 GMT 2019


Hi,

it turns out that the std::bind template (since C++11) can be used
without the std:: namespace prefix ('ve tried 4.8.4, 8.3.0, 9.1.0).

But why?

That is, I fail to see how 'bind' can resolve to '::std::bind'
in this example, where one would expect a compilation failure:

#include <functional>
struct Object {
   int get42() { return 42; }
};
int doGet42(Object * o)
{
  return bind(&Object::get42, ::std::placeholders::_1)(o);
}

However, using '::bind' does fail as expected.

Thanks!
/haubi/



More information about the Gcc-help mailing list