simplecpp icon indicating copy to clipboard operation
simplecpp copied to clipboard

Token pasting string constant to user defined literal throws invalidHashHash exception

Open bedw021 opened this issue 5 years ago • 0 comments

Token pasting to string constants ("abc") and character constants ('c') currently generates an invalidHashHash exception:

#define NUM_CHAR(str) str##_numch

inline auto operator "" _numch(const char *ch, std::size_t size) noexcept -> std:size_t
{
  return size;
}

int main()
{
  auto x = "abc"_numch; // Valid expression
  auto y = NUM_CHAR("abc"); // Throws invalidHashHash exception, but expands to the same as previous line
}

Token pasting A ## B should be allowed if A is a string or character constant, and B is a name, as B may be a literal that operates on A.

bedw021 avatar May 25 '19 04:05 bedw021