I read this question here on SO and stumbled over the best voted answer, which used code like this to call a lambda recursively:
std::function<void(int)>
f {[&f](int i){
// do something
}},
dummy((f(3), nullptr));
I wondered what the dummy(...)
part was about so I did some research but couldn't find anything about it. In the code snippet provided in the answer there was the <utility>
header used so I guess that thing must be declared somewhere in there, but I still couldn't find anything about it.
Could someone explain what that dummy
function (or functor) does, where it is declared and what it is usually used for?
I mean obviously in the example it is used to call the function f. But what its actual purpose?
NOTE: I know that question is a little broad, but since I couldn't find any information about it I could not focus the question onto one specif problem. Also I hope that an answer to my questions will help others finding information about the mysterious dummy()
.