Skip to content

Commit

Permalink
VariantAttorney: replace ResultOfGetData with a trailing return type
Browse files Browse the repository at this point in the history
  • Loading branch information
bblanchon committed Jun 20, 2023
1 parent 8d7bbff commit fffed4f
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/ArduinoJson/Variant/VariantAttorney.hpp
Expand Up @@ -14,29 +14,15 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE

// Grants access to the internal variant API
class VariantAttorney {
// Tells whether getData() returns a const pointer
template <typename TClient>
struct ResultOfGetData {
protected: // <- to avoid GCC's "all member functions in class are private"
static int probe(const VariantData*);
static char probe(VariantData*);

static TClient& client;

public:
typedef typename conditional<sizeof(probe(client.getData())) == sizeof(int),
const VariantData*, VariantData*>::type type;
};

public:
template <typename TClient>
FORCE_INLINE static ResourceManager* getResourceManager(TClient& client) {
return client.getResourceManager();
}

template <typename TClient>
FORCE_INLINE static typename ResultOfGetData<TClient>::type getData(
TClient& client) {
FORCE_INLINE static auto getData(TClient& client)
-> decltype(client.getData()) {
return client.getData();
}

Expand Down

0 comments on commit fffed4f

Please sign in to comment.