[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-frameworks-devel
Subject:    Updating our coding conventions and coding style for C++11
From:       Vlad Zahorodnii <vladzzag () gmail ! com>
Date:       2020-01-16 17:29:11
Message-ID: 01278363-d60f-a54f-7de1-82bc1aa21324 () gmail ! com
[Download RAW message or body]

Hi,

I would like to update our coding conventions
https://community.kde.org/Policies/Library_Code_Policy.

The auto keyword is not mentioned leading to it being a common point of
contention in reviews as we can't point to a reference.

I would like us to copy Qt's policy [1] for consistency:

Optionally, you can use the auto keyword in the following cases. If in
doubt, for example if using auto could make the code less readable, do
not use auto. Keep in mind that code is read much more often than
written.
When it avoids repetition of a type in the same statement.

    auto something = new MyCustomType;
    auto keyEvent = static_cast<QKeyEvent *>(event);
    auto myList = QStringList() << QLatin1String("FooThing") <<
QLatin1String("BarThing");

When assigning iterator types.

    auto it = myList.const_iterator();

In addition to the coding conventions, I would like to update the KDE
Frameworks Coding Style to include a statement about whitespace before
range-based for loop colons.

The common practice used in KDE seems to be:

    for (a<space>:<space>b)

Cheers,
vlad

[1] https://wiki.qt.io/Coding_Conventions#auto_Keyword
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic