6

So there I was reading about the implementation of lambda calculus with template metaprograms, one proof of TMP's Turing-completeness.

As I was reading through the source code I stumbled on one (and then more) lines like the following :

template <int Name, typename Value, typename Env>
struct EnvLookup <Name, Binding<Name,Value,Env> > 
{
  Value typedef result ; // Line 84, what is this ?
} ;

I'm used to typedef Type Alias;, but Type typedef Alias; looks alien to me. And still it compiles fine with g++ 4.9.0 and good old -std=c++98.

I could not find any documentation on this syntax with Google, nor here on SO. Is this standard-compliant ? A g++ extension perhaps ? Will it blend ?

Bathsheba
  • 231,907
  • 34
  • 361
  • 483
Quentin
  • 62,093
  • 7
  • 131
  • 191
  • just like `const int i` and `int const i` – Bryan Chen Jul 22 '14 at 09:49
  • So this is standard-compliant, and in fact just a quirk in the language's grammar. Thank you ! I hope this question will be more search-friendly than the duplicate, if anything. – Quentin Jul 22 '14 at 09:53
  • @Bathsheba to be honest I'm not that good at parsing grammars (seriously, without a side-to-side example it just skids off my brain). So I just trust the duplicate's accepted answer. Eh. – Quentin Jul 22 '14 at 10:05
  • In C, you can even write just `typedef;`. The `int` type is implied and you don't have to give the `typedef` a name. – Tobias Brandt Jul 22 '14 at 10:07
  • This language is mad and I love it. – Quentin Jul 22 '14 at 10:08

0 Answers0