diff --git a/src/ArduinoJson/Array/ArrayImpl.hpp b/src/ArduinoJson/Array/ArrayImpl.hpp index 2b72d586..2000567e 100644 --- a/src/ArduinoJson/Array/ArrayImpl.hpp +++ b/src/ArduinoJson/Array/ArrayImpl.hpp @@ -6,6 +6,7 @@ #include #include +#include ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE @@ -70,4 +71,9 @@ inline bool ArrayData::addValue(T&& value, ResourceManager* resources) { return true; } +// Returns the size (in bytes) of an array with n elements. +constexpr size_t sizeofArray(size_t n) { + return n * sizeof(VariantSlot); +} + ARDUINOJSON_END_PRIVATE_NAMESPACE diff --git a/src/ArduinoJson/Object/ObjectImpl.hpp b/src/ArduinoJson/Object/ObjectImpl.hpp index b193a929..7830576e 100644 --- a/src/ArduinoJson/Object/ObjectImpl.hpp +++ b/src/ArduinoJson/Object/ObjectImpl.hpp @@ -6,6 +6,7 @@ #include #include +#include ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE @@ -67,4 +68,9 @@ inline VariantData* ObjectData::addMember(TAdaptedString key, return valueSlot.data(); } +// Returns the size (in bytes) of an object with n members. +constexpr size_t sizeofObject(size_t n) { + return 2 * n * sizeof(VariantSlot); +} + ARDUINOJSON_END_PRIVATE_NAMESPACE diff --git a/src/ArduinoJson/Variant/VariantSlot.hpp b/src/ArduinoJson/Variant/VariantSlot.hpp index a600c6af..cdbd8863 100644 --- a/src/ArduinoJson/Variant/VariantSlot.hpp +++ b/src/ArduinoJson/Variant/VariantSlot.hpp @@ -24,14 +24,4 @@ union VariantSlot { FreeSlot free; }; -// Returns the size (in bytes) of an array with n elements. -constexpr size_t sizeofArray(size_t n) { - return n * sizeof(VariantSlot); -} - -// Returns the size (in bytes) of an object with n members. -constexpr size_t sizeofObject(size_t n) { - return 2 * n * sizeof(VariantSlot); -} - ARDUINOJSON_END_PRIVATE_NAMESPACE