From: Douglas Gregor Date: Tue, 4 Aug 2009 17:04:52 +0000 (+0000) Subject: Add some type traits that are used for Clang's statically-checked X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c7a6da6e1469100937851cc3741a36b5850e54da;p=oota-llvm.git Add some type traits that are used for Clang's statically-checked canonical types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78076 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/type_traits.h b/include/llvm/Support/type_traits.h index 5000a8b859b..32736b4141c 100644 --- a/include/llvm/Support/type_traits.h +++ b/include/llvm/Support/type_traits.h @@ -49,6 +49,33 @@ struct is_class enum { value = sizeof(char) == sizeof(dont_use::is_class_helper(0)) }; }; + +// enable_if_c - Enable/disable a template based on a metafunction +template +struct enable_if_c { + typedef T type; +}; + +template struct enable_if_c { }; + +// enable_if - Enable/disable a template based on a metafunction +template +struct enable_if : public enable_if_c { }; + +namespace dont_use { + template char base_of_helper(const volatile Base*); + template double base_of_helper(...); +} + +/// is_base_of - Metafunction to determine whether one type is a base class of +/// (or identical to) another type. +template +struct is_base_of { + static const bool value + = is_class::value && is_class::value && + sizeof(char) == sizeof(dont_use::base_of_helper((Derived*)0)); +}; + } #endif