Skip to content

Commit bc151e8

Browse files
author
Bruno Ribeiro
committed
Fix move constructor and Windows compatibility
1 parent 8f64088 commit bc151e8

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

library/cpp/base.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ template<typename T> struct traits
137137
if (temp.empty()) return false;
138138

139139
#if defined(_WIN32) || defined(_WIN64)
140-
static _locale_t loc = _create_locale(LC_NUMERIC_MASK | LC_MONETARY_MASK, "C");
141-
if (loc == 0) return false;
140+
static _locale_t loc = _create_locale(LC_NUMERIC, "C");
141+
if (loc == NULL) return false;
142142
value = (T) _strtod_l(temp.c_str(), NULL, loc);
143143
#else
144144
static locale_t loc = newlocale(LC_NUMERIC_MASK | LC_MONETARY_MASK, "C", 0);

library/cpp/cppgen.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,15 @@ static void generateMoveCtor( GeneratorContext &ctx, const Message &message )
205205
{
206206
ctx.printer(
207207
"#if __cplusplus >= 201103L\n"
208-
"$1$($1$ &&that) { this->swap(that); }\n"
209-
"#endif\n", message.name);
208+
"$1$($1$ &&that) {\n\t", message.name);
209+
for (auto fi = message.fields.begin(); fi != message.fields.end(); ++fi)
210+
{
211+
if (fi->type.id == TYPE_MESSAGE || fi->type.repeated)
212+
ctx.printer("this->$1$.swap(that.$1$);\n", fieldStorage(*fi));
213+
else
214+
ctx.printer("this->$1$ = that.$1$;\n", fieldStorage(*fi));
215+
}
216+
ctx.printer("\b}\n#endif\n");
210217
}
211218

212219

0 commit comments

Comments
 (0)