Skip to content

Commit

Permalink
Merge pull request #391 from pah/fix/no-doc2value-move
Browse files Browse the repository at this point in the history
Prohibit C++11 move from Document to Value
  • Loading branch information
miloyip committed Jul 20, 2015
2 parents 9b28107 + fec9e8a commit 3003b84
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion include/rapidjson/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ RAPIDJSON_NAMESPACE_BEGIN
template <typename Encoding, typename Allocator>
class GenericValue;

template <typename Encoding, typename Allocator, typename StackAllocator>
class GenericDocument;

//! Name-value pair in a JSON object value.
/*!
This class was internal to GenericValue. It used to be a inner struct.
Expand Down Expand Up @@ -446,6 +449,16 @@ class GenericValue {
//! Copy constructor is not permitted.
GenericValue(const GenericValue& rhs);

#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
//! Moving from a GenericDocument is not permitted.
template <typename StackAllocator>
GenericValue(GenericDocument<Encoding,Allocator,StackAllocator>&& rhs);

//! Move assignment from a GenericDocument is not permitted.
template <typename StackAllocator>
GenericValue& operator=(GenericDocument<Encoding,Allocator,StackAllocator>&& rhs);
#endif

public:

//! Constructor with JSON value type.
Expand Down Expand Up @@ -1792,7 +1805,7 @@ class GenericDocument : public GenericValue<Encoding, Allocator> {
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
//! Move constructor in C++11
GenericDocument(GenericDocument&& rhs) RAPIDJSON_NOEXCEPT
: ValueType(std::move(rhs)),
: ValueType(std::forward<ValueType>(rhs)), // explicit cast to avoid prohibited move from Document
allocator_(rhs.allocator_),
ownAllocator_(rhs.ownAllocator_),
stack_(std::move(rhs.stack_)),
Expand Down

0 comments on commit 3003b84

Please sign in to comment.