ARTICLE AD BOX
I wrote the below test code. As can be seen, I can use default arguments for a traditional function call, but not for invoking std::function object (if I were to uncomment the commented out invocation, the code won't compile).
What is the difference in this context?
TIA
Vinod
#include<functional> #include<string> #include<iostream> using std::function; using std::string; using std::cout; using std::endl; void print(const string& rS = "hello world!") { cout << rS << endl; return; } int func() { function<void(const string&)> print = [](const string& rS = "hello world!")->void { cout << rS << endl; return; }; ::print(); //print(); print("hello world!"); return 0; } int main() { auto exit = (int (*)()) &func; std::cout << exit() << std::endl; }