diff options
author | tzik <tzik@chromium.org> | 2016-03-09 23:17:25 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-10 07:19:09 +0000 |
commit | 403cb6c9b17343999f09df79b82b56e77bd93839 (patch) | |
tree | 4c072eb309fc7e1245e908ce2a8130541e555a42 | |
parent | 2df71fea360d6abde88d9c0de8fe084cb95f670e (diff) | |
download | chromium_src-403cb6c9b17343999f09df79b82b56e77bd93839.zip chromium_src-403cb6c9b17343999f09df79b82b56e77bd93839.tar.gz chromium_src-403cb6c9b17343999f09df79b82b56e77bd93839.tar.bz2 |
Replace template_util.h stuff with C++11 <type_traits>
BUG=554293
Review URL: https://codereview.chromium.org/1774443002
Cr-Commit-Position: refs/heads/master@{#380369}
24 files changed, 69 insertions, 259 deletions
diff --git a/base/android/scoped_java_ref.h b/base/android/scoped_java_ref.h index 8dcf2bc..a1b4b13 100644 --- a/base/android/scoped_java_ref.h +++ b/base/android/scoped_java_ref.h @@ -8,10 +8,11 @@ #include <jni.h> #include <stddef.h> +#include <type_traits> + #include "base/base_export.h" #include "base/logging.h" #include "base/macros.h" -#include "base/template_util.h" namespace base { namespace android { @@ -193,7 +194,7 @@ class ScopedJavaLocalRef : public JavaRef<T> { template<typename U> void Reset(JNIEnv* env, U obj) { - static_assert(base::is_convertible<U, T>::value, + static_assert(std::is_convertible<U, T>::value, "U must be convertible to T"); env_ = this->SetNewLocalRef(env, obj); } @@ -264,7 +265,7 @@ class ScopedJavaGlobalRef : public JavaRef<T> { template<typename U> void Reset(JNIEnv* env, U obj) { - static_assert(base::is_convertible<U, T>::value, + static_assert(std::is_convertible<U, T>::value, "U must be convertible to T"); this->SetNewGlobalRef(env, obj); } diff --git a/base/bind_helpers.h b/base/bind_helpers.h index a551465..117fc68 100644 --- a/base/bind_helpers.h +++ b/base/bind_helpers.h @@ -150,7 +150,6 @@ #include "base/callback.h" #include "base/memory/weak_ptr.h" -#include "base/template_util.h" #include "build/build_config.h" namespace base { @@ -262,21 +261,21 @@ class SupportsAddRefAndRelease { // Helpers to assert that arguments of a recounted type are bound with a // scoped_refptr. template <bool IsClasstype, typename T> -struct UnsafeBindtoRefCountedArgHelper : false_type { +struct UnsafeBindtoRefCountedArgHelper : std::false_type { }; template <typename T> struct UnsafeBindtoRefCountedArgHelper<true, T> - : integral_constant<bool, SupportsAddRefAndRelease<T>::value> { + : std::integral_constant<bool, SupportsAddRefAndRelease<T>::value> { }; template <typename T> -struct UnsafeBindtoRefCountedArg : false_type { +struct UnsafeBindtoRefCountedArg : std::false_type { }; template <typename T> struct UnsafeBindtoRefCountedArg<T*> - : UnsafeBindtoRefCountedArgHelper<is_class<T>::value, T> { + : UnsafeBindtoRefCountedArgHelper<std::is_class<T>::value, T> { }; template <typename T> @@ -433,14 +432,14 @@ T Unwrap(PassedWrapper<T>& o) { // The first argument should be the type of the object that will be received by // the method. template <bool IsMethod, typename... Args> -struct IsWeakMethod : public false_type {}; +struct IsWeakMethod : public std::false_type {}; template <typename T, typename... Args> -struct IsWeakMethod<true, WeakPtr<T>, Args...> : public true_type {}; +struct IsWeakMethod<true, WeakPtr<T>, Args...> : public std::true_type {}; template <typename T, typename... Args> struct IsWeakMethod<true, ConstRefWrapper<WeakPtr<T>>, Args...> - : public true_type {}; + : public std::true_type {}; // Packs a list of types to hold them in a single type. diff --git a/base/bind_internal.h b/base/bind_internal.h index 38a5756..199467c 100644 --- a/base/bind_internal.h +++ b/base/bind_internal.h @@ -68,7 +68,7 @@ namespace internal { // Implementation note: This non-specialized case handles zero-arity case only. // Non-zero-arity cases should be handled by the specialization below. template <typename List> -struct HasNonConstReferenceItem : false_type {}; +struct HasNonConstReferenceItem : std::false_type {}; // Implementation note: Select true_type if the first parameter is a non-const // reference. Otherwise, skip the first parameter and check rest of parameters @@ -76,7 +76,7 @@ struct HasNonConstReferenceItem : false_type {}; template <typename T, typename... Args> struct HasNonConstReferenceItem<TypeList<T, Args...>> : std::conditional<is_non_const_reference<T>::value, - true_type, + std::true_type, HasNonConstReferenceItem<TypeList<Args...>>>::type {}; // HasRefCountedTypeAsRawPtr selects true_type when any of the |Args| is a raw @@ -84,7 +84,7 @@ struct HasNonConstReferenceItem<TypeList<T, Args...>> // Implementation note: This non-specialized case handles zero-arity case only. // Non-zero-arity cases should be handled by the specialization below. template <typename... Args> -struct HasRefCountedTypeAsRawPtr : false_type {}; +struct HasRefCountedTypeAsRawPtr : std::false_type {}; // Implementation note: Select true_type if the first parameter is a raw pointer // to a RefCounted type. Otherwise, skip the first parameter and check rest of @@ -92,7 +92,7 @@ struct HasRefCountedTypeAsRawPtr : false_type {}; template <typename T, typename... Args> struct HasRefCountedTypeAsRawPtr<T, Args...> : std::conditional<NeedsScopedRefptrButGetsRawPtr<T>::value, - true_type, + std::true_type, HasRefCountedTypeAsRawPtr<Args...>>::type {}; // BindsArrayToFirstArg selects true_type when |is_method| is true and the first @@ -101,11 +101,11 @@ struct HasRefCountedTypeAsRawPtr<T, Args...> // zero-arity case only. Other cases should be handled by the specialization // below. template <bool is_method, typename... Args> -struct BindsArrayToFirstArg : false_type {}; +struct BindsArrayToFirstArg : std::false_type {}; template <typename T, typename... Args> struct BindsArrayToFirstArg<true, T, Args...> - : is_array<typename std::remove_reference<T>::type> {}; + : std::is_array<typename std::remove_reference<T>::type> {}; // HasRefCountedParamAsRawPtr is the same to HasRefCountedTypeAsRawPtr except // when |is_method| is true HasRefCountedParamAsRawPtr skips the first argument. @@ -170,7 +170,7 @@ class RunnableAdapter<R(T::*)(Args...)> { // MSVC 2013 doesn't support Type Alias of function types. // Revisit this after we update it to newer version. typedef R RunType(T*, Args...); - using IsMethod = true_type; + using IsMethod = std::true_type; explicit RunnableAdapter(R(T::*method)(Args...)) : method_(method) { @@ -190,7 +190,7 @@ template <typename R, typename T, typename... Args> class RunnableAdapter<R(T::*)(Args...) const> { public: using RunType = R(const T*, Args...); - using IsMethod = true_type; + using IsMethod = std::true_type; explicit RunnableAdapter(R(T::*method)(Args...) const) : method_(method) { @@ -322,7 +322,7 @@ struct InvokeHelper<true, ReturnType, Runnable> { // WeakCalls are only supported for functions with a void return type. // Otherwise, the function result would be undefined if the the WeakPtr<> // is invalidated. - static_assert(is_void<ReturnType>::value, + static_assert(std::is_void<ReturnType>::value, "weak_ptrs can only bind to methods without return values"); }; diff --git a/base/callback.h b/base/callback.h index 5f73b7f..c04e90d 100644 --- a/base/callback.h +++ b/base/callback.h @@ -7,7 +7,6 @@ #include "base/callback_forward.h" #include "base/callback_internal.h" -#include "base/template_util.h" // NOTE: Header files that do not require the full definition of Callback or // Closure should #include "base/callback_forward.h" instead of this file. diff --git a/base/callback_internal.h b/base/callback_internal.h index 7319614..1670557 100644 --- a/base/callback_internal.h +++ b/base/callback_internal.h @@ -19,7 +19,6 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/template_util.h" namespace base { namespace internal { @@ -127,7 +126,13 @@ extern template class CallbackBase<CopyMode::Copyable>; // confuses template deduction in VS2013 with certain types such as // std::unique_ptr. // TODO(dcheng): Revisit this when Windows switches to VS2015 by default. + template <typename T> struct IsMoveOnlyType { + // Types YesType and NoType are guaranteed such that sizeof(YesType) < + // sizeof(NoType). + using YesType = char; + struct NoType { YesType dummy[2]; }; + template <typename U> static YesType Test(const typename U::MoveOnlyTypeForCPP03*); @@ -135,7 +140,7 @@ template <typename T> struct IsMoveOnlyType { static NoType Test(...); static const bool value = sizeof((Test<T>(0))) == sizeof(YesType) && - !is_const<T>::value; + !std::is_const<T>::value; }; // Specialization of IsMoveOnlyType so that std::unique_ptr is still considered diff --git a/base/memory/raw_scoped_refptr_mismatch_checker.h b/base/memory/raw_scoped_refptr_mismatch_checker.h index 1e88b48..5dbc183 100644 --- a/base/memory/raw_scoped_refptr_mismatch_checker.h +++ b/base/memory/raw_scoped_refptr_mismatch_checker.h @@ -5,10 +5,10 @@ #ifndef BASE_MEMORY_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_ #define BASE_MEMORY_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_ +#include <tuple> +#include <type_traits> + #include "base/memory/ref_counted.h" -#include "base/template_util.h" -#include "base/tuple.h" -#include "build/build_config.h" // It is dangerous to post a task with a T* argument where T is a subtype of // RefCounted(Base|ThreadSafeBase), since by the time the parameter is used, the @@ -25,20 +25,14 @@ namespace internal { template <typename T> struct NeedsScopedRefptrButGetsRawPtr { -#if defined(OS_WIN) - enum { - value = base::false_type::value - }; -#else enum { // Human readable translation: you needed to be a scoped_refptr if you are a // raw pointer type and are convertible to a RefCounted(Base|ThreadSafeBase) // type. - value = (is_pointer<T>::value && - (is_convertible<T, subtle::RefCountedBase*>::value || - is_convertible<T, subtle::RefCountedThreadSafeBase*>::value)) + value = (std::is_pointer<T>::value && + (std::is_convertible<T, subtle::RefCountedBase*>::value || + std::is_convertible<T, subtle::RefCountedThreadSafeBase*>::value)) }; -#endif }; template <typename Params> diff --git a/base/memory/scoped_ptr.h b/base/memory/scoped_ptr.h index 358e9f1..db0d04b 100644 --- a/base/memory/scoped_ptr.h +++ b/base/memory/scoped_ptr.h @@ -102,7 +102,6 @@ #include "base/logging.h" #include "base/macros.h" #include "base/move.h" -#include "base/template_util.h" #include "build/build_config.h" namespace base { @@ -179,8 +178,8 @@ namespace internal { template <typename T> struct IsNotRefCounted { enum { - value = !base::is_convertible<T*, base::subtle::RefCountedBase*>::value && - !base::is_convertible<T*, base::subtle::RefCountedThreadSafeBase*>:: + value = !std::is_convertible<T*, base::subtle::RefCountedBase*>::value && + !std::is_convertible<T*, base::subtle::RefCountedThreadSafeBase*>:: value }; }; diff --git a/base/memory/weak_ptr.h b/base/memory/weak_ptr.h index 4e50c27..9ba5e25 100644 --- a/base/memory/weak_ptr.h +++ b/base/memory/weak_ptr.h @@ -70,12 +70,13 @@ #ifndef BASE_MEMORY_WEAK_PTR_H_ #define BASE_MEMORY_WEAK_PTR_H_ +#include <type_traits> + #include "base/base_export.h" #include "base/logging.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/sequence_checker.h" -#include "base/template_util.h" namespace base { @@ -160,8 +161,8 @@ class SupportsWeakPtrBase { // function that makes calling this easier. template<typename Derived> static WeakPtr<Derived> StaticAsWeakPtr(Derived* t) { - typedef - is_convertible<Derived, internal::SupportsWeakPtrBase&> convertible; + using convertible = + std::is_convertible<Derived*, internal::SupportsWeakPtrBase*>; static_assert(convertible::value, "AsWeakPtr argument must inherit from SupportsWeakPtr"); return AsWeakPtrImpl<Derived>(t, *t); diff --git a/base/numerics/safe_numerics_unittest.cc b/base/numerics/safe_numerics_unittest.cc index cb63ad0..861f515 100644 --- a/base/numerics/safe_numerics_unittest.cc +++ b/base/numerics/safe_numerics_unittest.cc @@ -11,7 +11,6 @@ #include "base/compiler_specific.h" #include "base/numerics/safe_conversions.h" #include "base/numerics/safe_math.h" -#include "base/template_util.h" #include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/base/template_util.h b/base/template_util.h index d58807a..0c3cac2 100644 --- a/base/template_util.h +++ b/base/template_util.h @@ -5,117 +5,15 @@ #ifndef BASE_TEMPLATE_UTIL_H_ #define BASE_TEMPLATE_UTIL_H_ -#include <stddef.h> +#include <type_traits> #include "build/build_config.h" namespace base { -// template definitions from tr1 - -template<class T, T v> -struct integral_constant { - static const T value = v; - typedef T value_type; - typedef integral_constant<T, v> type; -}; - -template <class T, T v> const T integral_constant<T, v>::value; - -typedef integral_constant<bool, true> true_type; -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. 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, 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 {}; -template <class T> struct is_same<T,T> : true_type {}; - -template<class> struct is_array : public false_type {}; -template<class T, size_t n> struct is_array<T[n]> : public true_type {}; -template<class T> struct is_array<T[]> : public true_type {}; - -template <class T> struct is_non_const_reference : false_type {}; -template <class T> struct is_non_const_reference<T&> : true_type {}; -template <class T> struct is_non_const_reference<const T&> : false_type {}; - -template <class T> struct is_const : false_type {}; -template <class T> struct is_const<const T> : true_type {}; - -template <class T> struct is_void : false_type {}; -template <> struct is_void<void> : true_type {}; - -namespace internal { - -// Types YesType and NoType are guaranteed such that sizeof(YesType) < -// sizeof(NoType). -typedef char YesType; - -struct NoType { - YesType dummy[2]; -}; - -// This class is an implementation detail for is_convertible, and you -// don't need to know how it works to use is_convertible. For those -// who care: we declare two different functions, one whose argument is -// of type To and one with a variadic argument list. We give them -// return types of different size, so we can use sizeof to trick the -// compiler into telling us which function it would have chosen if we -// had called it with an argument of type From. See Alexandrescu's -// _Modern C++ Design_ for more details on this sort of trick. - -struct ConvertHelper { - template <typename To> - static YesType Test(To); - - template <typename To> - static NoType Test(...); - - template <typename From> - static From& Create(); -}; - -// Used to determine if a type is a struct/union/class. Inspired by Boost's -// is_class type_trait implementation. -struct IsClassHelper { - template <typename C> - static YesType Test(void(C::*)(void)); - - template <typename C> - static NoType Test(...); -}; - -} // namespace internal - -// Inherits from true_type if From is convertible to To, false_type otherwise. -// -// Note that if the type is convertible, this will be a true_type REGARDLESS -// of whether or not the conversion would emit a warning. -template <typename From, typename To> -struct is_convertible - : integral_constant<bool, - sizeof(internal::ConvertHelper::Test<To>( - internal::ConvertHelper::Create<From>())) == - sizeof(internal::YesType)> { -}; - -template <typename T> -struct is_class - : integral_constant<bool, - sizeof(internal::IsClassHelper::Test<T>(0)) == - sizeof(internal::YesType)> { -}; +template <class T> struct is_non_const_reference : std::false_type {}; +template <class T> struct is_non_const_reference<T&> : std::true_type {}; +template <class T> struct is_non_const_reference<const T&> : std::false_type {}; } // namespace base diff --git a/base/template_util_unittest.cc b/base/template_util_unittest.cc index b960ab1..25441cd 100644 --- a/base/template_util_unittest.cc +++ b/base/template_util_unittest.cc @@ -9,99 +9,11 @@ namespace base { namespace { -struct AStruct {}; -class AClass {}; -enum AnEnum {}; - -class Parent {}; -class Child : public Parent {}; - -// is_pointer<Type> -static_assert(!is_pointer<int>::value, "IsPointer"); -static_assert(!is_pointer<int&>::value, "IsPointer"); -static_assert(is_pointer<int*>::value, "IsPointer"); -static_assert(is_pointer<const int*>::value, "IsPointer"); - -// is_array<Type> -static_assert(!is_array<int>::value, "IsArray"); -static_assert(!is_array<int*>::value, "IsArray"); -static_assert(!is_array<int (*)[3]>::value, "IsArray"); -static_assert(is_array<int[]>::value, "IsArray"); -static_assert(is_array<const int[]>::value, "IsArray"); -static_assert(is_array<int[3]>::value, "IsArray"); - // is_non_const_reference<Type> static_assert(!is_non_const_reference<int>::value, "IsNonConstReference"); static_assert(!is_non_const_reference<const int&>::value, "IsNonConstReference"); static_assert(is_non_const_reference<int&>::value, "IsNonConstReference"); -// is_convertible<From, To> - -// Extra parens needed to make preprocessor macro parsing happy. Otherwise, -// it sees the equivalent of: -// -// (is_convertible < Child), (Parent > ::value) -// -// Silly C++. -static_assert((is_convertible<Child, Parent>::value), "IsConvertible"); -static_assert(!(is_convertible<Parent, Child>::value), "IsConvertible"); -static_assert(!(is_convertible<Parent, AStruct>::value), "IsConvertible"); -static_assert((is_convertible<int, double>::value), "IsConvertible"); -static_assert((is_convertible<int*, void*>::value), "IsConvertible"); -static_assert(!(is_convertible<void*, int*>::value), "IsConvertible"); - -// Array types are an easy corner case. Make sure to test that -// it does indeed compile. -static_assert(!(is_convertible<int[10], double>::value), "IsConvertible"); -static_assert(!(is_convertible<double, int[10]>::value), "IsConvertible"); -static_assert((is_convertible<int[10], int*>::value), "IsConvertible"); - -// is_same<Type1, Type2> -static_assert(!(is_same<Child, Parent>::value), "IsSame"); -static_assert(!(is_same<Parent, Child>::value), "IsSame"); -static_assert((is_same<Parent, Parent>::value), "IsSame"); -static_assert((is_same<int*, int*>::value), "IsSame"); -static_assert((is_same<int, int>::value), "IsSame"); -static_assert((is_same<void, void>::value), "IsSame"); -static_assert(!(is_same<int, double>::value), "IsSame"); - -// is_class<Type> -static_assert(is_class<AStruct>::value, "IsClass"); -static_assert(is_class<AClass>::value, "IsClass"); -static_assert(!is_class<AnEnum>::value, "IsClass"); -static_assert(!is_class<int>::value, "IsClass"); -static_assert(!is_class<char*>::value, "IsClass"); -static_assert(!is_class<int&>::value, "IsClass"); -static_assert(!is_class<char[3]>::value, "IsClass"); - -static_assert(!is_member_function_pointer<int>::value, - "IsMemberFunctionPointer"); -static_assert(!is_member_function_pointer<int*>::value, - "IsMemberFunctionPointer"); -static_assert(!is_member_function_pointer<void*>::value, - "IsMemberFunctionPointer"); -static_assert(!is_member_function_pointer<AStruct>::value, - "IsMemberFunctionPointer"); -static_assert(!is_member_function_pointer<AStruct*>::value, - "IsMemberFunctionPointer"); -static_assert(!is_member_function_pointer<void (*)()>::value, - "IsMemberFunctionPointer"); -static_assert(!is_member_function_pointer<int (*)(int)>::value, - "IsMemberFunctionPointer"); -static_assert(!is_member_function_pointer<int (*)(int, int)>::value, - "IsMemberFunctionPointer"); - -static_assert(is_member_function_pointer<void (AStruct::*)()>::value, - "IsMemberFunctionPointer"); -static_assert(is_member_function_pointer<void (AStruct::*)(int)>::value, - "IsMemberFunctionPointer"); -static_assert(is_member_function_pointer<int (AStruct::*)(int)>::value, - "IsMemberFunctionPointer"); -static_assert(is_member_function_pointer<int (AStruct::*)(int) const>::value, - "IsMemberFunctionPointer"); -static_assert(is_member_function_pointer<int (AStruct::*)(int, int)>::value, - "IsMemberFunctionPointer"); - } // namespace } // namespace base diff --git a/chrome/chrome_watcher/chrome_watcher_main.cc b/chrome/chrome_watcher/chrome_watcher_main.cc index 18f4b5a..1976c7a 100644 --- a/chrome/chrome_watcher/chrome_watcher_main.cc +++ b/chrome/chrome_watcher/chrome_watcher_main.cc @@ -27,7 +27,6 @@ #include "base/strings/string_piece.h" #include "base/strings/utf_string_conversions.h" #include "base/synchronization/waitable_event.h" -#include "base/template_util.h" #include "base/thread_task_runner_handle.h" #include "base/threading/thread.h" #include "base/time/time.h" @@ -443,5 +442,5 @@ extern "C" int WatcherMain(const base::char16* registry_path, } static_assert( - base::is_same<decltype(&WatcherMain), ChromeWatcherMainFunction>::value, + std::is_same<decltype(&WatcherMain), ChromeWatcherMainFunction>::value, "WatcherMain() has wrong type"); diff --git a/device/hid/hid_service_win.cc b/device/hid/hid_service_win.cc index 0bfc485..8a20060 100644 --- a/device/hid/hid_service_win.cc +++ b/device/hid/hid_service_win.cc @@ -70,7 +70,8 @@ void HidServiceWin::Connect(const HidDeviceId& device_id, task_runner_->PostTask( FROM_HERE, - base::Bind(callback, new HidConnectionWin(device_info, std::move(file)))); + base::Bind(callback, make_scoped_refptr( + new HidConnectionWin(device_info, std::move(file))))); } // static diff --git a/extensions/common/permissions/base_set_operators.h b/extensions/common/permissions/base_set_operators.h index 2ac5357..ffe0323 100644 --- a/extensions/common/permissions/base_set_operators.h +++ b/extensions/common/permissions/base_set_operators.h @@ -11,7 +11,6 @@ #include <map> #include "base/memory/linked_ptr.h" -#include "base/template_util.h" namespace extensions { @@ -71,8 +70,8 @@ class BaseSetOperators { BaseSetOperators() { // Ensure |T| is convertible to us, so we can safely downcast when calling // methods that must exist in |T|. - static_assert((base::is_convertible<T*, BaseSetOperators<T>*>::value), - "U ptr must implicitly convert to T ptr"); + static_assert(std::is_convertible<T*, BaseSetOperators<T>*>::value, + "U ptr must implicitly convert to T ptr"); } BaseSetOperators(const T& set) { diff --git a/gin/object_template_builder.h b/gin/object_template_builder.h index 72369ee..bf0ece1 100644 --- a/gin/object_template_builder.h +++ b/gin/object_template_builder.h @@ -10,7 +10,6 @@ #include "base/bind.h" #include "base/callback.h" #include "base/strings/string_piece.h" -#include "base/template_util.h" #include "gin/converter.h" #include "gin/function_template.h" #include "gin/gin_export.h" @@ -57,7 +56,7 @@ struct CallbackTraits<base::Callback<T> > { template <typename T> struct CallbackTraits< T, - typename std::enable_if<base::is_member_function_pointer<T>::value>::type> { + typename std::enable_if<std::is_member_function_pointer<T>::value>::type> { static v8::Local<v8::FunctionTemplate> CreateTemplate(v8::Isolate* isolate, T callback) { return CreateFunctionTemplate(isolate, base::Bind(callback), diff --git a/gin/wrappable.h b/gin/wrappable.h index f253fd9..73c089a 100644 --- a/gin/wrappable.h +++ b/gin/wrappable.h @@ -8,7 +8,6 @@ #include <type_traits> #include "base/macros.h" -#include "base/template_util.h" #include "gin/converter.h" #include "gin/gin_export.h" #include "gin/public/wrapper_info.h" @@ -107,7 +106,7 @@ class Wrappable : public WrappableBase { template <typename T> struct Converter<T*, typename std::enable_if< - base::is_convertible<T*, WrappableBase*>::value>::type> { + std::is_convertible<T*, WrappableBase*>::value>::type> { static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, T* val) { return val->GetWrapper(isolate); } diff --git a/google_apis/drive/test_util.h b/google_apis/drive/test_util.h index f3fbf8d..96cf511 100644 --- a/google_apis/drive/test_util.h +++ b/google_apis/drive/test_util.h @@ -17,7 +17,6 @@ #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" -#include "base/template_util.h" #include "google_apis/drive/base_requests.h" #include "google_apis/drive/drive_api_error_codes.h" #include "google_apis/drive/task_util.h" @@ -137,9 +136,9 @@ namespace internal { // Declare if the type is movable or not. Currently limited to scoped_ptr only. // We can add more types upon the usage. -template<typename T> struct IsMovable : base::false_type {}; +template<typename T> struct IsMovable : std::false_type {}; template<typename T, typename D> -struct IsMovable<scoped_ptr<T, D> > : base::true_type {}; +struct IsMovable<scoped_ptr<T, D> > : std::true_type {}; // InType is const T& if |UseConstRef| is true, otherwise |T|. template<bool UseConstRef, typename T> struct InTypeHelper { @@ -169,7 +168,7 @@ struct CopyResultCallbackHelper // |InType| is const T&. // 2) Otherwise, |T| as is. : InTypeHelper< - base::is_class<T>::value && !IsMovable<T>::value, // UseConstRef + std::is_class<T>::value && !IsMovable<T>::value, // UseConstRef T>, MoveHelper<IsMovable<T>::value, T> { }; diff --git a/net/socket/client_socket_pool.h b/net/socket/client_socket_pool.h index 68946a8..73d90dd 100644 --- a/net/socket/client_socket_pool.h +++ b/net/socket/client_socket_pool.h @@ -11,7 +11,6 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/template_util.h" #include "base/time/time.h" #include "net/base/completion_callback.h" #include "net/base/load_states.h" diff --git a/net/socket/client_socket_pool_manager_impl.h b/net/socket/client_socket_pool_manager_impl.h index 538e507..e0662f1 100644 --- a/net/socket/client_socket_pool_manager_impl.h +++ b/net/socket/client_socket_pool_manager_impl.h @@ -6,12 +6,13 @@ #define NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_IMPL_H_ #include <map> +#include <type_traits> + #include "base/compiler_specific.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/stl_util.h" -#include "base/template_util.h" #include "base/threading/non_thread_safe.h" #include "net/cert/cert_database.h" #include "net/http/http_network_session.h" @@ -39,7 +40,7 @@ template <typename Key, typename Value> class OwnedPoolMap : public std::map<Key, Value> { public: OwnedPoolMap() { - static_assert(base::is_pointer<Value>::value, "value must be a pointer"); + static_assert(std::is_pointer<Value>::value, "value must be a pointer"); } ~OwnedPoolMap() { diff --git a/sandbox/linux/services/credentials.cc b/sandbox/linux/services/credentials.cc index 76038af..0e569fa 100644 --- a/sandbox/linux/services/credentials.cc +++ b/sandbox/linux/services/credentials.cc @@ -23,7 +23,6 @@ #include "base/macros.h" #include "base/posix/eintr_wrapper.h" #include "base/process/launch.h" -#include "base/template_util.h" #include "base/third_party/valgrind/valgrind.h" #include "build/build_config.h" #include "sandbox/linux/services/namespace_utils.h" diff --git a/sandbox/linux/services/namespace_utils.h b/sandbox/linux/services/namespace_utils.h index 7231033..ec5d241 100644 --- a/sandbox/linux/services/namespace_utils.h +++ b/sandbox/linux/services/namespace_utils.h @@ -7,9 +7,10 @@ #include <sys/types.h> +#include <type_traits> + #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/template_util.h" #include "sandbox/sandbox_export.h" namespace sandbox { @@ -17,7 +18,7 @@ namespace sandbox { // Utility functions for using Linux namepaces. class SANDBOX_EXPORT NamespaceUtils { public: - static_assert((base::is_same<uid_t, gid_t>::value), + static_assert(std::is_same<uid_t, gid_t>::value, "uid_t and gid_t must be the same type"); // generic_id_t can be used for either uid_t or gid_t. typedef uid_t generic_id_t; diff --git a/third_party/crashpad/README.chromium b/third_party/crashpad/README.chromium index 691b905..3bb727b 100644 --- a/third_party/crashpad/README.chromium +++ b/third_party/crashpad/README.chromium @@ -36,3 +36,5 @@ $ git am --3way --message-id -p4 /tmp/patchdir Local Modifications: - Move bit_cast from base/macros.h to its own header. +- Replace base/template_util.h with C++11 type_traits. +- Add std::is_same into compat/non_cxx11_lib/type_traits. diff --git a/third_party/crashpad/crashpad/compat/non_cxx11_lib/type_traits b/third_party/crashpad/crashpad/compat/non_cxx11_lib/type_traits index 9f11fd4..e56c220 100644 --- a/third_party/crashpad/crashpad/compat/non_cxx11_lib/type_traits +++ b/third_party/crashpad/crashpad/compat/non_cxx11_lib/type_traits @@ -30,6 +30,11 @@ struct remove_reference { using type = T; }; template <class T> struct remove_reference<T&> { using type = T; }; +template <typename T, typename S> +struct is_same { enum { value = false }; }; +template <typename T> +struct is_same<T, T> { enum { value = true }; }; + } // namespace std #endif // CXX_LIBRARY_VERSION diff --git a/third_party/crashpad/crashpad/util/win/process_info.cc b/third_party/crashpad/crashpad/util/win/process_info.cc index 5628e04..9e47206 100644 --- a/third_party/crashpad/crashpad/util/win/process_info.cc +++ b/third_party/crashpad/crashpad/util/win/process_info.cc @@ -18,11 +18,11 @@ #include <algorithm> #include <limits> +#include <type_traits> #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/strings/stringprintf.h" -#include "base/template_util.h" #include "build/build_config.h" #include "util/numeric/safe_assignment.h" #include "util/win/get_function.h" @@ -636,9 +636,9 @@ std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap( // Find all the ranges that overlap the target range, maintaining their order. ProcessInfo::MemoryBasicInformation64Vector overlapping; for (const auto& mi : memory_info) { - static_assert(base::is_same<decltype(mi.BaseAddress), WinVMAddress>::value, + static_assert(std::is_same<decltype(mi.BaseAddress), WinVMAddress>::value, "expected range address to be WinVMAddress"); - static_assert(base::is_same<decltype(mi.RegionSize), WinVMSize>::value, + static_assert(std::is_same<decltype(mi.RegionSize), WinVMSize>::value, "expected range size to be WinVMSize"); if (range.OverlapsRange(Range(mi.BaseAddress, mi.RegionSize))) overlapping.push_back(mi); |