News for hackers. Stuff that matters.
Re:C++ 11 Auto: How to use and avoid abuse by cheez on Saturday February 13, 2016 @09:48PM (#11096923)
auto, the new range for and lambdas are my most used C++11 features. Also make_shared/make_unique.

  auto ptr = make_shared<T>() 
Reads very nicely so I agree that if the type should be somewhere in the auto expression. That is, use auto to remove redundancy. I just wish they would have extended type deduction to lambda arguments so I could do:

  [](a,b){ ... }
Instead of:

  [](int a, int b) {...}
My understanding is that they're allowing:

  [](auto a, auto b) {...}
Bleh.
Re:C++ 11 Auto: How to use and avoid abuse by dbyte on Sunday February 14, 2016 @03:56AM (#11097630)
auto with lambdas can be quite dangerous if you are adding different types inside their bodies. Type promotion rules should be well understood. During code reviews we spotted several overflow bugs when using ints because the dev were thinking auto as a sort of very powerful resource.

Explicit casting if often required to make sure subtle bugs won't show up in production.

Re:C++ 11 Auto: How to use and avoid abuse by cheez on Sunday February 14, 2016 @08:38AM (#11098215)
What do you mean about promotion rules with auto?
Re:C++ 11 Auto: How to use and avoid abuse by RotsiserMho on Sunday February 14, 2016 @10:12AM (#11098523)
Couldn't that have been found by turning on the signed-to-unsigned conversion warning?
Re:C++ 11 Auto: How to use and avoid abuse by modulus1 on Sunday February 14, 2016 @12:35AM (#11097269)
> [](a,b){ ... }

Is valid if a and b are types.

Re:C++ 11 Auto: How to use and avoid abuse by cheez on Sunday February 14, 2016 @09:19AM (#11098321)
Yeah, I guess that's where the committee is hesitant to deduce parameters without the auto qualifier.