From 2b73169471458aec83230a805d92d4659a0b6036 Mon Sep 17 00:00:00 2001 From: Tall??di Mih??ly Date: Mon, 19 Sep 2016 18:14:34 +0200 Subject: [PATCH] Move constructor support for Writer This also requires turning off the c++98 compatibility checks when building with clang. --- include/rapidjson/writer.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/rapidjson/writer.h b/include/rapidjson/writer.h index c5a3b98a92..45d9cb03af 100644 --- a/include/rapidjson/writer.h +++ b/include/rapidjson/writer.h @@ -42,6 +42,7 @@ RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_OFF(padded) RAPIDJSON_DIAG_OFF(unreachable-code) +RAPIDJSON_DIAG_OFF(c++98-compat) #endif RAPIDJSON_NAMESPACE_BEGIN @@ -103,6 +104,14 @@ class Writer { Writer(StackAllocator* allocator = 0, size_t levelDepth = kDefaultLevelDepth) : os_(0), level_stack_(allocator, levelDepth * sizeof(Level)), maxDecimalPlaces_(kDefaultMaxDecimalPlaces), hasRoot_(false) {} +#if RAPIDJSON_HAS_CXX11_RVALUE_REFS + Writer(Writer &&other) : + os_(other.os_), level_stack_(std::move(other.level_stack_)), maxDecimalPlaces_(other.maxDecimalPlaces_), hasRoot_(other.hasRoot_) + { + other.os_=nullptr; + } +#endif + //! Reset the writer with a new stream. /*! This function reset the writer with a new stream and default settings,