| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <cstddef> // For size_t. | 9 #include <cstddef> // For size_t. |
| 10 | 10 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // _Modern C++ Design_ for more details on this sort of trick. | 63 // _Modern C++ Design_ for more details on this sort of trick. |
| 64 | 64 |
| 65 struct ConvertHelper { | 65 struct ConvertHelper { |
| 66 template <typename To> | 66 template <typename To> |
| 67 static YesType Test(To); | 67 static YesType Test(To); |
| 68 | 68 |
| 69 template <typename To> | 69 template <typename To> |
| 70 static NoType Test(...); | 70 static NoType Test(...); |
| 71 | 71 |
| 72 template <typename From> | 72 template <typename From> |
| 73 static From Create(); | 73 static From& Create(); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 // Used to determine if a type is a struct/union/class. Inspired by Boost's | 76 // Used to determine if a type is a struct/union/class. Inspired by Boost's |
| 77 // is_class type_trait implementation. | 77 // is_class type_trait implementation. |
| 78 struct IsClassHelper { | 78 struct IsClassHelper { |
| 79 template <typename C> | 79 template <typename C> |
| 80 static YesType Test(void(C::*)(void)); | 80 static YesType Test(void(C::*)(void)); |
| 81 | 81 |
| 82 template <typename C> | 82 template <typename C> |
| 83 static NoType Test(...); | 83 static NoType Test(...); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 100 template <typename T> | 100 template <typename T> |
| 101 struct is_class | 101 struct is_class |
| 102 : integral_constant<bool, | 102 : integral_constant<bool, |
| 103 sizeof(internal::IsClassHelper::Test<T>(0)) == | 103 sizeof(internal::IsClassHelper::Test<T>(0)) == |
| 104 sizeof(internal::YesType)> { | 104 sizeof(internal::YesType)> { |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 } // namespace base | 107 } // namespace base |
| 108 | 108 |
| 109 #endif // BASE_TEMPLATE_UTIL_H_ | 109 #endif // BASE_TEMPLATE_UTIL_H_ |
| OLD | NEW |