c++typedeflanguage-designtype-alias

C++ crazy typedef : what is the point of allowing this syntax by the Standard?


The old familiar one:

typedef int cute_int; //cute : common and familiar syntax. 

This syntax is perfect. No problem.

Now, when we can write typedefs like above, then what is the point of allowing this syntax:

int typedef crazy_int; //crazy : uncommon and unfamiliar syntax.

Just to confuse programmers? Is this syntax even needed anywhere (when in fact we've the previous one)? What do you think from the compilers' point of view? Do they find it cute or crazy? Or it doesn't matter to the compilers at all?


By the way, this code came from here : Use of typename keyword with typedef and new

In case if you're wondering if that is syntax error, then check out the working code here at ideone.


Solution

  • "The flip side of this is that you have to deal with old mistakes and with compatibility problems. For example, I consider the C declarator syntax an experiment that failed. Nevertheless, I adopted it for C++. The alternatives and improvements I considered at the time would not have improved matters. I rate is as a minor problem. The more serious problem is to maintain closeness of language definitions as C evolves." - Bjarne Stroustrup