Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: third_party/WebKit/Source/wtf/LeakAnnotations.h

Issue 1477213003: More switching to standard type traits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use std::is_base_of Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // 94 //
95 // An empty, trivial registerStatic() method is provided for all other class typ es T. 95 // An empty, trivial registerStatic() method is provided for all other class typ es T.
96 template<typename T> 96 template<typename T>
97 class CanRegisterStaticLocalReference { 97 class CanRegisterStaticLocalReference {
98 typedef char YesType; 98 typedef char YesType;
99 typedef struct NoType { 99 typedef struct NoType {
100 char padding[8]; 100 char padding[8];
101 } NoType; 101 } NoType;
102 102
103 // Check if class T has public method "T* registerAsStaticReference()". 103 // Check if class T has public method "T* registerAsStaticReference()".
104 template<typename V> static YesType checkHasRegisterAsStaticReferenceMethod( V* p, typename EnableIf<IsSubclass<V, typename std::remove_pointer<decltype(p->r egisterAsStaticReference())>::type>::value>::Type* = 0); 104 template<typename V> static YesType checkHasRegisterAsStaticReferenceMethod( V* p, typename std::enable_if<std::is_base_of<V, typename std::remove_pointer<de cltype(p->registerAsStaticReference())>::type>::value>::Type* = 0);
Nico 2015/12/09 15:09:39 Since you're replacing IsSubclass with is_base_of
Mikhail 2015/12/10 11:38:15 I do, thanks for noticing. Fixed in the latest pat
105 template<typename V> static NoType checkHasRegisterAsStaticReferenceMethod(. ..); 105 template<typename V> static NoType checkHasRegisterAsStaticReferenceMethod(. ..);
106 106
107 public: 107 public:
108 static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasRegi sterAsStaticReferenceMethod<T>(nullptr)) + sizeof(T); 108 static const bool value = sizeof(YesType) + sizeof(T) == sizeof(checkHasRegi sterAsStaticReferenceMethod<T>(nullptr)) + sizeof(T);
109 }; 109 };
110 110
111 template<typename T, bool = CanRegisterStaticLocalReference<T>::value> 111 template<typename T, bool = CanRegisterStaticLocalReference<T>::value>
112 class RegisterStaticLocalReference { 112 class RegisterStaticLocalReference {
113 public: 113 public:
114 static T* registerStatic(T* ptr) 114 static T* registerStatic(T* ptr)
(...skipping 14 matching lines...) Expand all
129 #define LEAK_SANITIZER_REGISTER_STATIC_LOCAL(Type, Object) WTF::RegisterStaticLo calReference<Type>::registerStatic(Object) 129 #define LEAK_SANITIZER_REGISTER_STATIC_LOCAL(Type, Object) WTF::RegisterStaticLo calReference<Type>::registerStatic(Object)
130 #else 130 #else
131 #define WTF_INTERNAL_LEAK_SANITIZER_DISABLED_SCOPE 131 #define WTF_INTERNAL_LEAK_SANITIZER_DISABLED_SCOPE
132 #define LEAK_SANITIZER_IGNORE_OBJECT 132 #define LEAK_SANITIZER_IGNORE_OBJECT
133 #define LEAK_SANITIZER_REGISTER_STATIC_LOCAL(Type, Object) Object 133 #define LEAK_SANITIZER_REGISTER_STATIC_LOCAL(Type, Object) Object
134 #endif // USE(LEAK_SANITIZER) 134 #endif // USE(LEAK_SANITIZER)
135 135
136 } // namespace WTF 136 } // namespace WTF
137 137
138 #endif // WTF_LeakAnnotations_h 138 #endif // WTF_LeakAnnotations_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698