C++ Logo


Advanced search

Re: Syntax of pointers to functions, members, and member functions

From: Tadeus Prastowo <tadeus.prastowo_at_[hidden]>
Date: Tue, 1 Oct 2019 22:23:29 +0200

> My question is simple: why doesn’t everyone declare pointers to
> functions, members, or member functions in the way I describe
> below? Is this breaking some rule? Is the two-step process
> somehow inefficient? I’ve even found style guides, for
> significant companies, that said (paraphrased): “Do not put
> pointers (‘*’) inside typedefs, to more clearly show what the
> type is for. Note that typedefs for pointers to functions can
> ignore this rule.” No! Keeping this rule, especially for
> pointers to functions (and members, and pointers to members),
> makes them even easier to understand!

I think it is because people are not accustomed to using function
types directly as you suggest due to functions being non-first-class
citizens in C/C++, unlike in some functional languages (e.g.,

I like your suggestion, will definitely use it if nothing else
prevents me from doing so, and appreciate your spreading of the idea
through the Wikipedia article. Hopefully, it will be taken up by some
existing projects, such as the Linux kernel, after which people would
get accustomed to your suggested style (as for the Linux kernel,
however, old habit dies hard).

Best regards,

Received on 2019-10-01 15:25:42