Please, explain, why in the following code there is no error:
void f()
{
}
void h()
{
std::bind(f)(42);
}
Why compiler doesn’t complain about redundant parameter in std::bind while binding function f? And if it shouldn’t, please explain why this can be useful.
This code is conformant. The arguments that you pass to the result of bind are only used if needed.
Using the terminology from the standard:
uis the result ofstd::bind(f, t1, ..., tN).Approximately speaking:
When
u(u1, u2, ..., uM)is called,fis called asf(v1, ..., vN), where the values ofviare determined by the following algorithm: