From bc151e89e22b6bbce2c80c6d0d80d8d8fe19892f Mon Sep 17 00:00:00 2001 From: Bruno Ribeiro Date: Wed, 30 Jan 2019 16:31:37 -0200 Subject: [PATCH] Fix move constructor and Windows compatibility --- library/cpp/base.cc | 4 ++-- library/cpp/cppgen.cc | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/library/cpp/base.cc b/library/cpp/base.cc index e094bbb..3298ca7 100644 --- a/library/cpp/base.cc +++ b/library/cpp/base.cc @@ -137,8 +137,8 @@ template struct traits if (temp.empty()) return false; #if defined(_WIN32) || defined(_WIN64) - static _locale_t loc = _create_locale(LC_NUMERIC_MASK | LC_MONETARY_MASK, "C"); - if (loc == 0) return false; + static _locale_t loc = _create_locale(LC_NUMERIC, "C"); + if (loc == NULL) return false; value = (T) _strtod_l(temp.c_str(), NULL, loc); #else static locale_t loc = newlocale(LC_NUMERIC_MASK | LC_MONETARY_MASK, "C", 0); diff --git a/library/cpp/cppgen.cc b/library/cpp/cppgen.cc index 52a27ce..b139b9b 100644 --- a/library/cpp/cppgen.cc +++ b/library/cpp/cppgen.cc @@ -205,8 +205,15 @@ static void generateMoveCtor( GeneratorContext &ctx, const Message &message ) { ctx.printer( "#if __cplusplus >= 201103L\n" - "$1$($1$ &&that) { this->swap(that); }\n" - "#endif\n", message.name); + "$1$($1$ &&that) {\n\t", message.name); + for (auto fi = message.fields.begin(); fi != message.fields.end(); ++fi) + { + if (fi->type.id == TYPE_MESSAGE || fi->type.repeated) + ctx.printer("this->$1$.swap(that.$1$);\n", fieldStorage(*fi)); + else + ctx.printer("this->$1$ = that.$1$;\n", fieldStorage(*fi)); + } + ctx.printer("\b}\n#endif\n"); }