August 2012
Intermediate to advanced
976 pages
30h 17m
English
decltype Type SpecifierSometimes we want to define a variable with a type that the compiler deduces from an expression but do not want to use that expression to initialize the variable. For such cases, the new standard introduced a second type specifier, decltype
, which returns the type of its operand. The compiler analyzes the expression to determine its type but does not evaluate the expression:
decltype(f()) sum = x; // sum has whatever type f returns
Here, the compiler does not call f, but it uses the type that such a call would ...
Read now
Unlock full access