3 ms·
The problem with C++ grammar is that inside templates, things are too flexible at times. For example: template<bool> struct a_t; template<> struct a_t
by int_19h 10y ago
The problem with C++ grammar is that inside templates, things are too flexible at times. For example:
template<bool> struct a_t;
template<> struct a_t<true> {
template<int> struct b {};
};
template<> struct a_t<false> {
enum { b };
};
typedef a_t<sizeof(void*)==sizeof(int)> a;
enum { c, d };
int main() {
a::b<c>d; // declaration or expression?
}
It's a fun C++ IDE torture test, which few pass. One that does is Visual Studio - if you create a C++ project and set up both 32-bit and 64-bit build targets, you can flip between them, and see the syntax highlighting change on the line with the comment.