简体   繁体   中英

I get error unresolved overloaded function type in c++

Why would piece of code like this:

boost::bind (SomeFunc<float>, function arguments go here);

produce this error:

no matching function for call to bind(<unresolved overloaded function type>

THanks

It could be that your function SomeFunc<float> is overloaded, in which case boost::bind cannot deal with this. You have to implement a manual solution, see here for more details:

You need to use a static_cast to tell the compiler which overload to pick if it's ambiguous, eg:

#include <boost/bind.hpp>

void foo(int) {}
void foo(double) {}

int main() {
  boost::bind(static_cast<void(*)(int)>(&foo), _1);
}

Sometimes "unresolved overloaded function type" can mean "none of the overloads are viable" in which case you need to figure out why it can't use any and fix that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM