diff options
author | Abseil Team <absl-team@google.com> | 2024-02-28 09:40:08 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-02-28 09:40:50 -0800 |
commit | cfde5f74e276049727f9556f13473a59fe77d9eb (patch) | |
tree | b3a432d8629d91cde51ab9c00c3f0322ccd98383 | |
parent | 653a6710cb1737185daa010dbfbcc46e3fa1c1d8 (diff) |
Workaround for NVIDIA C++ compiler being unable to parse variadic expansions in range of range-based for loop
Fixes: #1629
PiperOrigin-RevId: 611131201
Change-Id: I787731e00207b544ee16055e6e0d323a5094a433
-rw-r--r-- | absl/strings/str_cat.h | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/absl/strings/str_cat.h b/absl/strings/str_cat.h index bc8ea7d4..33355bfd 100644 --- a/absl/strings/str_cat.h +++ b/absl/strings/str_cat.h @@ -606,18 +606,17 @@ StrAppend(absl::Nonnull<String*> str, T... args) { ptrdiff_t n; // The length of the current argument typename String::pointer pos = &(*str)[old_size]; using SomeTrivialEmptyType = std::false_type; - // Ugly code due to the lack of C++14 fold expression makes us. - const SomeTrivialEmptyType dummy1; - for (const SomeTrivialEmptyType& dummy2 : - {(/* Comma expressions are poor man's C++17 fold expression for C++14 */ - (void)(n = lengths[i]), - (void)(n < 0 ? (void)(*pos++ = '-'), (n = ~n) : 0), - (void)absl::numbers_internal::FastIntToBufferBackward( - absl::numbers_internal::UnsignedAbsoluteValue(std::move(args)), - pos += n, static_cast<uint32_t>(n)), - (void)++i, dummy1)...}) { - (void)dummy2; // Remove & migrate to fold expressions in C++17 - } + const SomeTrivialEmptyType dummy; + // Ugly code due to the lack of C++17 fold expressions + const SomeTrivialEmptyType dummies[] = { + (/* Comma expressions are poor man's C++17 fold expression for C++14 */ + (void)(n = lengths[i]), + (void)(n < 0 ? (void)(*pos++ = '-'), (n = ~n) : 0), + (void)absl::numbers_internal::FastIntToBufferBackward( + absl::numbers_internal::UnsignedAbsoluteValue(std::move(args)), + pos += n, static_cast<uint32_t>(n)), + (void)++i, dummy)...}; + (void)dummies; // Remove & migrate to fold expressions in C++17 } // Helper function for the future StrCat default floating-point format, %.6g |