C++ auto Copies Every Element
When C++ auto is better: map<int,string> coll; for (const auto& elem : coll) {...} // no elem copy for (const pair<int,string>& elem : coll) {...} // copies elems Yes, because const for the key is missing the conversion creates a copy of each elem. Thx to Federico Kircheis
A programming meme explains that using `const auto&` in a C++ range-based loop avoids copying map elements, while explicitly declaring `const pair<int,string>&` can trigger a conversion and copy because the map key is implicitly const. It is shared as a humorous reaction to subtle C++ type and performance pitfalls. EN: A programming meme explains that using `const auto&` in a C++ range-based loop avoids copying map elements, while explicitly declaring `const pair<int,string>&` can trigger a conversion and copy because the map key is implicitly const. It is shared as a humorous reaction to subtle C++ type and performance pitfalls.
computer programmer / программистman with glasses / мужчина в очкахsocial media post / публикация в соцсетиC++ code / код C++code text / текст кодаmap container / контейнер mapkey-value pair / пара ключ-значениеcurly braces / фигурные скобкиdark interface / тёмный интерфейсprofile photo / фотография профиля
- @ithueti / 950 2019-05-26
- Type
- image
- Size
- 761×800 · 84.4 KiB
- Mood
- отвратительно смешно
- Language
- en
- Added