ES.23: change example code to better match the rule (#2150)

The example suggests that `int z = gsl::narrow_cast<int>(7.9);;` is OK. The rule says "Use `=` only when you are sure that there can be no narrowing conversions.", which matches, but is also says "For built-in arithmetic types, use `=` only with `auto`.", and this is not respected here. So replace the one line with both possibilities suggested by the rule.

Co-authored-by: Werner Henze <w.henze@avm.de>
This commit is contained in:
Werner Henze 2023-10-12 21:25:52 +02:00 committed by GitHub
parent a43285d95a
commit 2d87c45e4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11095,7 +11095,8 @@ For containers, there is a tradition for using `{...}` for a list of elements an
int x {7.9}; // error: narrowing
int y = 7.9; // OK: y becomes 7. Hope for a compiler warning
int z = gsl::narrow_cast<int>(7.9); // OK: you asked for it
int z {gsl::narrow_cast<int>(7.9)}; // OK: you asked for it
auto zz = gsl::narrow_cast<int>(7.9); // OK: you asked for it
##### Note