Bug 853988 - Move IsPointer and IsSame to the right locations. r=froydnj
authorJeff Walden <jwalden@mit.edu>
Fri, 22 Mar 2013 00:17:59 -0700
changeset 126142 9444636fb1d39e8dcda4bc0e40c8071713fcb940
parent 126141 f2af022787ee5f2893f704f294b1c19f2692351f
child 126143 6aaed09c846d471508c8fb1b624abba45f13c6e1
push id25300
push userjwalden@mit.edu
push dateMon, 25 Mar 2013 19:06:34 +0000
treeherdermozilla-inbound@669d96cdd9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs853988
milestone22.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 853988 - Move IsPointer and IsSame to the right locations. r=froydnj
mfbt/TypeTraits.h
--- a/mfbt/TypeTraits.h
+++ b/mfbt/TypeTraits.h
@@ -34,37 +34,55 @@ struct IntegralConstant
 /** Convenient aliases. */
 typedef IntegralConstant<bool, true> TrueType;
 typedef IntegralConstant<bool, false> FalseType;
 
 /* 20.9.4 Unary type traits */
 
 /* 20.9.4.1 Primary type categories */
 
+/**
+ * IsPointer determines whether a type is a pointer type (but not a pointer-to-
+ * member type).
+ *
+ * mozilla::IsPointer<struct S*>::value is true;
+ * mozilla::IsPointer<int**>::value is true;
+ * mozilla::IsPointer<void (*)(void)>::value is true;
+ * mozilla::IsPointer<int>::value is false;
+ * mozilla::IsPointer<struct S>::value is false.
+ */
+template<typename T>
+struct IsPointer : FalseType {};
+
+template<typename T>
+struct IsPointer<T*> : TrueType {};
+
 /* 20.9.4.2 Composite type traits */
 
 /* 20.9.4.3 Type properties */
 
 /* 20.9.5 Type property queries */
 
 /* 20.9.6 Relationships between types */
 
-/* 20.9.7 Transformations between types */
-
-/* 20.9.7.1 Const-volatile modifications */
-
-/* 20.9.7.2 Reference modifications */
+/**
+ * IsSame tests whether two types are the same type.
+ *
+ * mozilla::IsSame<int, int>::value is true;
+ * mozilla::IsSame<int*, int*>::value is true;
+ * mozilla::IsSame<int, unsigned int>::value is false;
+ * mozilla::IsSame<void, void>::value is true;
+ * mozilla::IsSame<const int, int>::value is false;
+ * mozilla::IsSame<struct S, struct S>::value is true.
+ */
+template<typename T, typename U>
+struct IsSame : FalseType {};
 
-/* 20.9.7.3 Sign modifications */
-
-/* 20.9.7.4 Array modifications */
-
-/* 20.9.7.5 Pointer modifications */
-
-/* 20.9.7.6 Other transformations */
+template<typename T>
+struct IsSame<T, T> : TrueType {};
 
 namespace detail {
 
 // 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
@@ -128,16 +146,30 @@ struct Conditional;
  * mozilla::IsBaseOf<A, B>::value is true;
  * mozilla::IsBaseOf<A, C>::value is false;
  */
 template<class Base, class Derived>
 struct IsBaseOf
   : Conditional<detail::BaseOfTester<Base, Derived>::value, TrueType, FalseType>::Type
 {};
 
+/* 20.9.7 Transformations between types */
+
+/* 20.9.7.1 Const-volatile modifications */
+
+/* 20.9.7.2 Reference modifications */
+
+/* 20.9.7.3 Sign modifications */
+
+/* 20.9.7.4 Array modifications */
+
+/* 20.9.7.5 Pointer modifications */
+
+/* 20.9.7.6 Other transformations */
+
 namespace detail {
 
 template<typename From, typename To>
 struct ConvertibleTester
 {
   private:
     static From create();
 
@@ -222,32 +254,16 @@ struct EnableIf
 
 template<typename T>
 struct EnableIf<true, T>
 {
     typedef T Type;
 };
 
 /**
- * IsSame tests whether two types are the same type.
- *
- * mozilla::IsSame<int, int>::value is true;
- * mozilla::IsSame<int*, int*>::value is true;
- * mozilla::IsSame<int, unsigned int>::value is false;
- * mozilla::IsSame<void, void>::value is true;
- * mozilla::IsSame<const int, int>::value is false;
- * mozilla::IsSame<struct S, struct S>::value is true.
- */
-template<typename T, typename U>
-struct IsSame : FalseType {};
-
-template<typename T>
-struct IsSame<T, T> : TrueType {};
-
-/**
  * Traits class for identifying POD types.  Until C++11 there's no automatic
  * way to detect PODs, so for the moment this is done manually.  Users may
  * define specializations of this class that inherit from mozilla::TrueType and
  * mozilla::FalseType (or equivalently mozilla::IntegralConstant<bool, true or
  * false>, or conveniently from mozilla::IsPod for composite types) as needed to
  * ensure correct IsPod behavior.
  */
 template<typename T>
@@ -265,27 +281,11 @@ template<> struct IsPod<unsigned long>  
 template<> struct IsPod<long long>          : TrueType {};
 template<> struct IsPod<unsigned long long> : TrueType {};
 template<> struct IsPod<bool>               : TrueType {};
 template<> struct IsPod<float>              : TrueType {};
 template<> struct IsPod<double>             : TrueType {};
 template<> struct IsPod<wchar_t>            : TrueType {};
 template<typename T> struct IsPod<T*>       : TrueType {};
 
-/**
- * IsPointer determines whether a type is a pointer type (but not a pointer-to-
- * member type).
- *
- * mozilla::IsPointer<struct S*>::value is true;
- * mozilla::IsPointer<int**>::value is true;
- * mozilla::IsPointer<void (*)(void)>::value is true;
- * mozilla::IsPointer<int>::value is false;
- * mozilla::IsPointer<struct S>::value is false.
- */
-template<typename T>
-struct IsPointer : FalseType {};
-
-template<typename T>
-struct IsPointer<T*> : TrueType {};
-
 } /* namespace mozilla */
 
 #endif  /* mozilla_TypeTraits_h_ */