Impala C++ Code follows a modified version of the Google C++ Style Guide at:
There are some key differences which are documented here.
- Separate inline headers: We allow putting inline functions in separate files, using the suffix
- Pros: ??
- Cons: ??
- namespaces use of anonymous namespaces are not recommended.
- Pros: ??
- Cons: naming conflicts can occur between object files
- namespaces the
using namespacedirective is encouraged
- Pros: reduces code volume
- Cons: pollutes the namespace, causes conflicts, makes it more difficult to determine the type of an object
- explicit ctors we do not mark single argument constructors
- Pros: None
- Cons: undesirable conversions
- copy ctors we do not implement or delete copy and assignment constructors
- Pros: easier use with the STL
- Cons: implicit copying of objects in C++ is a rich source of bugs and of performance problems
- operator overloading we extensively use operator overloading
- Pros: code looks nicer and is more compact
- Cons: It can fool our intuition into thinking that expensive operations are cheap, built-in operations. It is much harder to find the call sites for overloaded operators. Searching for
Equals()is much easier than searching for relevant invocations of
==. Some operators work on pointers too, making it easy to introduce bugs.
Foo + 4may do one thing, while
&Foo + 4does something totally different. The compiler does not complain for either of these, making this very hard to debug.
- default function arguments we use default function arguments
- Pros: clean syntax, reduced code volumne
- Cons: function pointers are confusing in the presence of default arguments
- casting we use cast formats such as
int x = (int) y;
- Pros: clean syntax
- Cons: ambiguous operator
- Line Length We use 90 character line lengths
- TODO Comments we do not include the name in the TODO comment
- Function Declaration we line wrap differently than google, for example do:
3. Conditionals we format conditionals as follows