Merge pull request #8917 from Sil3ntStorm/issue-6159

Use if constexpr in template functions
pull/8928/head
Joshua Haberman 3 years ago committed by GitHub
commit fe54248aba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/google/protobuf/port_def.inc
  2. 7
      src/google/protobuf/stubs/stringprintf.cc

@ -766,6 +766,8 @@
#pragma warning(disable : 4073)
// To silence the fact that we will pop this push from another file
#pragma warning(disable : 5031)
// Conditional expression is constant
#pragma warning(disable: 4127)
#endif
// We don't want code outside port_def doing complex testing, so

@ -44,14 +44,11 @@ namespace google {
namespace protobuf {
#ifdef _MSC_VER
enum { IS_COMPILER_MSVC = 1 };
#ifndef va_copy
// Define va_copy for MSVC. This is a hack, assuming va_list is simply a
// pointer into the stack and is safe to copy.
#define va_copy(dest, src) ((dest) = (src))
#endif
#else
enum { IS_COMPILER_MSVC = 0 };
#endif
void StringAppendV(std::string* dst, const char* format, va_list ap) {
@ -74,13 +71,15 @@ void StringAppendV(std::string* dst, const char* format, va_list ap) {
return;
}
if (IS_COMPILER_MSVC) {
#ifdef _MSC_VER
{
// Error or MSVC running out of space. MSVC 8.0 and higher
// can be asked about space needed with the special idiom below:
va_copy(backup_ap, ap);
result = vsnprintf(nullptr, 0, format, backup_ap);
va_end(backup_ap);
}
#endif
if (result < 0) {
// Just an error.

Loading…
Cancel
Save