Skip to content

Commit 35e800d

Browse files
committed
Fix for -Werror=range-loop-construct in GCC 11.
Range iteration in GCC 11 triggers range-loop-construct due to mismatch between element types (const key) forcing a copy. Switch to const auto& to avoid the type mismatch.
1 parent 910b558 commit 35e800d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/nop/base/map.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct Encoding<std::map<Key, T, Compare, Allocator>>
6767
if (!status)
6868
return status;
6969

70-
for (const std::pair<Key, T>& element : value) {
70+
for (const auto& element : value) {
7171
status = Encoding<Key>::Write(element.first, writer);
7272
if (!status)
7373
return status;
@@ -139,7 +139,7 @@ struct Encoding<std::unordered_map<Key, T, Hash, KeyEqual, Allocator>>
139139
if (!status)
140140
return status;
141141

142-
for (const std::pair<Key, T>& element : value) {
142+
for (const auto& element : value) {
143143
status = Encoding<Key>::Write(element.first, writer);
144144
if (!status)
145145
return status;

0 commit comments

Comments
 (0)