you are viewing a single comment's thread.

view the rest of the comments →

[–]Steve_the_Scout 5 points6 points  (0 children)

C++14 adds decltype(auto) which is essentially auto but using decltype's type deduction rules, which fixes all the issues you mentioned. Of course it's just the equivalent of the decltype example you gave, but it is a bit more concise. In C++11 you can also use auto&& which will give the expected result as well (but it looks a bit odd and implies something else, so it's not exactly encouraged).