Minh Nguyen / ArduinoJson
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers is_base_of.hpp Source File

is_base_of.hpp

00001 // ArduinoJson - arduinojson.org
00002 // Copyright Benoit Blanchon 2014-2021
00003 // MIT License
00004 
00005 #pragma once
00006 
00007 #include <ArduinoJson/Namespace.hpp>
00008 
00009 namespace ARDUINOJSON_NAMESPACE {
00010 
00011 // A meta-function that returns true if Derived inherits from TBase is an
00012 // integral type.
00013 template <typename TBase, typename TDerived>
00014 class is_base_of {
00015  protected:  // <- to avoid GCC's "all member functions in class are private"
00016   typedef char Yes[1];
00017   typedef char No[2];
00018 
00019   static Yes &probe(const TBase *);
00020   static No &probe(...);
00021 
00022  public:
00023   static const bool value =
00024       sizeof(probe(reinterpret_cast<TDerived *>(0))) == sizeof(Yes);
00025 };
00026 }  // namespace ARDUINOJSON_NAMESPACE