Both from my personal experience and from consulting answers to questions like What are some uses of decltype(auto)? I can find plenty of valuable use cases for decltype(a
Probably not a very deep answer, but basically decltype(auto)
was proposed to be used for return type deduction, to be able to deduce references when the return type is actually a reference (contrary to plain auto
that will never deduce the reference, or auto&&
that will always do it).
The fact that it can also be used for variable declaration not necessarily means that there should be better-than-other scenarios. Indeed, using decltype(auto)
in variable declaration will just complicate the code reading, given that, for a variable declaration, is has exactly the same meaning. On the other hand, the auto&&
form allows you to declare a constant variable, while decltype(auto)
doesn't.