simplecpp
simplecpp copied to clipboard
Token pasting string constant to user defined literal throws invalidHashHash exception
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.