1.. title:: clang-tidy - performance-implicit-conversion-in-loop
2
3performance-implicit-conversion-in-loop
4=======================================
5
6This warning appears in a range-based loop with a loop variable of const ref
7type where the type of the variable does not match the one returned by the
8iterator. This means that an implicit conversion happens, which can for example
9result in expensive deep copies.
10
11Example:
12
13.. code-block:: c++
14
15  map<int, vector<string>> my_map;
16  for (const pair<int, vector<string>>& p : my_map) {}
17  // The iterator type is in fact pair<const int, vector<string>>, which means
18  // that the compiler added a conversion, resulting in a copy of the vectors.
19
20The easiest solution is usually to use ``const auto&`` instead of writing the
21type manually.
22