Commit 489d6713 authored by aa's avatar aa Committed by Commit bot

Update base::is_member_function_pointer to use variadic templates.

BUG=

Review URL: https://codereview.chromium.org/598223003

Cr-Commit-Position: refs/heads/master@{#296817}
parent dfa74e6b
......@@ -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 {};
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment