diff --git a/cpp/utils.h b/cpp/utils.h index 75ba6ca..1cba8ef 100644 --- a/cpp/utils.h +++ b/cpp/utils.h @@ -31,6 +31,7 @@ template static void RepeatedFieldToVector(const T1& t1, T2& t2) { + t2.clear(); for (auto& val : t1) { t2.push_back(val); } @@ -40,6 +41,7 @@ template static void RepeatedFieldToSet(const T1& t1, T2& t2) { + t2.clear(); for (auto& val : t1) { t2.insert(val); } @@ -49,6 +51,7 @@ template static void VectorToRepeatedField(const T1& t1, T2& t2) { + t2.Clear(); for (auto& val : t1) { *t2.Add() = val; } @@ -58,6 +61,7 @@ template static void SetToRepeatedField(const T1& t1, T2& t2) { + t2.Clear(); for (auto& val : t1) { *t2.Add() = val; }