The following guidelines cover best practices and design decisions that we chose to adhere in our projects. It is not our intention to provide a universal style guide for C++.
.h
files. .h
file. UTF-8
encoding for all source files. 4
spaces (no tabs). <
and >
for external libraries as well as local public includes. Abstract
. get
. [more]set
prefix to setters. [more]m_
prefix to member variables, s_
to static member variables, t_
to thread-local variables, and g_
to global variables. const
. glm/fwd.hpp
and iosfwd
instead). #pragma once
instead of #define
guards. bool
, int
and float
). nullptr
. const
. [more]mutable
. using namespace
in header files. // ToDo <description>
) override
for overridden methods. auto
where applicable (see right-hand style). [more]= delete
as a mean to remove auto generated class methods. using
instead of typedef
. std::array
instead of c arrays. constexpr
) as they are not fully supported yet by all compilers. nullptr
for null pointers, 0
for numbers; never use NULL
. .hpp
file). #include <cmath>
). source/<library name>/include/<library name>/
. source/<library name>/source/
. auto
capture lambdas (std::function
is a functor wrapper not its type.) dynamic_cast
is not the default for down casts; if you know the type, use static_cast
. std::vector
s invalidates iterators. [more]<library uppercase name>_API
). std::vector
your favorite container type.