Schalk_Cronje@McAfee.com wrote:
I wonder why gcc is able to compile it. :-)
Well considering that the following also yields different results on MSVC7.1 and gcc 3.2/3.3 I would wonder if there is a problem with one of the compilers
#include <iostream> #include
struct X { void f() {std::cout << "None" << std::endl;} void f() const {std::cout << "const" << std::endl;} };
[...]
int main() { X x; boost::bind(&X::f, _1)(x); }
&X::f is ambiguous in boost::bind(&X::f, _1). boost::bind can't figure out which one you want, so it picks one at random. The example is actually similar to the one below; your "run" overloads accept an object and can be ordered, but the bind expression does not. boost::mem_fn(&X::f) is similarly ambiguous. #include <iostream> struct X { void f() {} void f() const {} }; template <class T> void mem_fn( void (T::*f_)() ) { std::cout << "None" << std::endl; } template <class T> void mem_fn( void (T::*f_)() const ) { std::cout << "const" << std::endl; } int main() { mem_fn(&X::f); }