4 ms·
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
by cheez 11y ago
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.
- modulus1 11y ago> [](a,b){ ... } Is valid if a and b are types.
- cheez 11y agoYeah, I guess that's where the committee is hesitant to deduce parameters without the auto qualifier.
- dbyte 11y agoauto 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.
- cheez 11y agoWhat do you mean about promotion rules with auto?
- RotsiserMho 11y agoCouldn't that have been found by turning on the signed-to-unsigned conversion warning?