From d07a3d2f4c9f1255b4803e9c032e5ab811a081d3 Mon Sep 17 00:00:00 2001 From: Wouter van Oortmerssen Date: Thu, 11 Apr 2019 16:14:38 -0700 Subject: [PATCH] Fixed VS2010 build. Change-Id: I3ee68c5f250d6baa02060ab2ecbc0f0fe254a9d8 --- samples/monster_generated.h | 3 ++- src/idl_gen_cpp.cpp | 3 ++- tests/monster_test_generated.h | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/samples/monster_generated.h b/samples/monster_generated.h index d9d64793d..b31a8ed5c 100644 --- a/samples/monster_generated.h +++ b/samples/monster_generated.h @@ -119,8 +119,9 @@ struct EquipmentUnion { void Reset(); #ifndef FLATBUFFERS_CPP98_STL - template ::type> + template void Set(T&& val) { + using RT = typename std::remove_reference::type; Reset(); type = EquipmentTraits::enum_value; if (type != Equipment_NONE) { diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp index 0c964d4bc..d3dfeb10e 100644 --- a/src/idl_gen_cpp.cpp +++ b/src/idl_gen_cpp.cpp @@ -1096,8 +1096,9 @@ class CppGenerator : public BaseGenerator { code_ += ""; if (!enum_def.uses_multiple_type_instances) { code_ += "#ifndef FLATBUFFERS_CPP98_STL"; - code_ += " template ::type>"; + code_ += " template "; code_ += " void Set(T&& val) {"; + code_ += " using RT = typename std::remove_reference::type;"; code_ += " Reset();"; code_ += " type = {{NAME}}Traits::enum_value;"; code_ += " if (type != {{NONE}}) {"; diff --git a/tests/monster_test_generated.h b/tests/monster_test_generated.h index a55a42754..3a440073f 100644 --- a/tests/monster_test_generated.h +++ b/tests/monster_test_generated.h @@ -207,8 +207,9 @@ struct AnyUnion { void Reset(); #ifndef FLATBUFFERS_CPP98_STL - template ::type> + template void Set(T&& val) { + using RT = typename std::remove_reference::type; Reset(); type = AnyTraits::enum_value; if (type != Any_NONE) { @@ -348,8 +349,9 @@ struct AnyUniqueAliasesUnion { void Reset(); #ifndef FLATBUFFERS_CPP98_STL - template ::type> + template void Set(T&& val) { + using RT = typename std::remove_reference::type; Reset(); type = AnyUniqueAliasesTraits::enum_value; if (type != AnyUniqueAliases_NONE) {