Possible Duplicates:
Why can't my C++ compiler deduce template argument for boost function?
Isn't the template argument (the signature) of std::function part of its type?
I have the following:
#include <functional>
void Foo( std::function<void()> );
void Foo( std::function<void(int)> );
void Bar();
int main()
{
Foo( Bar ); // Error: ambiguous
Foo( [](){} ); // Error: ambiguous
Foo( std::function<void()>( Bar ) ); // Ok
Foo( std::function<void()>( [](){} ) ); // Ok
}
Can I make the first two lines in main() work without the function-style cast in the last two lines? Perhaps with a std::enable_if solution?