Aspects


vs


Home Page
About Us

Auto

The `auto` keyword was repurposed in C++11 for a deduced type

Decltype

Decltype is a C++11 keyword that can be used to find the type of an expression.



Others

Example

Decltype is significantly more versatile that auto and can always be used in place of it

from question  

When should I use decltype(x) instead of auto to declare the type of a variable?

Other than that auto cannot be used as a standalone entity inside decltype x because that would prevent x from being a valid expression;decltype auto is an inseparable construct almost as if it were a keyword like decltype_auto

from question  

Decltype(auto), trailing return type and sfinae: can we mix them?

In the cases where auto can be used it is more concise than decltype as you don t need to provide the expression from which the type will be inferred

from question  

Decltype vs auto

Note decltype auto is primarily useful for deducing the return type of forwarding functions and similar wrappers as shown above where you want the type to exactly track some expression you re invoking;however decltype auto is not intended to be a widely used feature beyond that

from question  

Almost Always decltype(auto)?

Back to Home
Data comes from Stack Exchange with CC-BY-SA-4.0