[Development] Proposing changes to https://wiki.qt.io/Qt_Coding_Style
Marc Mutz
marc.mutz at qt.io
Wed May 10 07:39:46 CEST 2023
On 09.05.23 22:15, Allan Sandfeld Jensen wrote:
> On Dienstag, 9. Mai 2023 08:51:37 CEST Marc Mutz via Development wrote:
[...]
>> - space after template and before <:
>>
>> // WRONG
>> template<class T>
>> // CORRECT:
>> template <class T>
>>
>
>> Rationale: We always used the latter in Qt.
>
> We have always used both. I prefer the first one, which also happens to be the
> default by old Qt styles, but the second one is now more common in QtCore.
Some historical data, mined using
$ git grep --recurse-submodules -e 'template <' $version -- | \
grep -v /3rdparty/ | wc -l
$ git grep --recurse-submodules -e 'template<' $version -- | \
grep -v /3rdparty/ | wc -l
Qt | template < | template< | remarks |
-----+------------+-----------+-------------------+
4.5 | 2037 | 606 | qt.git |
4.8 | 2440 | 796 | |
-----+------------+-----------+-------------------+
5.0 | 2479 | 1429 | qt5.git (beta-1) |
5.6 | 3103 | 2040 | |
5.9 | 3315 | 2103 | |
-----+------------+-----------+-------------------+
(_clang-format demanding template< added here) |
(existed before in qtrepotools, it seems) |
-----+------------+-----------+-------------------+
5.12 | 5051 | 2637 | |
5.15 | 4989 | 2838 | |
6.0 | 5353 | 4027 | |
6.2 | 5580 | 4407 | |
6.5 | 6202 | 5395 | |
-----+------------+-----------+-------------------+
I think it's hopeless to convert to either over night, but it also seems
clear that with-space was the preferred form until the use of the
no-space form picked up dramatically following the addition, and then
uptick in use, of _clang-format to qt5.git.
Absent a consensus on this, I'd suggest to use whatever you find to be
predominant in the file/module you're editing.
> That said. I find discussing style-guides in general a waste of time, and will
> agree to anything that make us stop wasting time on this.
I tend to agree, but the choice is either to define it centrally, or you
repeat these discussions on Gerrit over and over again.
Thanks,
Marc
--
Marc Mutz <marc.mutz at qt.io>
Principal Software Engineer
The Qt Company
Erich-Thilo-Str. 10 12489
Berlin, Germany
www.qt.io
Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen
Sitz der Gesellschaft: Berlin,
Registergericht: Amtsgericht Charlottenburg,
HRB 144331 B
More information about the Development
mailing list