If you favor "T *var", do you ever write "T*"?
- by Roger Pate
Thinking about where we place our asterisks; how do those that prefer to keep the "pointerness" away from the type and with the identifier (int *i) write code when the identifier is missing?
void f(int*); // 1
void f(int *); // 2
The former seems much more common, no matter what your preference when with the identifier. Is this a special case? What makes it an exception?
However, the first still isn't universal, because I have seen the latter style. Besides consistency along the lines of "there's always a space with the identifier, so we have one without", are there any other reasons to prefer it?
What about casts or array and function types? How would you re-write these:
(void*)var /*or*/ (void *)var
int[3] /*or*/ int [3]
// more relevant in C++ than C: Example<int[3]>
void(int) /*or*/ void (int)
// more relevant in C++ than C: std::function<void(int)>
The latter two would rarely, if ever, be used in C, but are seen with C++ templates.