@@ -257,46 +257,44 @@ Below follow general guidelines with examples:
257257#### The use of ` auto ` is ok if the right-hand side makes clear which type it is
258258
259259``` c++
260- auto * xyz = new Xyz();
260+ auto * xyz = new Xyz(); // OK: type is clear from calling the constructor
261261```
262262
263263``` c++
264- auto xyz = <whatever>_cast<Xyz>(...);
264+ auto xyz = <whatever>_cast<Xyz>(...); // OK: type is clear from the cast
265265```
266266
267267``` c++
268- auto xyz = getAnything<Xyz>(...);
268+ auto xyz = getAnything<Xyz>(...); // OK: type is clear from the context and type parameter
269269```
270270
271- Counter examples:
272-
273271``` c++
274- auto value = randomThing.weirdProperty->getValue (); // non-obvious type
272+ auto value = randomThing.weirdProperty->getValue (); // bad: non-obvious type
275273```
276274
277275``` c++
278- auto doStuff () { ... } // auto as return type
276+ auto doStuff () { ... } // bad: auto as return type
279277```
280278
281279```c++
282- auto xyz = 1; // unclear what type of integer
280+ auto xyz = 1; // bad: unclear what type of integer
283281```
284282
285283#### The use of ` auto ` is ok if the type is long or verbose
286284
287285``` c++
288- auto it = foo.begin(); // iterator
286+ auto it = foo.begin(); // OK: iterator
289287```
290288
291289``` c++
292- auto lambda = [](){...};
290+ auto lambda = [](){...}; // OK: function type
293291```
294292
295293#### The use of `auto` is ok if redundancy is avoided
296294
297295```c++
298296std::unordered_map<std::string, int> map;
299- for (const auto& [key, value] : map) { ... }
297+ for (const auto& [key, value] : map) { ... } // OK: map declaration contains the type
300298```
301299
302300## Main code path and indentation
0 commit comments