@@ -222,18 +222,42 @@ class MemoryPoolAllocator {
222
222
{
223
223
RAPIDJSON_NOEXCEPT_ASSERT (rhs.shared_ ->refcount > 0 );
224
224
++rhs.shared_ ->refcount ;
225
+ this ->~MemoryPoolAllocator ();
226
+ baseAllocator_ = rhs.baseAllocator_ ;
227
+ chunk_capacity_ = rhs.chunk_capacity_ ;
228
+ shared_ = rhs.shared_ ;
229
+ return *this ;
230
+ }
225
231
232
+ #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
233
+ MemoryPoolAllocator (MemoryPoolAllocator&& rhs) RAPIDJSON_NOEXCEPT :
234
+ chunk_capacity_(rhs.chunk_capacity_),
235
+ baseAllocator_(rhs.baseAllocator_),
236
+ shared_(rhs.shared_)
237
+ {
238
+ RAPIDJSON_NOEXCEPT_ASSERT (rhs.shared_ ->refcount > 0 );
239
+ rhs.shared_ = 0 ;
240
+ }
241
+ MemoryPoolAllocator& operator =(MemoryPoolAllocator&& rhs) RAPIDJSON_NOEXCEPT
242
+ {
243
+ RAPIDJSON_NOEXCEPT_ASSERT (rhs.shared_ ->refcount > 0 );
226
244
this ->~MemoryPoolAllocator ();
227
245
baseAllocator_ = rhs.baseAllocator_ ;
228
246
chunk_capacity_ = rhs.chunk_capacity_ ;
229
247
shared_ = rhs.shared_ ;
248
+ rhs.shared_ = 0 ;
230
249
return *this ;
231
250
}
251
+ #endif
232
252
233
253
// ! Destructor.
234
254
/* ! This deallocates all memory chunks, excluding the user-supplied buffer.
235
255
*/
236
256
~MemoryPoolAllocator () RAPIDJSON_NOEXCEPT {
257
+ if (!shared_) {
258
+ // do nothing if moved
259
+ return ;
260
+ }
237
261
if (shared_->refcount > 1 ) {
238
262
--shared_->refcount ;
239
263
return ;
@@ -449,6 +473,17 @@ class StdAllocator :
449
473
baseAllocator_ (rhs.baseAllocator_)
450
474
{ }
451
475
476
+ #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
477
+ StdAllocator (StdAllocator&& rhs) RAPIDJSON_NOEXCEPT :
478
+ allocator_type(std::move(rhs)),
479
+ baseAllocator_(std::move(rhs.baseAllocator_))
480
+ { }
481
+ #endif
482
+ #if RAPIDJSON_HAS_CXX11
483
+ using propagate_on_container_move_assignment = std::true_type;
484
+ using propagate_on_container_swap = std::true_type;
485
+ #endif
486
+
452
487
/* implicit */
453
488
StdAllocator (const BaseAllocator& allocator) RAPIDJSON_NOEXCEPT :
454
489
allocator_type (),
@@ -549,6 +584,10 @@ class StdAllocator :
549
584
deallocate<value_type>(p, n);
550
585
}
551
586
587
+ #if RAPIDJSON_HAS_CXX11
588
+ using is_always_equal = std::is_empty<BaseAllocator>;
589
+ #endif
590
+
552
591
template <typename U>
553
592
bool operator ==(const StdAllocator<U, BaseAllocator>& rhs) const RAPIDJSON_NOEXCEPT
554
593
{
@@ -561,6 +600,7 @@ class StdAllocator :
561
600
}
562
601
563
602
// ! rapidjson Allocator concept
603
+ static const bool kNeedFree = BaseAllocator::kNeedFree ;
564
604
void * Malloc (size_t size)
565
605
{
566
606
return baseAllocator_.Malloc (size);
0 commit comments