Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-06-19 16:16:17


Michael Marcin wrote:
> I have a windows compiler that is a derivative of cw 9.4 that is
> complaining when trying to compile the following
>
>
> #include <boost/bind.hpp>
>
> struct a
> {
> void foo(int) {}
> void foo() {}
> };
>
> void bar()
> {
> boost::bind( &a::foo, _1 );
> }

...

> Changing the definition to
>
> struct a
> {
> void foo() {}
> void foo(int) {}
> };
>
> lets it compile but this is not a general solution as this fails to
> compile:
> void bar()
> {
> boost::bind( &a::foo, _1, 0 );
> }

Sounds like a compiler bug.

boost::bind tries to do its best to resolve ambiguous overloads, but this is
not possible in general, even without compiler limitations getting in the
way. You'd need to pick the right overload manually:

void bar()
{
   void (a::*pmf)( int ) = &a::foo;
   boost::bind( pmf, _1, 0 );
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net