libredex/DexStructure.cpp:116:21: error: loop variable '[v, c]' of type 'const std::1::pair<DexMethodRef *const, unsigned long>'
creates a copy from type 'const std::1::pair<DexMethodRef const, unsigned long>' [-Werror,-Wrange-loop-analysis]
for (const auto [v, c] : b) {
^
libredex/DexStructure.cpp:314:33: note: in instantiation of function template specialization 'set_difference_size<DexMethodRef >'
requested here
const auto extra_mrefs_size = set_difference_size(clazz_mrefs, m_mrefs);
^
libredex/DexStructure.cpp:116:10: note: use reference type 'const std::1::pair<DexMethodRef *const, unsigned long> &' to prevent
copying
for (const auto [v, c] : b) {
^~~~~~~
&
libredex/DexStructure.cpp:116:21: error: loop variable '[v, c]' of type 'const std::1::pair<DexFieldRef const, unsigned long>'
creates a copy from type 'const std::__1::pair<DexFieldRef const, unsigned long>' [-Werror,-Wrange-loop-analysis]
for (const auto [v, c] : b) {
^
libredex/DexStructure.cpp:326:33: note: in instantiation of function template specialization 'set_difference_size<DexFieldRef >'
requested here
const auto extra_frefs_size = set_difference_size(clazz_frefs, m_frefs);
^
libredex/DexStructure.cpp:116:10: note: use reference type 'const std::__1::pair<DexFieldRef const, unsigned long> &' to prevent
copying
for (const auto [v, c] : b) {
^~~~~~~
&
libredex/DexStructure.cpp:116:21: error: loop variable '[v, c]' of type 'const std::1::pair<DexType *const, unsigned long>' creates a
copy from type 'const std::1::pair<DexType const, unsigned long>' [-Werror,-Wrange-loop-analysis]
for (const auto [v, c] : b) {
^
libredex/DexStructure.cpp:340:33: note: in instantiation of function template specialization 'set_difference_size<DexType >' requested
here
const auto extra_trefs_size = set_difference_size(clazz_trefs, m_trefs);
^
libredex/DexStructure.cpp:116:10: note: use reference type 'const std::__1::pair<DexType *const, unsigned long> &' to prevent copying
for (const auto [v, c] : b) {
^~~~~~~
&
3 errors generated.
make[2]: [libredex/DexStructure.lo] Error 1
make[1]: [all-recursive] Error 1
make: *** [all] Error 2
Returns the count of elements present in a but not in b.
*/
template
size_t set_difference_size(const std::unordered_set& a,
const std::unordered_map<T, size_t>& b) {
size_t result = a.size();
if (a.size() <= b.size()) {
for (const auto& v : a) {
result -= b.count(v);
}
} else {
for (const auto& [v, c] : b) {
result -= a.count(v);
}
}
return result;
}
for (const auto [v,c] : b) -> for (const auto& [v,c] : b) to prevent copying
MacOs 12.3.1 intel autoconf: 2.71 automake: 1.16.5 libtool: 2.4.7 xcode-select version 2395
this is the error:
libredex/DexStructure.cpp:116:21: error: loop variable '[v, c]' of type 'const std::1::pair<DexMethodRef *const, unsigned long>' creates a copy from type 'const std::1::pair<DexMethodRef const, unsigned long>' [-Werror,-Wrange-loop-analysis] for (const auto [v, c] : b) { ^ libredex/DexStructure.cpp:314:33: note: in instantiation of function template specialization 'set_difference_size<DexMethodRef >' requested here const auto extra_mrefs_size = set_difference_size(clazz_mrefs, m_mrefs); ^ libredex/DexStructure.cpp:116:10: note: use reference type 'const std::1::pair<DexMethodRef *const, unsigned long> &' to prevent copying for (const auto [v, c] : b) { ^
~~~~~~ & libredex/DexStructure.cpp:116:21: error: loop variable '[v, c]' of type 'const std::1::pair<DexFieldRef const, unsigned long>' creates a copy from type 'const std::__1::pair<DexFieldRef const, unsigned long>' [-Werror,-Wrange-loop-analysis] for (const auto [v, c] : b) { ^ libredex/DexStructure.cpp:326:33: note: in instantiation of function template specialization 'set_difference_size<DexFieldRef >' requested here const auto extra_frefs_size = set_difference_size(clazz_frefs, m_frefs); ^ libredex/DexStructure.cpp:116:10: note: use reference type 'const std::__1::pair<DexFieldRef const, unsigned long> &' to prevent copying for (const auto [v, c] : b) { ^~~~~~~ & libredex/DexStructure.cpp:116:21: error: loop variable '[v, c]' of type 'const std::1::pair<DexType *const, unsigned long>' creates a copy from type 'const std::1::pair<DexType const, unsigned long>' [-Werror,-Wrange-loop-analysis] for (const auto [v, c] : b) { ^ libredex/DexStructure.cpp:340:33: note: in instantiation of function template specialization 'set_difference_size<DexType >' requested here const auto extra_trefs_size = set_difference_size(clazz_trefs, m_trefs); ^ libredex/DexStructure.cpp:116:10: note: use reference type 'const std::__1::pair<DexType *const, unsigned long> &' to prevent copying for (const auto [v, c] : b) { ^~~~~~~ & 3 errors generated. make[2]: [libredex/DexStructure.lo] Error 1 make[1]: [all-recursive] Error 1 make: *** [all] Error 2