On Sat, Jan 16, 2010 at 1:08 AM, Victor Lazzarini
<Victor.Lazzarini(a)nuim.ie> wrote:
Torben's new project brought back to my mind
this mind-bending C++
template example (see attached), which I could not yet get to compile, I
have been told it has been compiled, but g++ will have none of it. So I
still have doubts on whether it includes legal C++ code or not. But it is an
interesting example (even if it does not build) of what (possibly) can be
done with templates.
My question to the list is: has anyone managed to compile this code?
Wow, that's insane. But as far as I can tell, it is (almost) valid
C++. What gcc rightly complains about are a couple of missing typename
keywords. That's actually a pretty common mistake, because it's hard
to understand why these are even necessary, and some compilers simply
don't care.
The attached version of the file compiles fine with gcc, and the
program gives the correct answer.
Dominic