[libcxx] r239649 - Refactor is_member_function_pointer to use is_function and not __member_function_traits.

Eric Fiselier eric at efcs.ca
Fri Jun 12 17:33:13 PDT 2015


Author: ericwf
Date: Fri Jun 12 19:33:13 2015
New Revision: 239649

URL: http://llvm.org/viewvc/llvm-project?rev=239649&view=rev
Log:
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.

Modified:
    libcxx/trunk/include/type_traits
    libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp

Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=239649&r1=239648&r2=239649&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Fri Jun 12 19:33:13 2015
@@ -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
 

Modified: libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp?rev=239649&r1=239648&r2=239649&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp Fri Jun 12 19:33:13 2015
@@ -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
 }





More information about the cfe-commits mailing list