-
Notifications
You must be signed in to change notification settings - Fork 0
Style Guide
Every class has to follow the rule of 5 or rule or 0.
This means that every class should either explicitly implement or delete a destructor, a copy constructor, a copy assignment, a move constructor, and a move assignment or none of them.
For static classes which shouldn't be created an instance of, make a public default constructor and delete it.
[[nodiscard]] : This is recommended where necessary.
noexcept : This is recommended where necessary for all functions at the momment. This can be changed in the future.
constexpr : Shouldn't put constexpr everywhere, only add it where the semantics is right. (If you are almost certain it can be constexpr.)
Headers should be included as the following order, with an additional line spacing between the categories. The order is local to global, in a nutshell.
- If it is a cpp file of a class, the header file corresponding to it.
- pch.h (The precompiled header)
- Header files in the same directory.
- Header files in the same project.
- Header files from other projects.
- Header files from dependencies.
- System headers.
This is not mandatory, the primary rule is to make it readable as possible to the user. Generally, put constructors and the big 5 at the front, then public > protected > private. In each access modifiers, the order is: type definitions, static members and methods, non-static members and methods
- public enums, classes and typedefs/usings
- (regardless of the access modifiers) constructors, destructor, copy constructor, move constructor, copy assignment, and move assignment
- public static members and methods (Creation related methods come first)
- public non-static members and methods (Getters and setters come last)
- (Similar to public stuff) protected enums and classes > static members and methods > non-static members and methods
- (Similar to public stuff) private enums and classes > static members and methods > non-static members and methods
- friend declarations
- All functions and type names use PascalCase.
- Local variables use camelCase.
- Compile-time constants and macros use SCREAMING_SNAKE_CASE.
- Member variables has
m_prefix (m_MemberName). - Static variables has
s_prefix (s_StaticMemberName).