Skip to content

Commit

Permalink
ES.30 fix example code (#2143)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
SpeedReach authored Oct 12, 2023
1 parent 56e5b42 commit 1bdb43e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions CppCoreGuidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>();
// ...
}

Expand Down

0 comments on commit 1bdb43e

Please sign in to comment.