Bug 888548 - Part 1: Add mozilla::IsEnum to TypeTraits.h. r=froydnj
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Thu, 01 Aug 2013 21:21:31 -0400
changeset 153327 dbce2a590a2bfd6e48f725c6cc9bfb751eb3e057
parent 153326 d0f70faea77807222bfbcfb770524eda8bd34cd4
child 153328 99511f74122542a4227c8efdb61fa3cd54b10b2b
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs888548
milestone25.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 888548 - Part 1: Add mozilla::IsEnum to TypeTraits.h. r=froydnj
mfbt/TypeTraits.h
--- a/mfbt/TypeTraits.h
+++ b/mfbt/TypeTraits.h
@@ -122,16 +122,38 @@ struct IsFloatingPoint
  * mozilla::IsPointer<struct S>::value is false.
  */
 template<typename T>
 struct IsPointer : FalseType {};
 
 template<typename T>
 struct IsPointer<T*> : TrueType {};
 
+namespace detail {
+
+// __is_enum is a supported extension across all of our supported compilers.
+template<typename T>
+struct IsEnumHelper
+  : IntegralConstant<bool, __is_enum(T)>
+{};
+
+} // namespace detail
+
+/**
+ * IsEnum determines whether a type is an enum type.
+ *
+ * mozilla::IsEnum<enum S>::value is true;
+ * mozilla::IsEnum<enum S*>::value is false;
+ * mozilla::IsEnum<int>::value is false;
+ */
+template<typename T>
+struct IsEnum
+  : detail::IsEnumHelper<typename RemoveCV<T>::Type>
+{};
+
 /* 20.9.4.2 Composite type traits [meta.unary.comp] */
 
 /**
  * IsArithmetic determines whether a type is arithmetic.  A type is arithmetic
  * iff it is an integral type or a floating point type.
  *
  * mozilla::IsArithmetic<int>::value is true;
  * mozilla::IsArithmetic<double>::value is true;