bug 899319 - use __is_base_of() on gcc / clang / msvc r=froydnj
authorTrevor Saunders <trev.saunders@gmail.com>
Thu, 06 Mar 2014 23:34:20 -0500
changeset 191660 57da41536eb408330d677328f726b10d67e11691
parent 191659 8764e9f061d0e971051613dab10b42d6916a1446
child 191661 4853e04fe2a63354cc0edc9979b09c132b0904be
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs899319
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 899319 - use __is_base_of() on gcc / clang / msvc r=froydnj
mfbt/TypeTraits.h
--- a/mfbt/TypeTraits.h
+++ b/mfbt/TypeTraits.h
@@ -471,16 +471,23 @@ struct IsUnsigned : detail::IsUnsignedHe
 template<typename T, typename U>
 struct IsSame : FalseType {};
 
 template<typename T>
 struct IsSame<T, T> : TrueType {};
 
 namespace detail {
 
+#if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)
+
+template<class Base, class Derived>
+struct BaseOfTester : IntegralConstant<bool, __is_base_of(Base, Derived)> {};
+
+#else
+
 // The trickery used to implement IsBaseOf here makes it possible to use it for
 // the cases of private and multiple inheritance.  This code was inspired by the
 // sample code here:
 //
 // http://stackoverflow.com/questions/2910979/how-is-base-of-works
 template<class Base, class Derived>
 struct BaseOfHelper
 {
@@ -519,16 +526,18 @@ template<class Base, class Derived>
 struct BaseOfTester<Base&, Derived&> : FalseType {};
 
 template<class Type>
 struct BaseOfTester<Type, Type> : TrueType {};
 
 template<class Type>
 struct BaseOfTester<Type, const Type> : TrueType {};
 
+#endif
+
 } /* namespace detail */
 
 /*
  * IsBaseOf allows to know whether a given class is derived from another.
  *
  * Consider the following class definitions:
  *
  *   class A {};