1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
From 35e800d81f28c632956c5a592e3cbe8085ecd430 Mon Sep 17 00:00:00 2001
From: Corey Tabaka <eieio@google.com>
Date: Tue, 2 Nov 2021 18:51:11 -0700
Subject: [PATCH] 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.
---
include/nop/base/map.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/nop/base/map.h b/include/nop/base/map.h
index 7c4cb9a..1b028a9 100644
--- a/include/nop/base/map.h
+++ b/include/nop/base/map.h
@@ -67,7 +67,7 @@ struct Encoding<std::map<Key, T, Compare, Allocator>>
if (!status)
return status;
- for (const std::pair<Key, T>& element : value) {
+ for (const auto& element : value) {
status = Encoding<Key>::Write(element.first, writer);
if (!status)
return status;
@@ -139,7 +139,7 @@ struct Encoding<std::unordered_map<Key, T, Hash, KeyEqual, Allocator>>
if (!status)
return status;
- for (const std::pair<Key, T>& element : value) {
+ for (const auto& element : value) {
status = Encoding<Key>::Write(element.first, writer);
if (!status)
return status;
|