Avoid compiler crash with Clang 6.0

Instead of C++17 structured bindings, use a plain `const auto&` and annotate
arguments with comments instead.

We still support Clang 6.0, as that is the compiler that ships with Ubuntu
18.04 LTS by default.

PiperOrigin-RevId: 428016214
Change-Id: I3a43b2d47c6825ac4425d22018750282cfe23c1b
This commit is contained in:
Christian Blichmann 2022-02-11 09:08:23 -08:00 committed by Copybara-Service
parent 36d0f928c6
commit d1ed8ac66e

View File

@ -31,8 +31,11 @@ void SaveStatusToProto(const absl::Status& status, StatusProto* out) {
absl::Status MakeStatusFromProto(const StatusProto& proto) {
absl::Status status(static_cast<absl::StatusCode>(proto.code()),
proto.message());
for (const auto& [type_key, payload] : proto.payloads()) {
status.SetPayload(type_key, absl::Cord(payload));
// Note: Using C++17 structured bindings instead of `entry` crashes Clang 6.0
// on Ubuntu 18.04 (bionic).
for (const auto& entry : proto.payloads()) {
status.SetPayload(/*type_url=*/entry.first,
/*payload=*/absl::Cord(entry.second));
}
return status;
}