| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_TEMPLATE_UTIL_H_ | 5 #ifndef BASE_TEMPLATE_UTIL_H_ |
| 6 #define BASE_TEMPLATE_UTIL_H_ | 6 #define BASE_TEMPLATE_UTIL_H_ |
| 7 | 7 |
| 8 #include <cstddef> // For size_t. | 8 #include <cstddef> // For size_t. |
| 9 | 9 |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 template <class T, T v> const T integral_constant<T, v>::value; | 23 template <class T, T v> const T integral_constant<T, v>::value; |
| 24 | 24 |
| 25 typedef integral_constant<bool, true> true_type; | 25 typedef integral_constant<bool, true> true_type; |
| 26 typedef integral_constant<bool, false> false_type; | 26 typedef integral_constant<bool, false> false_type; |
| 27 | 27 |
| 28 template <class T> struct is_pointer : false_type {}; | 28 template <class T> struct is_pointer : false_type {}; |
| 29 template <class T> struct is_pointer<T*> : true_type {}; | 29 template <class T> struct is_pointer<T*> : true_type {}; |
| 30 | 30 |
| 31 // Member function pointer detection up to four params. Add more as needed | 31 // Member function pointer detection. This is built-in to C++ 11's stdlib, and |
| 32 // below. This is built-in to C++ 11, and we can remove this when we switch. | 32 // we can remove this when we switch to it. |
| 33 template<typename T> | 33 template<typename T> |
| 34 struct is_member_function_pointer : false_type {}; | 34 struct is_member_function_pointer : false_type {}; |
| 35 | 35 |
| 36 template <typename R, typename Z> | 36 template <typename R, typename Z, typename... A> |
| 37 struct is_member_function_pointer<R(Z::*)()> : true_type {}; | 37 struct is_member_function_pointer<R(Z::*)(A...)> : true_type {}; |
| 38 template <typename R, typename Z> | 38 template <typename R, typename Z, typename... A> |
| 39 struct is_member_function_pointer<R(Z::*)() const> : true_type {}; | 39 struct is_member_function_pointer<R(Z::*)(A...) const> : true_type {}; |
| 40 | |
| 41 template <typename R, typename Z, typename A> | |
| 42 struct is_member_function_pointer<R(Z::*)(A)> : true_type {}; | |
| 43 template <typename R, typename Z, typename A> | |
| 44 struct is_member_function_pointer<R(Z::*)(A) const> : true_type {}; | |
| 45 | |
| 46 template <typename R, typename Z, typename A, typename B> | |
| 47 struct is_member_function_pointer<R(Z::*)(A, B)> : true_type {}; | |
| 48 template <typename R, typename Z, typename A, typename B> | |
| 49 struct is_member_function_pointer<R(Z::*)(A, B) const> : true_type {}; | |
| 50 | |
| 51 template <typename R, typename Z, typename A, typename B, typename C> | |
| 52 struct is_member_function_pointer<R(Z::*)(A, B, C)> : true_type {}; | |
| 53 template <typename R, typename Z, typename A, typename B, typename C> | |
| 54 struct is_member_function_pointer<R(Z::*)(A, B, C) const> : true_type {}; | |
| 55 | |
| 56 template <typename R, typename Z, typename A, typename B, typename C, | |
| 57 typename D> | |
| 58 struct is_member_function_pointer<R(Z::*)(A, B, C, D)> : true_type {}; | |
| 59 template <typename R, typename Z, typename A, typename B, typename C, | |
| 60 typename D> | |
| 61 struct is_member_function_pointer<R(Z::*)(A, B, C, D) const> : true_type {}; | |
| 62 | 40 |
| 63 | 41 |
| 64 template <class T, class U> struct is_same : public false_type {}; | 42 template <class T, class U> struct is_same : public false_type {}; |
| 65 template <class T> struct is_same<T,T> : true_type {}; | 43 template <class T> struct is_same<T,T> : true_type {}; |
| 66 | 44 |
| 67 template<class> struct is_array : public false_type {}; | 45 template<class> struct is_array : public false_type {}; |
| 68 template<class T, size_t n> struct is_array<T[n]> : public true_type {}; | 46 template<class T, size_t n> struct is_array<T[n]> : public true_type {}; |
| 69 template<class T> struct is_array<T[]> : public true_type {}; | 47 template<class T> struct is_array<T[]> : public true_type {}; |
| 70 | 48 |
| 71 template <class T> struct is_non_const_reference : false_type {}; | 49 template <class T> struct is_non_const_reference : false_type {}; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 119 |
| 142 template<bool B, class T = void> | 120 template<bool B, class T = void> |
| 143 struct enable_if {}; | 121 struct enable_if {}; |
| 144 | 122 |
| 145 template<class T> | 123 template<class T> |
| 146 struct enable_if<true, T> { typedef T type; }; | 124 struct enable_if<true, T> { typedef T type; }; |
| 147 | 125 |
| 148 } // namespace base | 126 } // namespace base |
| 149 | 127 |
| 150 #endif // BASE_TEMPLATE_UTIL_H_ | 128 #endif // BASE_TEMPLATE_UTIL_H_ |
| OLD | NEW |