Minh Nguyen / ArduinoJson
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers is_class.hpp Source File

is_class.hpp

00001 // ArduinoJson - arduinojson.org
00002 // Copyright Benoit Blanchon 2014-2021
00003 // MIT License
00004 
00005 #pragma once
00006 
00007 #include "declval.hpp"
00008 
00009 namespace ARDUINOJSON_NAMESPACE {
00010 
00011 template <typename T>
00012 struct is_class {
00013  protected:  // <- to avoid GCC's "all member functions in class are private"
00014   typedef char Yes[1];
00015   typedef char No[2];
00016 
00017   template <typename U>
00018   static Yes &probe(void (U::*)(void));
00019   template <typename>
00020   static No &probe(...);
00021 
00022  public:
00023   static const bool value = sizeof(probe<T>(0)) == sizeof(Yes);
00024 };
00025 
00026 }  // namespace ARDUINOJSON_NAMESPACE