4 ms·
Codebases that do that are very rarely const correct, however. (Personally, I don’t think typing unique_ptr<Foo> or unique_ptr<const Foo> is such a big deal. B
by codeflo 5y ago
Codebases that do that are very rarely const correct, however.
(Personally, I don’t think typing unique_ptr<Foo> or unique_ptr<const Foo> is such a big deal. But then, I also consider having “using namespace std” the only somewhat sane way to use the STL.)
- omegalulw 5y ago+1. In modern C++ you use can use auto most of the time anyway :)
- tialaramex 5y agoThe thing about auto compared to Rust's inferred types is that when Rust isn't sure it won't infer anything and punts the problem back to you. let sandwiches = inventory.filter(delicious_cheeses).map(make_sandwich).collect(); ... won't compile because Rust can't infer what sort of container sandwiches is. Is it a vector? A list? Something custom? When C++ can't be sure in some places auto is obligatory anyway, so, too bad, you get what you're given. There are rules for what you get, but you might have reasonably intended something else, and so the effect is surprising.
- MauranKilom 5y ago> But then, I also consider having “using namespace std” the only somewhat sane way to use the STL. I hope you never ever do that in a header :)