While answering this question, I see the following fact by accident.
Please see this example:
void func1(const char *str1, const char *str2) { puts(str1); puts(str2); }
...
auto fn = std::bind(func1, "asdf");
fn("1234");
It is failed to compile it:
prog.cpp: In function ‘int main()’:
prog.cpp:11:14: error: no match for call to ‘(std::_Bind<void (*(const char*))(const char*, const char*)>) (const char [5])’
fn("1234");
^
If I change code into this, it works well:
auto fn = std::bind(func1, "asdf", _1);
Output is:
asdf
1234
Why? I bind only first argument.. Is it impossible that std::bind
automatically do 'placeholdering' the other arguments? (I expected the same result of std::bind1st
in C++98.) Why??