-
-
Notifications
You must be signed in to change notification settings - Fork 327
Style Guide
Here you will find the style guide for edb. If you are considering submitting a PR, please do you best to meet this guidelines. It is worth noting that edb has been in development for a while now, and has had its style change over time, and therefore is currently is non-compliant with this guide and that we are working to resolve that.
edb is written using C++11. We may choose to move on to C++14 some time in the future, but for now, please stick to features that are provided by C++11 only. So long as a feature being used is well supported by both GCC and Clang, unless otherwise noted in the guide, it is acceptable to utilize it.
For now, we support both Qt4 and Qt5, so all code is expected to compile cleanly and function correctly against both Qt4 and Qt5 libraries.
The goal is always to compile without warnings when built with -std=c++11 -W -Wall -pedantic
.
Code should be standards compliant and not use compiler extensions (exceptions can be made, but must be wrapped in compiler specific #ifdef
blocks.
Note: C++11 introduced a syntax for type aliases which make use of the using
keyword, this is not talking about those.
Never place a namespace using directive in a header.
Prefer explicit namespace usage such as:
std::string s;
You may utilize a using
directive at function scope if it makes the code more readable, and is actually recommended if this aids in ADL. The most common example of this, is with custom swap
methods. For example:
class T {
public:
void swap(T &other) {
using std::swap;
swap(x, other.x);
swap(y, other.y);
}
private:
int x;
B y;
};
Due to ADL, if B::swap
exists, it will be preferred over default std::swap
.