Pointer to function returning function pointer

前端 未结 2 1928
被撕碎了的回忆
被撕碎了的回忆 2021-02-07 04:37

I would like to declare a variable of type pointer to function returning pointer to function. Essentially what the following does, but without any typedefs

2条回答
  •  感情败类
    2021-02-07 05:23

    You can have a look at the declaration of signal() which is a function taking a void(*)() and returning one of those. The variable ptr can be declared like this:

    void (*(*ptr)())()
    

    The notation is a bit awkward and clearly inside out. It may be easier to use trailing return types:

    auto (*ptr)() -> void (*)()
    

    ... or, of course, use trailing return types all the way through:

    auto (*ptr)() -> auto (*)() -> void
    

提交回复
热议问题