mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Fix detection of char types
This commit is contained in:
		| @@ -40,12 +40,8 @@ serialize(JsonVariantConst source, void* buffer, size_t bufferSize) { | ||||
| } | ||||
|  | ||||
| template <template <typename> class TSerializer, typename TChar, size_t N> | ||||
| #if defined _MSC_VER && _MSC_VER < 1900 | ||||
| typename enable_if<sizeof(remove_reference<TChar>::type) == 1, size_t>::type | ||||
| #else | ||||
| typename enable_if<sizeof(TChar) == 1, size_t>::type | ||||
| #endif | ||||
| serialize(JsonVariantConst source, TChar (&buffer)[N]) { | ||||
| typename enable_if<IsChar<TChar>::value, size_t>::type serialize( | ||||
|     JsonVariantConst source, TChar (&buffer)[N]) { | ||||
|   return serialize<TSerializer>(source, buffer, N); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -13,6 +13,10 @@ | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
|  | ||||
| template <typename T> | ||||
| struct IsChar | ||||
|     : integral_constant<bool, is_integral<T>::value && sizeof(T) == 1> {}; | ||||
|  | ||||
| class ZeroTerminatedRamString { | ||||
|  public: | ||||
|   static const size_t typeSortKey = 3; | ||||
| @@ -58,7 +62,7 @@ class ZeroTerminatedRamString { | ||||
| }; | ||||
|  | ||||
| template <typename TChar> | ||||
| struct StringAdapter<TChar*, typename enable_if<sizeof(TChar) == 1>::type> { | ||||
| struct StringAdapter<TChar*, typename enable_if<IsChar<TChar>::value>::type> { | ||||
|   typedef ZeroTerminatedRamString AdaptedString; | ||||
|  | ||||
|   static AdaptedString adapt(const TChar* p) { | ||||
| @@ -67,7 +71,7 @@ struct StringAdapter<TChar*, typename enable_if<sizeof(TChar) == 1>::type> { | ||||
| }; | ||||
|  | ||||
| template <typename TChar, size_t N> | ||||
| struct StringAdapter<TChar[N], typename enable_if<sizeof(TChar) == 1>::type> { | ||||
| struct StringAdapter<TChar[N], typename enable_if<IsChar<TChar>::value>::type> { | ||||
|   typedef ZeroTerminatedRamString AdaptedString; | ||||
|  | ||||
|   static AdaptedString adapt(const TChar* p) { | ||||
| @@ -128,7 +132,7 @@ class SizedRamString { | ||||
|  | ||||
| template <typename TChar> | ||||
| struct SizedStringAdapter<TChar*, | ||||
|                           typename enable_if<sizeof(TChar) == 1>::type> { | ||||
|                           typename enable_if<IsChar<TChar>::value>::type> { | ||||
|   typedef SizedRamString AdaptedString; | ||||
|  | ||||
|   static AdaptedString adapt(const TChar* p, size_t n) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user