From 35db1dc99be09d89bb3f07118e52fe5404748cc9 Mon Sep 17 00:00:00 2001 From: ksooo <3226626+ksooo@users.noreply.github.com> Date: Thu, 26 Oct 2023 11:36:55 +0200 Subject: [docs] Coding guideline: Add, that we are using prefix operators in traditional for loop's increment statement. --- docs/CODE_GUIDELINES.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'docs') diff --git a/docs/CODE_GUIDELINES.md b/docs/CODE_GUIDELINES.md index 1af839e6a4..25d64574e4 100644 --- a/docs/CODE_GUIDELINES.md +++ b/docs/CODE_GUIDELINES.md @@ -821,6 +821,25 @@ for (const auto& : var) ``` Remove `const` if the value has to be modified. Do not use references to fundamental types that are not modified. +In traditional for loops, for the `increment statement` of the loop, use prefix increment/decrement operator, not postfix. + +✅ Good: +```cpp +[...] +for (int i = 0; i < 100; ++i) +{ + [...] +} +``` + +❌ Bad: +```cpp +for (int i = 0; i < 100; i++) +{ + [...] +} +``` + ### 12.6. Include guards Use `#pragma once`. -- cgit v1.2.3