summaryrefslogtreecommitdiffstats
path: root/libcxx
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2012-08-25 15:06:50 +0000
committerHoward Hinnant <hhinnant@apple.com>2012-08-25 15:06:50 +0000
commite890ab2377c9da1af9faa4accd25d35267872a15 (patch)
tree3ed07cb6d7c9ec0660ff99d9f898124408acc1e2 /libcxx
parent48ddcf2cb57caf57f8e1f1029f39fc490de74e08 (diff)
downloadbcm5719-llvm-e890ab2377c9da1af9faa4accd25d35267872a15.tar.gz
bcm5719-llvm-e890ab2377c9da1af9faa4accd25d35267872a15.zip
Michel Morin: My previous fix for C++03 was incomplete.
It does not consider user-defined conversions that convert an rvalue into an lvalue and works incorrectly for types with such a conversion operator. For example, struct foo { operator int&(); }; returns false_type. Attached a patch that fixes this problem. http://llvm.org/bugs/show_bug.cgi?id=13601 llvm-svn: 162644
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/include/type_traits33
1 files changed, 18 insertions, 15 deletions
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index 7b5827c5d5c..783ed3f5858 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -607,6 +607,20 @@ template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {}
template <class _Tp> struct _LIBCPP_VISIBLE is_abstract : public __libcpp_abstract<_Tp> {};
+// is_base_of
+
+#ifdef _LIBCP_HAS_IS_BASE_OF
+
+template <class _Bp, class _Dp>
+struct _LIBCPP_VISIBLE is_base_of
+ : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
+
+#else // __has_feature(is_base_of)
+
+#error is_base_of not implemented.
+
+#endif // __has_feature(is_base_of)
+
// is_convertible
#if __has_feature(is_convertible_to)
@@ -660,7 +674,10 @@ struct __is_convertible
sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
&& !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
&& (!is_const<typename remove_reference<_T2>::type>::value
- || is_volatile<typename remove_reference<_T2>::type>::value))
+ || is_volatile<typename remove_reference<_T2>::type>::value)
+ && (is_same<typename remove_cv<_T1>::type,
+ typename remove_cv<typename remove_reference<_T2>::type>::type>::value
+ || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
#endif
>
{};
@@ -723,20 +740,6 @@ template <class _T1, class _T2> struct _LIBCPP_VISIBLE is_convertible
#endif // __has_feature(is_convertible_to)
-// is_base_of
-
-#ifdef _LIBCP_HAS_IS_BASE_OF
-
-template <class _Bp, class _Dp>
-struct _LIBCPP_VISIBLE is_base_of
- : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
-
-#else // __has_feature(is_base_of)
-
-#error is_base_of not implemented.
-
-#endif // __has_feature(is_base_of)
-
// is_empty
#if __has_feature(is_empty)
OpenPOWER on IntegriCloud