On 8/6/19 5:44 PM, Roman Gilg wrote:
Hi,
Hi,
I am not sure whether you started this discussion in Qt/Development
mailing list, so I'll just leave my 2 cents here.
Let's start with very obvious thing first: If you align pointers and
references to right, then you're doing something fishy. [1]
Frameworks C++ coding style for pointer declarations follows the
asterisk to the right approach like Qt coding style recommends.
This is most often a sensible choice but is difficult to read in my
opinion when there is no identifier to the right the asterisk is
associated with, for example for function return types and casts.
Because of that I prefer a style like explained here:
https://www.quora.com/Where-should-I-put-the-asterisk-for-pointers-in-C++-Is-it-int*-ptr-int-*-ptr-or-int-*ptr/answer/David-Vandevoorde
Any arguments for or against doing it this way?
While I kind of see what the point of the proposed style is, I think
it's just complex. If you write code with this style for a long period
of time, maybe it'll be natural for you. However, we also value
contributions from community. The proposed style is very rare as most
people align pointers and references either to left or right, so it'll
be more difficult for them to contribute.
Aestetically, code with this style looks clunky (imho), e.g.
Foo* bar(const QVector<Bar*> *foo1, Bar *foo2);
Another problem is that tools like clang-format can't be used to
re-format existing code with such style. They can attach * and & either
to type, or name, or between name and type. It's very crucial because
you should not expect people to fix coding style by hand.
Cheers,
Vlad
[1] Some people can disagree with that. ;-)