考虑这个例子:
#include <boost/signals2/signal.hpp>
#include <boost/bind.hpp>
typedef boost::signals2::signal< void ( double ) > DoubleSignalType;
typedef boost::signals2::signal< void ( void ) > VoidSignalType;
class B {
public:
void connect( DoubleSignalType::slot_type dbl_slot ) {
dbl_sig.connect( dbl_slot );
}
void connect( VoidSignalType::slot_type void_slot ) {
void_sig.connect( void_slot );
}
private:
DoubleSignalType dbl_sig;
VoidSignalType void_sig;
};
class A {
public:
void foo( double a ) {};
void bar( void ) {};
void other(){
B b;
b.connect( boost::bind( &A::foo, this, _1 ) );
}
};
int main( int argc, char* argv[] ) { return 0; }
当我编译这个时,我得到:
g++ x.cpp
x.cpp: In member function ‘void A::other()’:
x.cpp:27:53: error: call of overloaded ‘connect(boost::_bi::bind_t<void, boost::_mfi::mf1<void, A, double>, boost::_bi::list2<boost::_bi::value<A*>, boost::arg<1> > >)’ is ambiguous
x.cpp:27:53: note: candidates are:
x.cpp:9:10: note: void B::connect(boost::signals2::signal1<void, double, boost::signals2::optional_last_value<void>, int, std::less<int>, boost::function<void(double)>, boost::function<void(const boost::signals2::connection&, double)>, boost::signals2::mutex>::slot_type)
x.cpp:13:10: note: void B::connect(boost::signals2::signal0<void, boost::signals2::optional_last_value<void>, int, std::less<int>, boost::function<void()>, boost::function<void(const boost::signals2::connection&)>, boost::signals2::mutex>::slot_type)
有办法吗?