News for hackers. Stuff that matters.
Re:Why I don't spend time with Modern C++ anymore by ensiferum on Wednesday May 18, 2016 @07:25AM (#11721126)
My personal rules for using auto. Only use it iff:

1. the actual type is clearly visible on the right hand side. auto f = make_widget(); // it's a widget auto i = 123; // it's an int auto x = vec3(1.0, 0.0, 0.0); // it's a vector

2. the actual type doesn't really matter so much or is complicated to type out. auto it = vec.begin(); // it's an iterator auto it = // some template expression

3. the actual type is not known i.e. lambdas

Re:Why I don't spend time with Modern C++ anymore by slavik81 on Wednesday May 18, 2016 @06:53PM (#11726668)
I'm not a huge fan of the first rule. It's valid as stated, but the examples are questionable. I've seen all those in real code, and they're kind of annoying.

    auto f = make_widget();
    // is f of type widget or widget*?

    auto i = 123;
    // ok, I guess, but...
    // int i = 123; is shorter and more clear.

    auto x = vec3(1.0, 0.0, 0.0);
    // this can be shorter and simpler.
    // vec3 x(1.0, 0.0, 0.0);
Re:Why I don't spend time with Modern C++ anymore by fish2000 on Wednesday May 18, 2016 @12:15PM (#11722986)
These are good rules – as in liquor advertisements, it’s advisable to always accompany a declaration that uses `auto` with a rejoinder in the comments to Please Enjoy Responsibly
Re:Why I don't spend time with Modern C++ anymore by Aleman360 on Wednesday May 18, 2016 @09:09AM (#11721611)
In a word where most new code is JavaScript, just use auto everywhere. It will be OK.