Hi,
I'm playing around with std::function and lambdas with
a snapshot of g++, trunk revision 152966. Compiling
the following code with -std=c++0x results in
test.cpp: In function 'int main()':
test.cpp:17:48: error: call of overloaded 'foo(main()::<lambda()>)' is
ambiguous
test.cpp:4:6: note: candidates are: void foo(std::function<void(long int)>)
test.cpp:9:6: note: void foo(std::function<void()>)
#include <iostream>
#include <functional>
void foo(std::function<void(long)> bar)
{
bar(5);
}
void foo(std::function<void()> bar)
{
bar();
}
int main()
{
foo(std::function<void()>([](){std::cout << "foobar" << std::endl;}));
// OK
foo([](){std::cout << "foobar" << std::endl;});
// Line 17: Error
}
Is it a bug or the behaviour as the standard suggests? In theory, gcc
should be able
to deduce the right type by the parameter-list of the lambda - or am i
missing
something?