Skip to content

Commit 8789617

Browse files
authored
ES.87 (redundant == or !=) Fix dynamic_cast to Circle pointer (isocpp#2168)
The second ES.87 example seemed to mistakenly assume that `Circle` is pointer type, by the way it was using `dynamic_cast`. However, `Circle` is meant to be a class type instead. This fix is consistent with other examples, that also do `dynamic_cast<Circle*>`.
1 parent e49158a commit 8789617

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

CppCoreGuidelines.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13335,9 +13335,9 @@ whereas `if (p != nullptr)` would be a long-winded workaround.
1333513335

1333613336
This rule is especially useful when a declaration is used as a condition
1333713337

13338-
if (auto pc = dynamic_cast<Circle>(ps)) { ... } // execute if ps points to a kind of Circle, good
13338+
if (auto pc = dynamic_cast<Circle*>(ps)) { ... } // execute if ps points to a kind of Circle, good
1333913339

13340-
if (auto pc = dynamic_cast<Circle>(ps); pc != nullptr) { ... } // not recommended
13340+
if (auto pc = dynamic_cast<Circle*>(ps); pc != nullptr) { ... } // not recommended
1334113341

1334213342
##### Example
1334313343

0 commit comments

Comments
 (0)