[cfe-commits] [libcxx] r131090 - in /libcxx/trunk: include/type_traits www/type_traits_design.html

Howard Hinnant hhinnant at apple.com
Mon May 9 12:21:17 PDT 2011


Author: hhinnant
Date: Mon May  9 14:21:17 2011
New Revision: 131090

URL: http://llvm.org/viewvc/llvm-project?rev=131090&view=rev
Log:
Updated type_traits and the type_traits design doc with recent work done in clang.

Modified:
    libcxx/trunk/include/type_traits
    libcxx/trunk/www/type_traits_design.html

Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=131090&r1=131089&r2=131090&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Mon May  9 14:21:17 2011
@@ -292,27 +292,27 @@
 
 // is_union
 
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
 
 template <class _Tp> struct _LIBCPP_VISIBLE is_union
     : public integral_constant<bool, __is_union(_Tp)> {};
 
-#else  // _LIBCPP_HAS_TYPE_TRAITS
+#else
 
 template <class _Tp> struct __libcpp_union : public false_type {};
 template <class _Tp> struct _LIBCPP_VISIBLE is_union
     : public __libcpp_union<typename remove_cv<_Tp>::type> {};
 
-#endif  // _LIBCPP_HAS_TYPE_TRAITS
+#endif
 
 // is_class
 
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
 
 template <class _Tp> struct _LIBCPP_VISIBLE is_class
     : public integral_constant<bool, __is_class(_Tp)> {};
 
-#else  // _LIBCPP_HAS_TYPE_TRAITS
+#else
 
 namespace __is_class_imp
 {
@@ -323,7 +323,7 @@
 template <class _Tp> struct _LIBCPP_VISIBLE is_class
     : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
 
-#endif  // _LIBCPP_HAS_TYPE_TRAITS
+#endif
 
 // is_function
 
@@ -370,12 +370,12 @@
 
 // is_enum
 
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
 
 template <class _Tp> struct _LIBCPP_VISIBLE is_enum
     : public integral_constant<bool, __is_enum(_Tp)> {};
 
-#else  // _LIBCPP_HAS_TYPE_TRAITS
+#else
 
 template <class _Tp> struct _LIBCPP_VISIBLE is_enum
     : public integral_constant<bool, !is_void<_Tp>::value             &&
@@ -389,7 +389,7 @@
                                      !is_class<_Tp>::value            &&
                                      !is_function<_Tp>::value         > {};
 
-#endif  // _LIBCPP_HAS_TYPE_TRAITS
+#endif
 
 // is_arithmetic
 
@@ -814,7 +814,7 @@
 
 // has_virtual_destructor
 
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#ifdef __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
 
 template <class _Tp> struct _LIBCPP_VISIBLE has_virtual_destructor
     : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
@@ -1920,7 +1920,7 @@
 
 template <class _Tp>
 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_trivial_constructor(_Tp)>
 #else
     : integral_constant<bool, is_scalar<_Tp>::value>
@@ -1934,7 +1934,7 @@
 #else
 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp>
 #endif
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_trivial_copy(_Tp)>
 #else
     : integral_constant<bool, is_scalar<_Tp>::value>
@@ -1944,7 +1944,7 @@
 
 template <class _Tp>
 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_trivial_copy(_Tp)>
 #else
     : integral_constant<bool, is_scalar<_Tp>::value>
@@ -1954,7 +1954,7 @@
 
 template <class _Tp>
 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_trivial_copy(_Tp)>
 #else
     : integral_constant<bool, is_scalar<_Tp>::value>
@@ -1974,7 +1974,7 @@
 template <class _Tp>
 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, __is_construct::__nat,
                                                        __is_construct::__nat>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_trivial_constructor(_Tp)>
 #else
     : integral_constant<bool, is_scalar<_Tp>::value>
@@ -1985,7 +1985,7 @@
 template <class _Tp>
 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp,
                                                        __is_construct::__nat>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_trivial_copy(_Tp)>
 #else
     : integral_constant<bool, is_scalar<_Tp>::value>
@@ -1996,7 +1996,7 @@
 template <class _Tp>
 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&,
                                                        __is_construct::__nat>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_trivial_copy(_Tp)>
 #else
     : integral_constant<bool, is_scalar<_Tp>::value>
@@ -2007,7 +2007,7 @@
 template <class _Tp>
 struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&,
                                                        __is_construct::__nat>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_trivial_copy(_Tp)>
 #else
     : integral_constant<bool, is_scalar<_Tp>::value>
@@ -2047,7 +2047,7 @@
 
 template <class _Tp>
 struct is_trivially_assignable<_Tp&, _Tp>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_trivial_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_trivial_assign(_Tp)> {};
 #else
     : integral_constant<bool, is_scalar<_Tp>::value> {};
@@ -2055,7 +2055,7 @@
 
 template <class _Tp>
 struct is_trivially_assignable<_Tp&, _Tp&>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_trivial_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_trivial_assign(_Tp)> {};
 #else
     : integral_constant<bool, is_scalar<_Tp>::value> {};
@@ -2063,7 +2063,7 @@
 
 template <class _Tp>
 struct is_trivially_assignable<_Tp&, const _Tp&>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_trivial_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_trivial_assign(_Tp)> {};
 #else
     : integral_constant<bool, is_scalar<_Tp>::value> {};
@@ -2073,7 +2073,7 @@
 
 template <class _Tp>
 struct is_trivially_assignable<_Tp&, _Tp&&>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_trivial_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_trivial_assign(_Tp)> {};
 #else
     : integral_constant<bool, is_scalar<_Tp>::value> {};
@@ -2101,7 +2101,7 @@
 
 // is_trivially_destructible
 
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
 
 template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_destructible
     : public integral_constant<bool, __has_trivial_destructor(_Tp)> {};
@@ -2129,7 +2129,7 @@
 
 template <class _Tp>
 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_nothrow_constructor(_Tp)>
 #else
     : integral_constant<bool, is_scalar<_Tp>::value>
@@ -2143,7 +2143,7 @@
 #else
 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp>
 #endif
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_nothrow_copy(_Tp)>
 #else
     : integral_constant<bool, is_scalar<_Tp>::value>
@@ -2153,7 +2153,7 @@
 
 template <class _Tp>
 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, const _Tp&>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_nothrow_copy(_Tp)>
 #else
     : integral_constant<bool, is_scalar<_Tp>::value>
@@ -2163,7 +2163,7 @@
 
 template <class _Tp>
 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_nothrow_copy(_Tp)>
 #else
     : integral_constant<bool, is_scalar<_Tp>::value>
@@ -2183,7 +2183,7 @@
 template <class _Tp>
 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, __is_construct::__nat,
                                                        __is_construct::__nat>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_nothrow_constructor(_Tp)>
 #else
     : integral_constant<bool, is_scalar<_Tp>::value>
@@ -2194,7 +2194,7 @@
 template <class _Tp>
 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp,
                                                        __is_construct::__nat>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_nothrow_copy(_Tp)>
 #else
     : integral_constant<bool, is_scalar<_Tp>::value>
@@ -2205,7 +2205,7 @@
 template <class _Tp>
 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, const _Tp&,
                                                        __is_construct::__nat>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_nothrow_copy(_Tp)>
 #else
     : integral_constant<bool, is_scalar<_Tp>::value>
@@ -2216,7 +2216,7 @@
 template <class _Tp>
 struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&,
                                                        __is_construct::__nat>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_nothrow_copy(_Tp)>
 #else
     : integral_constant<bool, is_scalar<_Tp>::value>
@@ -2256,7 +2256,7 @@
 
 template <class _Tp>
 struct is_nothrow_assignable<_Tp&, _Tp>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
 #else
     : integral_constant<bool, is_scalar<_Tp>::value> {};
@@ -2264,7 +2264,7 @@
 
 template <class _Tp>
 struct is_nothrow_assignable<_Tp&, _Tp&>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
 #else
     : integral_constant<bool, is_scalar<_Tp>::value> {};
@@ -2272,7 +2272,7 @@
 
 template <class _Tp>
 struct is_nothrow_assignable<_Tp&, const _Tp&>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
 #else
     : integral_constant<bool, is_scalar<_Tp>::value> {};
@@ -2282,7 +2282,7 @@
 
 template <class _Tp>
 struct is_nothrow_assignable<_Tp&, _Tp&&>
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
 #else
     : integral_constant<bool, is_scalar<_Tp>::value> {};
@@ -2319,7 +2319,7 @@
 
 // is_pod
 
-#ifdef _LIBCPP_HAS_TYPE_TRAITS
+#if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
 
 template <class _Tp> struct _LIBCPP_VISIBLE is_pod
     : public integral_constant<bool, __is_pod(_Tp)> {};
@@ -2334,6 +2334,17 @@
 
 #endif  // _LIBCPP_HAS_TYPE_TRAITS
 
+// is_literal_type;
+
+template <class _Tp> struct _LIBCPP_VISIBLE is_literal_type
+#if __has_feature(is_literal)
+    : public integral_constant<bool, __is_literal(_Tp)>
+#else
+    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
+                              is_reference<typename remove_all_extents<_Tp>::type>::value>
+#endif
+    {};
+    
 template <class _Tp>
 inline _LIBCPP_INLINE_VISIBILITY
 void

Modified: libcxx/trunk/www/type_traits_design.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/type_traits_design.html?rev=131090&r1=131089&r2=131090&view=diff
==============================================================================
--- libcxx/trunk/www/type_traits_design.html (original)
+++ libcxx/trunk/www/type_traits_design.html Mon May  9 14:21:17 2011
@@ -110,7 +110,7 @@
 
 <tr>
 <td><tt>is_constructible<T, Args...></tt></td>
-<td bgcolor="#FF5965"><tt>__is_constructible(T, Args...)</tt></td>
+<td bgcolor="#FF5965">Needs CWG 1170 or <tt>__is_constructible(T, Args...)</tt></td>
 </tr>
 
 <tr>
@@ -130,7 +130,7 @@
 
 <tr>
 <td><tt>is_assignable<T, U></tt></td>
-<td bgcolor="#FF5965"><tt>__is_assignable(T, U)</tt></td>
+<td bgcolor="#FF5965">Needs CWG 1170 or <code>__is_assignable(T, U)</code></td>
 </tr>
 
 <tr>
@@ -145,7 +145,7 @@
 
 <tr>
 <td><tt>is_destructible<T></tt></td>
-<td bgcolor="#FF5965"><tt>__is_destructible(T)</tt></td>
+<td bgcolor="#FF5965">Needs CWG 1170 or <tt>__is_destructible(T)</tt></td>
 </tr>
 
 <tr>
@@ -245,12 +245,12 @@
 
 <tr>
 <td><tt>is_literal_type<T></tt></td>
-<td bgcolor="#FF5965"><tt>__is_literal_type(T)</tt></td>
+<td bgcolor="#80FF80"><tt>__is_literal_type(T)</tt></td>
 </tr>
 
 <tr>
 <td><tt>is_convertible<T, U></tt></td>
-<td bgcolor="#FF5965"><tt>__is_convertible(T, U)</tt></td>
+<td bgcolor="#80FF80"><tt>__is_convertible_to(T, U)</tt></td>
 </tr>
 
 <tr>
@@ -263,6 +263,21 @@
 <td bgcolor="#FF5965"><tt>__underlying_type(T)</tt></td>
 </tr>
 
+<tr>
+<td><tt>is_polymorphic<T></tt></td>
+<td><tt>__is_polymorphic(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_empty<T></tt></td>
+<td><tt>__is_empty(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_abstract<T></tt></td>
+<td><tt>__is_abstract(T)</tt></td>
+</tr>
+
 </table>
 </blockquote>
 





More information about the cfe-commits mailing list