3 ms·
"Effective Modern C++" (Scott Meyer) has a chapter on how to tease deduced types out of compilers. You can argue "it's silly that I even have to do that", and y
by roel_v 9y ago
"Effective Modern C++" (Scott Meyer) has a chapter on how to tease deduced types out of compilers. You can argue "it's silly that I even have to do that", and yes I'd argue that too, but sometimes you just need auto inside templates. Before I started using it, I thought it'd be a train wreck, but now I quite like it - when used judiciously.
I do find myself writing code with auto, then when I revisit it at some point, replace it with the explicit type for readability. But that's only for a small percentage of the cases where I use auto, so overall it's a net plus.
- AnimalMuppet 9y ago> ... when used judiciously. That applies to many C++ features, not just auto. Maybe the problem with C++ is that it's not a language that you can use well without developing a sense of good taste - knowing when to use certain things, and when not to. (And then you have to interface with code written by someone else who didn't have any taste, and just used features without regard to whether they made things better or worse...)
- pjmlp 9y agoThat applies to any production language that has been in the wild for a few decades.
- roel_v 9y agoPff, is that a problem with C++ or with programming in general? There is not a single language in the world you can use well without developing a sense of good taste. And what is good taste not only differs between languages (for the exact same concept, like how do you sum the values of an array, or how do you execute two code paths in parallel), but also changes over time.