diff options
| author | Eric Fiselier <eric@efcs.ca> | 2015-06-13 00:33:13 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2015-06-13 00:33:13 +0000 |
| commit | 8aba6a6db4835fbb9f3d789edff3f92b44eb3850 (patch) | |
| tree | 8236272d1a9aaa497159c57288d775b2273e96f6 | |
| parent | 776cc6e48f6954988bfb86c1854c14ba93d86c5e (diff) | |
| download | bcm5719-llvm-8aba6a6db4835fbb9f3d789edff3f92b44eb3850.tar.gz bcm5719-llvm-8aba6a6db4835fbb9f3d789edff3f92b44eb3850.zip | |
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
| -rw-r--r-- | libcxx/include/type_traits | 16 | ||||
| -rw-r--r-- | libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp | 60 |
2 files changed, 53 insertions, 23 deletions
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index 4753a61a60f..760047abb06 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -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 diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp index 67ef3db2b71..6f546efdf51 100644 --- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp @@ -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::*)(...) &>(); + 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::*)() 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::*)(...) &>(); - 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 } |

