Jump to content

Portal:Computer programming/Selected article/9

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by John of Reading (talk | contribs) at 19:36, 7 April 2016 (Reverted 2 edits by 95.106.117.76 (talk) to last revision by Ls6777. (TW)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In the C++ programming language, decltype is an operator for querying the type of an expression. It was 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.

As generic programming techniques became increasingly popular throughout the 1990s, the need for a type-deduction mechanism was recognized. Many compiler vendors implemented their own versions of the operator, typically called typeof, and some portable implementations with limited functionality, based on existing language features were developed. In 2002, Bjarne Stroustrup proposed that a standardized version of the operator be added to the C++ language, and suggested the name "decltype", to reflect that the operator would yield the "declared type" of an expression.

 This article incorporates text available under the CC BY-SA 3.0 license.