Skip to content

Commit

Permalink
ES.30 fix example code
Browse files Browse the repository at this point in the history
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
  • Loading branch information
SpeedReach authored Sep 30, 2023
1 parent 27e662b commit 0466b1d
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 @@ -11365,8 +11365,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 @@ -11378,9 +11376,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<1>(); //ok
string s2 = stringify<2>(); //does not compile
// ...
}

Expand Down

0 comments on commit 0466b1d

Please sign in to comment.