memesearch
C++ auto Copies Every Element

C++ auto Copies Every Element

Download Find similar pictures
Text on the meme
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
What it means

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.

Who
Objects
Tags
Source
Type
image
Size
761×800 · 84.4 KiB
Mood
отвратительно смешно
Language
en
Added