Commit cfde5f74 by Abseil Team Committed by Copybara-Service

Workaround for NVIDIA C++ compiler being unable to parse variadic expansions in…

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
parent 653a6710
...@@ -606,18 +606,17 @@ StrAppend(absl::Nonnull<String*> str, T... args) { ...@@ -606,18 +606,17 @@ StrAppend(absl::Nonnull<String*> str, T... args) {
ptrdiff_t n; // The length of the current argument ptrdiff_t n; // The length of the current argument
typename String::pointer pos = &(*str)[old_size]; typename String::pointer pos = &(*str)[old_size];
using SomeTrivialEmptyType = std::false_type; using SomeTrivialEmptyType = std::false_type;
// Ugly code due to the lack of C++14 fold expression makes us. const SomeTrivialEmptyType dummy;
const SomeTrivialEmptyType dummy1; // Ugly code due to the lack of C++17 fold expressions
for (const SomeTrivialEmptyType& dummy2 : const SomeTrivialEmptyType dummies[] = {
{(/* Comma expressions are poor man's C++17 fold expression for C++14 */ (/* Comma expressions are poor man's C++17 fold expression for C++14 */
(void)(n = lengths[i]), (void)(n = lengths[i]),
(void)(n < 0 ? (void)(*pos++ = '-'), (n = ~n) : 0), (void)(n < 0 ? (void)(*pos++ = '-'), (n = ~n) : 0),
(void)absl::numbers_internal::FastIntToBufferBackward( (void)absl::numbers_internal::FastIntToBufferBackward(
absl::numbers_internal::UnsignedAbsoluteValue(std::move(args)), absl::numbers_internal::UnsignedAbsoluteValue(std::move(args)),
pos += n, static_cast<uint32_t>(n)), pos += n, static_cast<uint32_t>(n)),
(void)++i, dummy1)...}) { (void)++i, dummy)...};
(void)dummy2; // Remove & migrate to fold expressions in C++17 (void)dummies; // Remove & migrate to fold expressions in C++17
}
} }
// Helper function for the future StrCat default floating-point format, %.6g // Helper function for the future StrCat default floating-point format, %.6g
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment