What is the difference between auto and decltype, and what is decltype(auto)?
Last updated
autodeduces like template deduction, stripping top-levelconstand references (useauto&to keep them).decltype(expr)yields the exact type including references. A parenthesized lvalue likedecltype((x))yields a reference.decltype(auto)deduces from the initializer usingdecltyperules, mainly for forwarding return types that must preserve references.