Refactor is_member_function_pointer to use is_function and not __member_function_traits.

Replacing the dependancy on __member_function_traits with is_function allows
is_member_function_pointer to work more often. In particular it allows it to
work when we don't have variadic templates but the function has an arity > 3.

llvm-svn: 239649
This commit is contained in:
Eric Fiselier 2015-06-13 00:33:13 +00:00
parent 776cc6e48f
commit 8aba6a6db4
2 changed files with 55 additions and 25 deletions

View File

@ -479,19 +479,15 @@ struct __member_pointer_traits_imp
};
namespace __libcpp_is_member_function_pointer_imp {
template <typename _Tp>
char __test(typename std::__member_pointer_traits_imp<_Tp, true, false>::_FnType *);
template <typename>
std::__two __test(...);
};
template <class _Tp> struct __libcpp_is_member_function_pointer
: public integral_constant<bool, sizeof(__libcpp_is_member_function_pointer_imp::__test<_Tp>(nullptr)) == 1> {};
: public false_type {};
template <class _Ret, class _Class>
struct __libcpp_is_member_function_pointer<_Ret _Class::*>
: public is_function<_Ret> {};
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer
: public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type> {};
: public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
// is_member_pointer

View File

@ -12,12 +12,13 @@
// member_function_pointer
#include <type_traits>
#include "test_macros.h"
template <class T>
void test_member_function_pointer_imp()
{
static_assert(!std::is_void<T>::value, "");
#if _LIBCPP_STD_VER > 11
#if TEST_STD_VER > 11
static_assert(!std::is_null_pointer<T>::value, "");
#endif
static_assert(!std::is_integral<T>::value, "");
@ -73,30 +74,63 @@ int main()
test_member_function_pointer<void (Class::*)(int, ...) volatile>();
test_member_function_pointer<void (Class::*)(int, char, ...) volatile>();
#if __cplusplus >= 201103L
// reference qualifiers on functions are a C++11 extension
test_member_function_pointer<void (Class::*)() &&>();
test_member_function_pointer<void (Class::*)(int) &&>();
test_member_function_pointer<void (Class::*)(int, char) &&>();
#if TEST_STD_VER >= 11
test_member_function_pointer<void (Class::*)() &>();
test_member_function_pointer<void (Class::*)(int) &>();
test_member_function_pointer<void (Class::*)(int, char) &>();
test_member_function_pointer<void (Class::*)() volatile &&>();
test_member_function_pointer<void (Class::*)(int) volatile &&>();
test_member_function_pointer<void (Class::*)(int, char) volatile &&>();
test_member_function_pointer<void (Class::*)(...) &&>();
test_member_function_pointer<void (Class::*)(int,...) &&>();
test_member_function_pointer<void (Class::*)(int, char,...) &&>();
test_member_function_pointer<void (Class::*)(...) &>();
test_member_function_pointer<void (Class::*)(int,...) &>();
test_member_function_pointer<void (Class::*)(int, char,...) &>();
test_member_function_pointer<void (Class::*)() const &>();
test_member_function_pointer<void (Class::*)(int) const &>();
test_member_function_pointer<void (Class::*)(int, char) const &>();
test_member_function_pointer<void (Class::*)(...) const &>();
test_member_function_pointer<void (Class::*)(int,...) const &>();
test_member_function_pointer<void (Class::*)(int, char,...) const &>();
test_member_function_pointer<void (Class::*)() volatile &>();
test_member_function_pointer<void (Class::*)(int) volatile &>();
test_member_function_pointer<void (Class::*)(int, char) volatile &>();
test_member_function_pointer<void (Class::*)(...) volatile &>();
test_member_function_pointer<void (Class::*)(int,...) volatile &>();
test_member_function_pointer<void (Class::*)(int, char,...) volatile &>();
test_member_function_pointer<void (Class::*)() const volatile &>();
test_member_function_pointer<void (Class::*)(int) const volatile &>();
test_member_function_pointer<void (Class::*)(int, char) const volatile &>();
test_member_function_pointer<void (Class::*)(...) const volatile &>();
test_member_function_pointer<void (Class::*)(int,...) const volatile &>();
test_member_function_pointer<void (Class::*)(int, char,...) const volatile &>();
// RValue qualifiers
test_member_function_pointer<void (Class::*)() &&>();
test_member_function_pointer<void (Class::*)(int) &&>();
test_member_function_pointer<void (Class::*)(int, char) &&>();
test_member_function_pointer<void (Class::*)(...) &&>();
test_member_function_pointer<void (Class::*)(int,...) &&>();
test_member_function_pointer<void (Class::*)(int, char,...) &&>();
test_member_function_pointer<void (Class::*)() const &&>();
test_member_function_pointer<void (Class::*)(int) const &&>();
test_member_function_pointer<void (Class::*)(int, char) const &&>();
test_member_function_pointer<void (Class::*)(...) const &&>();
test_member_function_pointer<void (Class::*)(int,...) const &&>();
test_member_function_pointer<void (Class::*)(int, char,...) const &&>();
test_member_function_pointer<void (Class::*)() volatile &&>();
test_member_function_pointer<void (Class::*)(int) volatile &&>();
test_member_function_pointer<void (Class::*)(int, char) volatile &&>();
test_member_function_pointer<void (Class::*)(...) volatile &&>();
test_member_function_pointer<void (Class::*)(int,...) volatile &&>();
test_member_function_pointer<void (Class::*)(int, char,...) volatile &&>();
test_member_function_pointer<void (Class::*)() const volatile &&>();
test_member_function_pointer<void (Class::*)(int) const volatile &&>();
test_member_function_pointer<void (Class::*)(int, char) const volatile &&>();
test_member_function_pointer<void (Class::*)(...) const volatile &&>();
test_member_function_pointer<void (Class::*)(int,...) const volatile &&>();
test_member_function_pointer<void (Class::*)(int, char,...) const volatile &&>();
#endif
}