From 7d6d5f91320af20d77d57a198c54abe6e36a00ea Mon Sep 17 00:00:00 2001 From: Ronny Krüger Date: Mon, 16 Apr 2018 09:58:24 +0200 Subject: Fixed a Visual Studio 2017 build error. (#4488) The current 15.6.x versions of Visual Studio 2017 contain a bug that prevent them from compiling the following construct under certain conditions: std::unique_ptr []> foos; This will fail to compile if Foo is an abstract class. To work-around the problem the whole construct was change into: std::vector> foos; This not only fixes the compiler error but is also more readable than previous version. --- src/google/protobuf/compiler/objectivec/objectivec_field.cc | 6 ++---- src/google/protobuf/compiler/objectivec/objectivec_field.h | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src/google/protobuf/compiler/objectivec') diff --git a/src/google/protobuf/compiler/objectivec/objectivec_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_field.cc index 67b026c3..f74599ba 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_field.cc @@ -410,10 +410,8 @@ bool RepeatedFieldGenerator::RuntimeUsesHasBit(void) const { FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor, const Options& options) : descriptor_(descriptor), - field_generators_( - new std::unique_ptr[descriptor->field_count()]), - extension_generators_( - new std::unique_ptr[descriptor->extension_count()]) { + field_generators_(descriptor->field_count()), + extension_generators_(descriptor->extension_count()) { // Construct all the FieldGenerators. for (int i = 0; i < descriptor->field_count(); i++) { field_generators_[i].reset( diff --git a/src/google/protobuf/compiler/objectivec/objectivec_field.h b/src/google/protobuf/compiler/objectivec/objectivec_field.h index 888cfefc..216034d0 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_field.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_field.h @@ -182,8 +182,8 @@ class FieldGeneratorMap { private: const Descriptor* descriptor_; - std::unique_ptr[]> field_generators_; - std::unique_ptr[]> extension_generators_; + std::vector> field_generators_; + std::vector> extension_generators_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap); }; -- cgit v1.2.3