mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 00:32:37 +01:00 
			
		
		
		
	Fix compatibility with GCC 5.2 (fixes #1897)
This commit is contained in:
		| @@ -5,6 +5,7 @@ HEAD | ||||
| ---- | ||||
|  | ||||
| * Double speed of `DynamicJsonDocument::garbageCollect()` | ||||
| * Fix compatibility with GCC 5.2 (issue #1897) | ||||
|  | ||||
| v6.21.0 (2023-03-14) | ||||
| ------- | ||||
|   | ||||
| @@ -24,6 +24,30 @@ TEST_CASE("deserializeJson(char*)") { | ||||
|   } | ||||
| } | ||||
|  | ||||
| TEST_CASE("deserializeJson(unsigned char*, unsigned int)") {  // issue #1897 | ||||
|   StaticJsonDocument<1024> doc; | ||||
|  | ||||
|   unsigned char input[] = "{\"hello\":\"world\"}"; | ||||
|   unsigned char* input_ptr = input; | ||||
|   unsigned int size = sizeof(input); | ||||
|  | ||||
|   DeserializationError err = deserializeJson(doc, input_ptr, size); | ||||
|  | ||||
|   REQUIRE(err == DeserializationError::Ok); | ||||
| } | ||||
|  | ||||
| TEST_CASE("deserializeJson(uint8_t*, size_t)") {  // issue #1898 | ||||
|   StaticJsonDocument<1024> doc; | ||||
|  | ||||
|   uint8_t input[] = "{\"hello\":\"world\"}"; | ||||
|   uint8_t* input_ptr = input; | ||||
|   size_t size = sizeof(input); | ||||
|  | ||||
|   DeserializationError err = deserializeJson(doc, input_ptr, size); | ||||
|  | ||||
|   REQUIRE(err == DeserializationError::Ok); | ||||
| } | ||||
|  | ||||
| TEST_CASE("deserializeJson(const std::string&)") { | ||||
|   DynamicJsonDocument doc(4096); | ||||
|  | ||||
|   | ||||
| @@ -12,6 +12,17 @@ | ||||
|  | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // A meta-function that returns the first type of the parameter pack | ||||
| // or void if empty | ||||
| template <typename...> | ||||
| struct first_or_void { | ||||
|   using type = void; | ||||
| }; | ||||
| template <typename T, typename... Rest> | ||||
| struct first_or_void<T, Rest...> { | ||||
|   using type = T; | ||||
| }; | ||||
|  | ||||
| template <template <typename, typename> class TDeserializer, typename TReader, | ||||
|           typename TWriter> | ||||
| TDeserializer<TReader, TWriter> makeDeserializer(MemoryPool* pool, | ||||
| @@ -22,7 +33,9 @@ TDeserializer<TReader, TWriter> makeDeserializer(MemoryPool* pool, | ||||
| } | ||||
|  | ||||
| template <template <typename, typename> class TDeserializer, typename TStream, | ||||
|           typename... Args> | ||||
|           typename... Args, | ||||
|           typename = typename enable_if<  // issue #1897 | ||||
|               !is_integral<typename first_or_void<Args...>::type>::value>::type> | ||||
| DeserializationError deserialize(JsonDocument& doc, TStream&& input, | ||||
|                                  Args... args) { | ||||
|   auto reader = makeReader(detail::forward<TStream>(input)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user