#include <boost/bind.hpp>
#include <boost/make_shared.hpp>
#include <boost/function.hpp>
#include <string>
class A {
public:
A(boost::function0<void>) {}
};
void f() {}
void g(std::string) {}
int main() {
using boost::make_shared;
make_shared<A>( boost::bind(f) ); // no error
make_shared<A>( boost::bind(g, "hoi") ); // error
return 0;
}
Can you imagine why it doesn't compile?
The error is same as before:
1>c:\users\christian\documents\visual studio 2010\projects\minimalmakesharederror\main.cpp(18): error C2668: 'boost::make_shared' : ambiguous call to overloaded function 1> c:\libraries\boost_1_47\boost\smart_ptr\make_shared.hpp(198): could be 'boost::shared_ptr<T> boost::make_shared<A,boost::_bi::bind_t<R,F,L>>(A1 &&)' 1> with 1> [ 1> T=A, 1> R=void, 1> F=void (__cdecl *)(std::string), 1> L=boost::_bi::list1<boost::_bi::value<const char *>>, 1> A1=boost::_bi::bind_t<void,void (__cdecl *)(std::string),boost::_bi::list1<boost::_bi::value<const char *>>> 1> ] 1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xxshared(33): or 'std::tr1::shared_ptr<_Ty> std::tr1::make_shared<A,boost::_bi::bind_t<R,F,L>>(_Arg0 &&)' [found using argument-dependent lookup] 1> with 1> [ 1> _Ty=A, 1> R=void, 1> F=void (__cdecl *)(std::string), 1> L=boost::_bi::list1<boost::_bi::value<const char *>>, 1> _Arg0=boost::_bi::bind_t<void,void (__cdecl *)(std::string),boost::_bi::list1<boost::_bi::value<const char *>>> 1> ] 1> while trying to match the argument list '(boost::_bi::bind_t<R,F,L>)' 1> with 1> [ 1> R=void, 1> F=void (__cdecl *)(std::string), 1> L=boost::_bi::list1<boost::_bi::value<const char *>> 1> ]
Note that the error is only there when the argument type of g is in the std namespace.