decltype

Introduced in C++11, its primary intended use is in generic programming, where it is often difficult, or even impossible, to express types that depend on template parameters.

[4] His work was expanded on by Bill Gibbons, who concluded that the technique had several limitations and was generally less powerful than an actual typeof mechanism.

[4] In an October 2000 article of Dr. Dobb's Journal, Andrei Alexandrescu remarked that "having a typeof would make much template code easier to write and understand.

"[6] They characterized the use of type conventions, like the typedefs provided by the Standard Template Library, as a more powerful and general technique.

[6] However, Steve Dewhurst argued that such conventions are "costly to design and promulgate", and that it would be "much easier to ... simply extract the type of the expression.

"[7] In a 2011 article on C++0x, Koenig and Moo predicted that "decltype will be widely used to make everyday programs easier to write.

[11] The fact that extra parentheses introduce a reference qualifier to the type can be a source of errors for programmers who do not fully understand decltype.

[16] While commenting on the formal Committee Draft for C++0x, the Japanese ISO member body noted that "a scope operator(::) cannot be applied to decltype, but it should be.

Microsoft's Visual C++ 2010 and later compilers provide a decltype type specifier that closely mimics the semantics as described in the standards committee proposal.