ES.30 fix example code (#2143)

* ES.30 fix example code 

The example should be passing in a constexpr and validating it at compile time like a macro, but instead passes a unknown value at compile time. Which may cause mislead and the code doesn't even work.

Ref: #2136

* Update CppCoreGuidelines.md

Used enums instead of raw numbers.
This commit is contained in:
Sleep_AllDay 2023-10-13 05:02:51 +08:00 committed by GitHub
parent 56e5b42eee
commit 1bdb43e5c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11368,8 +11368,6 @@ Also, `#` and `##` encourages the definition and use of macros:
There are workarounds for low-level string manipulation using macros. For example:
string s = "asdf" "lkjh"; // ordinary string literal concatenation
enum E { a, b };
template<int x>
@ -11381,9 +11379,10 @@ There are workarounds for low-level string manipulation using macros. For exampl
}
}
void f(int x, int y)
void f()
{
string sx = stringify<x>();
string s1 = stringify<a>();
string s2 = stringify<b>();
// ...
}