code snippet:
#include <iostream>
int main()
{
std::function<int(int)> func = [](int data)->int{
std::cout << "this is " << data << "\n";
};
func(3);
}
output
this is 3
I expected the above not to compile at all, but to my supprise it did compile. the compiler only generated this warning:
main.cpp:7:5: warning: non-void lambda does not return a value [-Wreturn-type]
};
^
1 warning generated.
My question is why wasnt a compile error generated?