Search code examples
c++decltype

Type of variable declared with decltype (having function as an expression)


I'm now reading C++ Primer by Stephen Prata and while I read about decltype I'm a little bit confused. In the first part of the paragraph he wrote:

If expression is a function call, then var has the type of the function return type

and then gives an example

long indeed(int);
decltype (indeed(3)) m; // m is type int

Isn't that a mistake? My logic says that return type of indeed function is long and m should has type long. If I'm right, where is mistake in the first part of paragraph or in the second (example)?


Solution

  • It is definitely the example that is in error. m will have type long.