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)?
It is definitely the example that is in error. m
will have type long
.
It, indeed, is a mistake.
In the given example, m
will be type long
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.