[cfe-commits] [libcxx] r131198 - in /libcxx/trunk/include: __config type_traits

Howard Hinnant hhinnant at apple.com
Wed May 11 13:19:41 PDT 2011


Author: hhinnant
Date: Wed May 11 15:19:40 2011
New Revision: 131198

URL: http://llvm.org/viewvc/llvm-project?rev=131198&view=rev
Log:
Redid nothrow traits in terms of non-nothrow traits when noexcept is available

Modified:
    libcxx/trunk/include/__config
    libcxx/trunk/include/type_traits

Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=131198&r1=131197&r2=131198&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed May 11 15:19:40 2011
@@ -86,8 +86,9 @@
 
 #if defined(__clang__)
 
-#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
+//#if !__has_feature(cxx_alias_templates)
 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+//#endif
 
 #ifndef __GXX_EXPERIMENTAL_CXX0X__
 #ifdef __linux__
@@ -138,6 +139,7 @@
 
 #if !(__has_feature(cxx_auto_type))
 #define _LIBCPP_HAS_NO_AUTO_TYPE
+#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
 #endif
 
 #if !(__has_feature(cxx_variadic_templates))
@@ -162,6 +164,14 @@
 #define _LIBCPP_HAS_NO_CONSTEXPR
 #endif
 
+#if (__has_feature(cxx_noexcept))
+#  define _NOEXCEPT noexcept
+#  define _NOEXCEPT_(x) noexcept(x)
+#else
+#  define _NOEXCEPT throw()
+#  define _NOEXCEPT_(x)
+#endif
+
 // end defined(__clang__)
 
 #elif defined(__GNUC__)
@@ -173,6 +183,9 @@
 #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
 #define _LIBCPP_HAS_NO_CONSTEXPR
 
+#define _NOEXCEPT throw()
+#define _NOEXCEPT_(x)
+
 #ifndef __GXX_EXPERIMENTAL_CXX0X__
 
 #define _LIBCPP_HAS_NO_ADVANCED_SFINAE

Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=131198&r1=131197&r2=131198&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Wed May 11 15:19:40 2011
@@ -490,7 +490,7 @@
 
 template <class _Tp>
 typename add_rvalue_reference<_Tp>::type
-declval();
+declval() _NOEXCEPT;
 
 #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
@@ -2121,6 +2121,30 @@
 
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 
+#if __has_feature(cxx_noexcept)
+
+template <bool, class _Tp, class... _Args> struct __is_nothrow_constructible;
+
+template <class _Tp, class... _Args>
+struct __is_nothrow_constructible<true, _Tp, _Args...>
+    : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
+{
+};
+
+template <class _Tp, class... _Args>
+struct __is_nothrow_constructible<false, _Tp, _Args...>
+    : public false_type
+{
+};
+
+template <class _Tp, class... _Args>
+struct _LIBCPP_VISIBLE is_nothrow_constructible
+    : __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...>
+{
+};
+
+#else  // __has_feature(cxx_noexcept)
+
 template <class _Tp, class... _Args>
 struct _LIBCPP_VISIBLE is_nothrow_constructible
     : false_type
@@ -2171,6 +2195,8 @@
 {
 };
 
+#endif  // __has_feature(cxx_noexcept)
+
 #else  // _LIBCPP_HAS_NO_VARIADICS
 
 template <class _Tp, class _A0 = __is_construct::__nat,
@@ -2250,12 +2276,36 @@
 
 // is_nothrow_assignable
 
+#if __has_feature(cxx_noexcept)
+
+template <bool, class _Tp, class _Arg> struct __is_nothrow_assignable;
+
 template <class _Tp, class _Arg>
-struct is_nothrow_assignable
+struct __is_nothrow_assignable<false, _Tp, _Arg>
+    : public false_type
+{
+};
+
+template <class _Tp, class _Arg>
+struct __is_nothrow_assignable<true, _Tp, _Arg>
+    : public integral_constant<bool, noexcept(_STD::declval<_Tp>() = _STD::declval<_Arg>()) >
+{
+};
+
+template <class _Tp, class _Arg>
+struct _LIBCPP_VISIBLE is_nothrow_assignable
+    : public __is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
+{
+};
+
+#else  // __has_feature(cxx_noexcept)
+
+template <class _Tp, class _Arg>
+struct _LIBCPP_VISIBLE is_nothrow_assignable
     : public false_type {};
 
 template <class _Tp>
-struct is_nothrow_assignable<_Tp&, _Tp>
+struct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, _Tp>
 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
 #else
@@ -2263,7 +2313,7 @@
 #endif
 
 template <class _Tp>
-struct is_nothrow_assignable<_Tp&, _Tp&>
+struct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, _Tp&>
 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
 #else
@@ -2271,7 +2321,7 @@
 #endif
 
 template <class _Tp>
-struct is_nothrow_assignable<_Tp&, const _Tp&>
+struct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, const _Tp&>
 #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
     : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
 #else
@@ -2290,6 +2340,8 @@
 
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
+#endif  // __has_feature(cxx_noexcept)
+
 // is_nothrow_copy_assignable
 
 template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_copy_assignable
@@ -2310,6 +2362,30 @@
 
 // is_nothrow_destructible
 
+#if __has_feature(cxx_noexcept)
+
+template <bool, class _Tp> struct __is_nothrow_destructible;
+
+template <class _Tp>
+struct __is_nothrow_destructible<false, _Tp>
+    : public false_type
+{
+};
+
+template <class _Tp>
+struct __is_nothrow_destructible<true, _Tp>
+    : public integral_constant<bool, noexcept(_STD::declval<_Tp>().~_Tp()) >
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_VISIBLE is_nothrow_destructible
+    : public __is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
+{
+};
+
+#else
+
 template <class _Tp> struct __libcpp_nothrow_destructor
     : public integral_constant<bool, is_scalar<_Tp>::value ||
                                      is_reference<_Tp>::value> {};
@@ -2317,6 +2393,8 @@
 template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_destructible
     : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
 
+#endif
+
 // is_pod
 
 #if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)





More information about the cfe-commits mailing list