Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualaeroz

Posted 29 January 2012 - 09:41 AM

I was able to remove all the unimportant code from my project and got a minimal error producing example!

#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.

#3aeroz

Posted 29 January 2012 - 09:40 AM

I was able to remove all the unimportant code from my project and got a minimal error producing example!

#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.

#2aeroz

Posted 29 January 2012 - 09:37 AM

I was able to remove all the unimportant code from my project and got a minimal error producing example!

#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>		  ]

#1aeroz

Posted 29 January 2012 - 09:36 AM

I was able to remove all the unimportant code from my project and got a minimal error producing example!

#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>		  ]

PARTNERS