Skip to content

Commit

Permalink
Fix move constructor and Windows compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Ribeiro committed Jan 30, 2019
1 parent 8f64088 commit bc151e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions library/cpp/base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ template<typename T> 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);
Expand Down
11 changes: 9 additions & 2 deletions library/cpp/cppgen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}


Expand Down

0 comments on commit bc151e8

Please sign in to comment.