From 41d211cd51acc97240217d9dbebd0b27ceb41242 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Fri, 11 Jul 2014 08:27:28 +0200 Subject: [PATCH] GenericValue::operator= : fixup assignment operator While MSVC doesn't like the explicit `.template operator=<...>` syntax (see 4f40ed6), Clang 3.5 complains about the absence of it: In file included from ../../test/perftest/rapidjsontest.cpp:6: ../../include/rapidjson/document.h:504:18: error: use 'template' keyword to treat 'operator =' as a dependent template name return (*this).operator=(str); ^ template Delegate both operator=(StringRefType) and operator=(T) to operator(GenericValue&). --- include/rapidjson/document.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 8406598..45b6c3f 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -501,7 +501,8 @@ public: \see GenericStringRef, operator=(T) */ GenericValue& operator=(StringRefType str) { - return (*this).operator=(str); + GenericValue s(str); + return *this = s; } //! Assignment with primitive types. @@ -519,9 +520,8 @@ public: template RAPIDJSON_DISABLEIF_RETURN(internal::IsPointer,GenericValue&) operator=(T value) { - this->~GenericValue(); - new (this) GenericValue(value); - return *this; + GenericValue v(value); + return *this = v; } //! Deep-copy assignment from Value