dummy() function - What is that supposed to be?

前端 未结 2 1539
清歌不尽
清歌不尽 2021-02-03 20:23

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
           


        
2条回答
  •  無奈伤痛
    2021-02-03 20:58

    where [dummy] is declared

    In the declaration that you show. Simplified:

    T f /* the declarator */, dummy /* the declarator */;
    

    dummy is just a name of a variable, just like f. They are both declared in the same declaration.

    Could someone explain what that dummy function (or functor) does

    I mean obviously in the example it is used to call the function f. But what its actual purpose?

    That is the actual purpose. The only reason it is declared, is so that f could be called within the same declaration, as was desired in the linked question. The solution is silly, but so is perhaps the desire.

提交回复
热议问题