my problem code is:
#include <string>
#include <boost/function.hpp>
void func (const std::string&) {}
void func (const boost::function<void()>&) {}
int main() {
func (main);
func ("bad");
return 0;
}
=>
error: call of overloaded ‘func(const char [4])’ is ambiguous
overload.cpp:4: note: candidates are: void func(const std::string&)
overload.cpp:5: note: void func(const boost::function<void ()()>&)
I know that I can solve this by explicitly calling func (string ("bad")); or by creating func (const char *), but I wonder if there is a way to keep the caller's side, as in the example, and not introduce more overloads.
Maybe something with boost :: enable_if? Thanks for any tips.
source
share