Fix StringBuffer compilation error in VS2013
Add move constructor and prohibit copy constructor and assignment operator.
This commit is contained in:
parent
7eee4303c7
commit
a6117dae16
@ -33,11 +33,21 @@ RAPIDJSON_NAMESPACE_BEGIN
|
|||||||
\note implements Stream concept
|
\note implements Stream concept
|
||||||
*/
|
*/
|
||||||
template <typename Encoding, typename Allocator = CrtAllocator>
|
template <typename Encoding, typename Allocator = CrtAllocator>
|
||||||
struct GenericStringBuffer {
|
class GenericStringBuffer {
|
||||||
|
public:
|
||||||
typedef typename Encoding::Ch Ch;
|
typedef typename Encoding::Ch Ch;
|
||||||
|
|
||||||
GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {}
|
GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {}
|
||||||
|
|
||||||
|
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
|
||||||
|
GenericStringBuffer(GenericStringBuffer&& rhs) : stack_(std::move(rhs.stack_)) {}
|
||||||
|
GenericStringBuffer& operator=(GenericStringBuffer&& rhs) {
|
||||||
|
if (&rhs != this)
|
||||||
|
stack_ = std::move(rhs.stack_);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void Put(Ch c) { *stack_.template Push<Ch>() = c; }
|
void Put(Ch c) { *stack_.template Push<Ch>() = c; }
|
||||||
void Flush() {}
|
void Flush() {}
|
||||||
|
|
||||||
@ -63,6 +73,11 @@ struct GenericStringBuffer {
|
|||||||
|
|
||||||
static const size_t kDefaultCapacity = 256;
|
static const size_t kDefaultCapacity = 256;
|
||||||
mutable internal::Stack<Allocator> stack_;
|
mutable internal::Stack<Allocator> stack_;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Prohibit copy constructor & assignment operator.
|
||||||
|
GenericStringBuffer(const GenericStringBuffer&);
|
||||||
|
GenericStringBuffer& operator=(const GenericStringBuffer&);
|
||||||
};
|
};
|
||||||
|
|
||||||
//! String buffer with UTF8 encoding
|
//! String buffer with UTF8 encoding
|
||||||
|
Loading…
x
Reference in New Issue
Block a user