From 6447520b5b116178fe0272558508b657d3af962a Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Tue, 22 Nov 2022 18:56:42 +0100 Subject: [PATCH] Replace `Yes`/`No` with `int`/`char` --- src/ArduinoJson/Polyfills/type_traits/is_base_of.hpp | 9 +++------ src/ArduinoJson/Polyfills/type_traits/is_class.hpp | 9 +++------ src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp | 9 +++------ src/ArduinoJson/Variant/ConverterImpl.hpp | 9 +++------ src/ArduinoJson/Variant/VariantAttorney.hpp | 9 +++------ 5 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/ArduinoJson/Polyfills/type_traits/is_base_of.hpp b/src/ArduinoJson/Polyfills/type_traits/is_base_of.hpp index 1583fd52..8936bd9b 100644 --- a/src/ArduinoJson/Polyfills/type_traits/is_base_of.hpp +++ b/src/ArduinoJson/Polyfills/type_traits/is_base_of.hpp @@ -13,14 +13,11 @@ namespace ARDUINOJSON_NAMESPACE { template class is_base_of { protected: // <- to avoid GCC's "all member functions in class are private" - typedef char Yes[1]; - typedef char No[2]; - - static Yes& probe(const TBase*); - static No& probe(...); + static int probe(const TBase*); + static char probe(...); public: static const bool value = - sizeof(probe(reinterpret_cast(0))) == sizeof(Yes); + sizeof(probe(reinterpret_cast(0))) == sizeof(int); }; } // namespace ARDUINOJSON_NAMESPACE diff --git a/src/ArduinoJson/Polyfills/type_traits/is_class.hpp b/src/ArduinoJson/Polyfills/type_traits/is_class.hpp index 06f97cab..a586c3c5 100644 --- a/src/ArduinoJson/Polyfills/type_traits/is_class.hpp +++ b/src/ArduinoJson/Polyfills/type_traits/is_class.hpp @@ -11,16 +11,13 @@ namespace ARDUINOJSON_NAMESPACE { template struct is_class { protected: // <- to avoid GCC's "all member functions in class are private" - typedef char Yes[1]; - typedef char No[2]; - template - static Yes& probe(void (U::*)(void)); + static int probe(void (U::*)(void)); template - static No& probe(...); + static char probe(...); public: - static const bool value = sizeof(probe(0)) == sizeof(Yes); + static const bool value = sizeof(probe(0)) == sizeof(int); }; } // namespace ARDUINOJSON_NAMESPACE diff --git a/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp b/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp index 2d3ef4b7..ef18cf24 100644 --- a/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp +++ b/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp @@ -24,16 +24,13 @@ namespace ARDUINOJSON_NAMESPACE { template struct is_convertible { protected: // <- to avoid GCC's "all member functions in class are private" - typedef char Yes[1]; - typedef char No[2]; - - static Yes& probe(To); - static No& probe(...); + static int probe(To); + static char probe(...); static From& _from; public: - static const bool value = sizeof(probe(_from)) == sizeof(Yes); + static const bool value = sizeof(probe(_from)) == sizeof(int); }; } // namespace ARDUINOJSON_NAMESPACE diff --git a/src/ArduinoJson/Variant/ConverterImpl.hpp b/src/ArduinoJson/Variant/ConverterImpl.hpp index 60d3ea4c..888cfed7 100644 --- a/src/ArduinoJson/Variant/ConverterImpl.hpp +++ b/src/ArduinoJson/Variant/ConverterImpl.hpp @@ -307,15 +307,12 @@ inline bool canConvertFromJson(VariantConstRef src, const std::string_view&) { template struct ConverterNeedsWriteableRef { protected: // <- to avoid GCC's "all member functions in class are private" - typedef char Yes[1]; - typedef char No[2]; - - static Yes& probe(T (*f)(VariantRef)); - static No& probe(T (*f)(VariantConstRef)); + static int probe(T (*f)(VariantRef)); + static char probe(T (*f)(VariantConstRef)); public: static const bool value = - sizeof(probe(Converter::fromJson)) == sizeof(Yes); + sizeof(probe(Converter::fromJson)) == sizeof(int); }; } // namespace ARDUINOJSON_NAMESPACE diff --git a/src/ArduinoJson/Variant/VariantAttorney.hpp b/src/ArduinoJson/Variant/VariantAttorney.hpp index ebb7d879..7994fc8a 100644 --- a/src/ArduinoJson/Variant/VariantAttorney.hpp +++ b/src/ArduinoJson/Variant/VariantAttorney.hpp @@ -17,16 +17,13 @@ class VariantAttorney { template struct ResultOfGetData { protected: // <- to avoid GCC's "all member functions in class are private" - typedef char Yes[1]; - typedef char No[2]; - - static Yes& probe(const VariantData*); - static No& probe(VariantData*); + static int probe(const VariantData*); + static char probe(VariantData*); static TClient& client; public: - typedef typename conditional::type type; };