mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-02 00:38:26 +01:00
Added move-constructor and move-assignment to BasicJsonDocument
This commit is contained in:
@@ -52,6 +52,14 @@ class BasicJsonDocument : AllocatorOwner<TAllocator>, public JsonDocument {
|
||||
set(src);
|
||||
}
|
||||
|
||||
#if ARDUINOJSON_HAS_RVALUE_REFERENCES
|
||||
BasicJsonDocument(BasicJsonDocument&& src)
|
||||
: AllocatorOwner<TAllocator>(src), JsonDocument(src) {
|
||||
src._data.setNull();
|
||||
src._pool = MemoryPool(0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
// disambiguate
|
||||
BasicJsonDocument(VariantRef src)
|
||||
: JsonDocument(allocPool(src.memoryUsage())) {
|
||||
@@ -68,6 +76,17 @@ class BasicJsonDocument : AllocatorOwner<TAllocator>, public JsonDocument {
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ARDUINOJSON_HAS_RVALUE_REFERENCES
|
||||
BasicJsonDocument& operator=(BasicJsonDocument&& src) {
|
||||
freePool();
|
||||
_data = src._data;
|
||||
_pool = src._pool;
|
||||
src._data.setNull();
|
||||
src._pool = MemoryPool(0, 0);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
BasicJsonDocument& operator=(const T& src) {
|
||||
reallocPoolIfTooSmall(src.memoryUsage());
|
||||
|
||||
Reference in New Issue
Block a user