Boost logo

Boost Users :

From: Andre Hentz (ahentz_at_[hidden])
Date: 2002-11-28 09:41:59


I've just encountered this problem and it looks like a MS bug. Not sure it
deserves a Boost workaround but I thought it would be nice to let you know
(in case you don't already).

Here's the code:

#include <boost/bind.hpp>
namespace A{
        struct c{
                void setName(const char*) {}
        };
}
namespace B{
        struct c{
                void setName(const char*) {}
        };
}
using namespace B;
using namespace A;
int main() {
        boost::bind(&A::c::setName, _1, _2);
        return 0;
}

It looks legal to me but I'm no expert. GCC compiles with no warnings but
MSVC++ 6sp5 gives the error below.

boost/bind/mem_fn_vw.hpp(29) : error C2872: 'c' : ambiguous symbol
        boost/bind.hpp(875) : see reference to class template
instantiation 'boost::_mfi::mf1<void
,struct A::c,char const *>' being compiled

        boost/bind.hpp(886) : see reference to class template
instantiation 'boost::_bi::bind_t_generator<void>::implementation<struct
boost::_mfi::mf1<void,struct A::c,char const *>,class
boost::_bi::list2<class boost::arg<1>,class boost::arg<2> > >' being
compiled

        test.cpp(15) : see reference to class template instantiation
'boost::_bi::bind_t<void,struct boost::_mfi::mf1<void,struct A::c,char
const *>,class boost::_bi::list2<class boost::arg<1>,cla
ss boost::arg<2> > >' being compiled

boost/bind/mem_fn_vw.hpp(31) : error C2872: 'c' : ambiguous symbol
        boost/bind.hpp(875) : see reference to class template
instantiation 'boost::_mfi::mf1<void,struct A::c,char const *>' being
compiled

        boost/bind.hpp(886) : see reference to class template
instantiation 'boost::_bi::bind_t_generator<void>::implementation<struct
boost::_mfi::mf1<void,struct A::c,char const *>,class
boost::_bi::list2<class boost::arg<1>,class boost::arg<2> > >' being
compiled

        test.cpp(15) : see reference to class template instantiation
'boost::_bi::bind_t<void,struct boost::_mfi::mf1<void,struct A::c,char
const *>,class boost::_bi::list2<class boost::arg<1>,class boost::arg<2> >
>' being compiled

Best,

                                Andre Hentz


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