summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/template_util.h34
-rw-r--r--base/template_util_unittest.cc25
2 files changed, 8 insertions, 51 deletions
diff --git a/base/template_util.h b/base/template_util.h
index f4bf746..83fa322 100644
--- a/base/template_util.h
+++ b/base/template_util.h
@@ -28,37 +28,15 @@ typedef integral_constant<bool, false> false_type;
template <class T> struct is_pointer : false_type {};
template <class T> struct is_pointer<T*> : true_type {};
-// Member function pointer detection up to four params. Add more as needed
-// below. This is built-in to C++ 11, and we can remove this when we switch.
+// Member function pointer detection. This is built-in to C++ 11's stdlib, and
+// we can remove this when we switch to it.
template<typename T>
struct is_member_function_pointer : false_type {};
-template <typename R, typename Z>
-struct is_member_function_pointer<R(Z::*)()> : true_type {};
-template <typename R, typename Z>
-struct is_member_function_pointer<R(Z::*)() const> : true_type {};
-
-template <typename R, typename Z, typename A>
-struct is_member_function_pointer<R(Z::*)(A)> : true_type {};
-template <typename R, typename Z, typename A>
-struct is_member_function_pointer<R(Z::*)(A) const> : true_type {};
-
-template <typename R, typename Z, typename A, typename B>
-struct is_member_function_pointer<R(Z::*)(A, B)> : true_type {};
-template <typename R, typename Z, typename A, typename B>
-struct is_member_function_pointer<R(Z::*)(A, B) const> : true_type {};
-
-template <typename R, typename Z, typename A, typename B, typename C>
-struct is_member_function_pointer<R(Z::*)(A, B, C)> : true_type {};
-template <typename R, typename Z, typename A, typename B, typename C>
-struct is_member_function_pointer<R(Z::*)(A, B, C) const> : true_type {};
-
-template <typename R, typename Z, typename A, typename B, typename C,
- typename D>
-struct is_member_function_pointer<R(Z::*)(A, B, C, D)> : true_type {};
-template <typename R, typename Z, typename A, typename B, typename C,
- typename D>
-struct is_member_function_pointer<R(Z::*)(A, B, C, D) const> : true_type {};
+template <typename R, typename Z, typename... A>
+struct is_member_function_pointer<R(Z::*)(A...)> : true_type {};
+template <typename R, typename Z, typename... A>
+struct is_member_function_pointer<R(Z::*)(A...) const> : true_type {};
template <class T, class U> struct is_same : public false_type {};
diff --git a/base/template_util_unittest.cc b/base/template_util_unittest.cc
index 98ad938..3ec3887 100644
--- a/base/template_util_unittest.cc
+++ b/base/template_util_unittest.cc
@@ -87,6 +87,8 @@ COMPILE_ASSERT(!is_member_function_pointer<AStruct>::value,
IsMemberFunctionPointer);
COMPILE_ASSERT(!is_member_function_pointer<AStruct*>::value,
IsMemberFunctionPointer);
+COMPILE_ASSERT(!is_member_function_pointer<void(*)()>::value,
+ IsMemberFunctionPointer);
COMPILE_ASSERT(!is_member_function_pointer<int(*)(int)>::value,
IsMemberFunctionPointer);
COMPILE_ASSERT(!is_member_function_pointer<int(*)(int, int)>::value,
@@ -102,29 +104,6 @@ COMPILE_ASSERT(is_member_function_pointer<int (AStruct::*)(int) const>::value,
IsMemberFunctionPointer);
COMPILE_ASSERT(is_member_function_pointer<int (AStruct::*)(int, int)>::value,
IsMemberFunctionPointer);
-COMPILE_ASSERT(is_member_function_pointer<
- int (AStruct::*)(int, int) const>::value,
- IsMemberFunctionPointer);
-COMPILE_ASSERT(is_member_function_pointer<
- int (AStruct::*)(int, int, int)>::value,
- IsMemberFunctionPointer);
-COMPILE_ASSERT(is_member_function_pointer<
- int (AStruct::*)(int, int, int) const>::value,
- IsMemberFunctionPointer);
-COMPILE_ASSERT(is_member_function_pointer<
- int (AStruct::*)(int, int, int, int)>::value,
- IsMemberFunctionPointer);
-COMPILE_ASSERT(is_member_function_pointer<
- int (AStruct::*)(int, int, int, int) const>::value,
- IsMemberFunctionPointer);
-
-// False because we don't have a specialization for 5 params yet.
-COMPILE_ASSERT(!is_member_function_pointer<
- int (AStruct::*)(int, int, int, int, int)>::value,
- IsMemberFunctionPointer);
-COMPILE_ASSERT(!is_member_function_pointer<
- int (AStruct::*)(int, int, int, int, int) const>::value,
- IsMemberFunctionPointer);
} // namespace
} // namespace base