News for hackers. Stuff that matters.
Re:Why the C++ standard ships every three years by shaklee3 on Saturday July 13, 2019 @07:19PM (#20430734)
Why would you ever use or see the latter? Fabricated examples aren't helpful.
Re:Why the C++ standard ships every three years by comex on Sunday July 14, 2019 @02:43AM (#20432038)
You wouldn't...

...instead you'd use "decltype(auto) v = <expr>", which is equivalent. And people certainly use decltype(auto), or else it wouldn't have been added to the language, 3 years after regular auto.

Re:Why the C++ standard ships every three years by saagarjha on Saturday July 13, 2019 @08:09PM (#20430890)
Not sure why this was downvoted, decltype was introduced with C++11 alongside of auto for declarations: the example given isn't accurate of reality. A better one might be a function returning auto vs returning decltype(some expression).
Re:Why the C++ standard ships every three years by detaro on Saturday July 13, 2019 @08:21PM (#20430926)
Which specific example is choosen doesn't seem all that relevant for the point of "there's these two similar but not identical things people have to/might not understand the difference of"
Re:Why the C++ standard ships every three years by saagarjha on Saturday July 13, 2019 @08:28PM (#20430945)
Picking an example that never occurs is not relevant, because nobody needs to learn the thing that never comes up in practice.
Re:Why the C++ standard ships every three years by detaro on Saturday July 13, 2019 @08:36PM (#20430964)
But as you show with your other example, the difference between auto and decltype does come up in practice, even if the example is not a typical one.
Re:Why the C++ standard ships every three years by saagarjha on Saturday July 13, 2019 @08:40PM (#20430978)
Sure: that's why I provided one that reflected the real world more closely.
Re:Why the C++ standard ships every three years by detaro on Saturday July 13, 2019 @08:43PM (#20430982)
re-reading: My first comment was addressing the "why might this have been downvoted part", I didn't make that clear enough.