@@ -587,10 +587,7 @@ Prefer C++-style casts
587587^^^^^^^^^^^^^^^^^^^^^^
588588
589589When casting, use ``static_cast ``, ``reinterpret_cast ``, and ``const_cast ``,
590- rather than C-style casts. There are two exceptions to this:
591-
592- * When casting to ``void `` to suppress warnings about unused variables (as an
593- alternative to ``[[maybe_unused]] ``). Prefer C-style casts in this instance.
590+ rather than C-style casts. There is one exception to this:
594591
595592* When casting between integral types (including enums that are not strongly-
596593 typed), functional-style casts are permitted as an alternative to
@@ -1288,15 +1285,15 @@ These are two interesting different cases. In the first case, the call to
12881285``V.size() `` is only useful for the assert, and we don't want it executed when
12891286assertions are disabled. Code like this should move the call into the assert
12901287itself. In the second case, the side effects of the call must happen whether
1291- the assert is enabled or not. In this case, the value should be cast to void to
1292- disable the warning. To be specific, it is preferred to write the code like
1293- this:
1288+ the assert is enabled or not. In this case, the value should be defined using
1289+ the `` [[maybe_unused]] `` attribute to disable the warning. To be specific, it is
1290+ preferred to write the code like this:
12941291
12951292.. code-block :: c++
12961293
12971294 assert(V.size() > 42 && "Vector smaller than it should be");
12981295
1299- bool NewToSet = Myset.insert(Value); (void)NewToSet ;
1296+ [[maybe_unused]] bool NewToSet = Myset.insert(Value);
13001297 assert(NewToSet && "The value shouldn't be in the set yet");
13011298
13021299Do Not Use ``using namespace std ``
0 commit comments