On Tue, Oct 21, 2008 at 9:32 AM, Joe Buck <[EMAIL PROTECTED]> wrote: > On Mon, Oct 20, 2008 at 07:21:49PM -0700, Andrew Pinski wrote: >> On Mon, Oct 20, 2008 at 7:19 PM, Peng Yu <[EMAIL PROTECTED]> wrote: >> > Could you please help explain what the difference between typeof and >> > decltype are? What are c++0x/g++0x modes? >> >> Well decltype is part of the C++0x standard >> (http://gcc.gnu.org/projects/cxx0x.html, >> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf ). >> typedef is a GCC extension. > > You meant to say "typeof", of course. > > Is there a reason why typeof shouldn't just be a synonym for decltype?
Yes. Making it a synonym makes it useless to users (if they want decltype, they can type it, and get portable code), and breaks existing code. > If there's an extension that's almost the same as a new standard feature, > it would seem easiest to make it exactly the same, unless that would > cause extensive breakage (if it breaks corner cases that might not > be such a big deal, for an extension). The reason the standard name is "decltype" is in large part to avoid breaking code which uses the various differing existing implementationf of "typeof", just as with naming the hashed C++ containers unordered_xxx instead of hash_xxx. The legacy names are for backwards compatibility. -- James