[cfe-commits] [libcxx] r159211 - /libcxx/trunk/include/type_traits
Howard Hinnant
hhinnant at apple.com
Tue Jun 26 10:37:16 PDT 2012
Author: hhinnant
Date: Tue Jun 26 12:37:15 2012
New Revision: 159211
URL: http://llvm.org/viewvc/llvm-project?rev=159211&view=rev
Log:
Fixed a bug regarding result_of reported by Sven Behne. The fix is C++11 only mainly because result_of is a variadic beast and working with variadics is just such a problem in C++03 mode. This should bring result_of up to full conformance with the C++11 spec.
Modified:
libcxx/trunk/include/type_traits
Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=159211&r1=159210&r2=159211&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Tue Jun 26 12:37:15 2012
@@ -1609,77 +1609,13 @@
template <class _Callable> class result_of;
+#ifdef _LIBCPP_HAS_NO_VARIADICS
+
template <class _Fn, bool, bool>
class __result_of
{
};
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-
-template <class _Fn, class ..._ArgTypes>
-class __result_of<_Fn(_ArgTypes...), true, false>
-{
-public:
- typedef decltype(declval<_Fn>()(declval<_ArgTypes>()...)) type;
-};
-
-template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
-struct __result_of_mp;
-
-// member function pointer
-
-template <class _MP, class _Tp>
-struct __result_of_mp<_MP, _Tp, true>
- : public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
-{
-};
-
-// member data pointer
-
-template <class _MP, class _Tp, bool>
-struct __result_of_mdp;
-
-template <class _Rp, class _Class, class _Tp>
-struct __result_of_mdp<_Rp _Class::*, _Tp, false>
-{
- typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type&& type;
-};
-
-template <class _Rp, class _Class, class _Tp>
-struct __result_of_mdp<_Rp _Class::*, _Tp, true>
-{
- typedef typename __apply_cv<_Tp, _Rp>::type&& type;
-};
-
-template <class _Rp, class _Class, class _Tp>
-struct __result_of_mp<_Rp _Class::*, _Tp, false>
- : public __result_of_mdp<_Rp _Class::*, _Tp,
- is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
-{
-};
-
-template <class _Fn, class _Tp, class ..._ArgTypes>
-class __result_of<_Fn(_Tp, _ArgTypes...), false, true> // _Fn must be member pointer
- : public __result_of_mp<typename remove_reference<_Fn>::type,
- _Tp,
- is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
-{
-};
-
-// result_of
-
-template <class _Fn, class ..._ArgTypes>
-class _LIBCPP_VISIBLE result_of<_Fn(_ArgTypes...)>
- : public __result_of<_Fn(_ArgTypes...),
- is_class<typename remove_reference<_Fn>::type>::value ||
- is_function<typename remove_reference<_Fn>::type>::value,
- is_member_pointer<typename remove_reference<_Fn>::type>::value
- >
-{
-};
-
-#else // _LIBCPP_HAS_NO_VARIADICS
-
template <class _Fn>
class __result_of<_Fn(), true, false>
{
@@ -2951,6 +2887,12 @@
{
};
+template <class _Fp, class ..._Args>
+class _LIBCPP_VISIBLE result_of<_Fp(_Args...)>
+ : public __invoke_of<_Fp, _Args...>
+{
+};
+
#endif // _LIBCPP_HAS_NO_VARIADICS
template <class _Tp>
More information about the cfe-commits
mailing list