Boost logo

Boost Users :

Subject: [Boost-users] overload resolution with boost::function
From: Jens Auer (jensa_at_[hidden])
Date: 2010-09-17 03:34:10


Hi,

I am trying to use objects of boost::function as parameters to overloaded function. However, the compiler fails to automatically resolve the function type when I use a function pointer:
#include <boost/function.hpp>

void f(int);

void accept( boost::function< void () > g); void accept( boost::function< void (int) > g);

int main(int argc, char* argv[])
{
   accept(f);
   return 0;
}

boost_function.cpp: In function »int main(int, char**)«:
boost_function.cpp:11: Fehler: Aufruf des überladenen »accept(void (&)(int))« ist nicht eindeutig
boost_function.cpp:6: Anmerkung: Kandidaten sind: void accept(boost::function<vo
id()>)
boost_function.cpp:7: Anmerkung: void accept(boost::function<vo
id(int)>)

Sorry for the german error messages, the compiler complains about ambigous functions and shows two candidates. Is there any way to have the accept function call resolved automatically without creating explicit boost::function object?


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