Been trying out C++ auto in a few different places and use cases to see how it feels and whether we want to use it more. Prevailing opinion in my team is clear: auto harms readability, comes with unwelcome gotchas, and is generally irritating. Very on brand for C++ though.
-
-
Vastauksena käyttäjälle @promit_roy
I've just had a bug caused by an auto, I was expecting a ref, the deducted type wasn't a ref :( Ironically sometimes auto requires to be more cautious.
3 vastausta 0 uudelleentwiittausta 2 tykkäystä -
Vastauksena käyttäjille @LMCrashy ja @promit_roy
This used to be my issue with auto, till I realized that if I had wanted a copy, and auto deduced a ref type, there would be no syntax for getting a copy. Use auto& for reference. Use auto for copy.
2 vastausta 0 uudelleentwiittausta 5 tykkäystä
And for funzies, if the type returned is a const ref, auto&& will work, while auto& will not. Of course, const auto& would also work. The one thing I had to really work at was pointers. Those are by copy, even though in my head they are references.
Lataaminen näyttää kestävän hetken.
Twitter saattaa olla ruuhkautunut tai ongelma on muuten hetkellinen. Yritä uudelleen tai käy Twitterin tilasivulla saadaksesi lisätietoja.