diff options
author | Ronny Krüger <rcane@rkxs.de> | 2018-04-16 09:58:24 +0200 |
---|---|---|
committer | Ronny Krüger <rcane@rkxs.de> | 2018-04-16 09:58:24 +0200 |
commit | 7d6d5f91320af20d77d57a198c54abe6e36a00ea (patch) | |
tree | a91c80c18a70f70ac5f8b94fb9951baa608d268d /src/google/protobuf/compiler/cpp | |
parent | 320d56c833f835f40c56bdaf2a375768cdd1b334 (diff) |
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<std::unique_ptr<Foo> []> 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<std::unique_ptr<Foo>> foos;
This not only fixes the compiler error but is also more readable than
previous version.
Diffstat (limited to 'src/google/protobuf/compiler/cpp')
-rw-r--r-- | src/google/protobuf/compiler/cpp/cpp_field.cc | 3 | ||||
-rw-r--r-- | src/google/protobuf/compiler/cpp/cpp_field.h | 2 |
2 files changed, 2 insertions, 3 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_field.cc b/src/google/protobuf/compiler/cpp/cpp_field.cc index 33ffe574..0de20f84 100644 --- a/src/google/protobuf/compiler/cpp/cpp_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_field.cc @@ -117,8 +117,7 @@ FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor, SCCAnalyzer* scc_analyzer) : descriptor_(descriptor), options_(options), - field_generators_( - new std::unique_ptr<FieldGenerator>[descriptor->field_count()]) { + field_generators_(descriptor->field_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/cpp/cpp_field.h b/src/google/protobuf/compiler/cpp/cpp_field.h index 6cb466a8..8cdbe886 100644 --- a/src/google/protobuf/compiler/cpp/cpp_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_field.h @@ -203,7 +203,7 @@ class FieldGeneratorMap { private: const Descriptor* descriptor_; const Options& options_; - std::unique_ptr<std::unique_ptr<FieldGenerator> []> field_generators_; + std::vector<std::unique_ptr<FieldGenerator>> field_generators_; static FieldGenerator* MakeGenerator(const FieldDescriptor* field, const Options& options, |