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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@159211 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
67c8082a18
commit
2d62229b96
@ -1609,77 +1609,13 @@ struct __member_pointer_traits
|
||||
|
||||
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 @@ struct __invoke_of
|
||||
{
|
||||
};
|
||||
|
||||
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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user