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.
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:
Instead of:
My understanding is that they're allowing:
Bleh.
[ Parent
| on HN ]
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?