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

Side by Side Diff: include/private/SkTLogic.h

Issue 1360943003: simplify code in SkRecords.h (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: another SaveLayer Created 5 years, 2 months 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
« no previous file with comments | « include/private/SkRecords.h ('k') | src/core/SkMiniRecorder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 * 6 *
7 * 7 *
8 * This header provides some of the helpers (std::integral_constant) and 8 * This header provides some of the helpers (std::integral_constant) and
9 * type transformations (std::conditional) which will become available with 9 * type transformations (std::conditional) which will become available with
10 * C++11 in the type_traits header. 10 * C++11 in the type_traits header.
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // same_xxx<D, S> can be written as copy_xxx<remove_xxx_t<D>, S> 213 // same_xxx<D, S> can be written as copy_xxx<remove_xxx_t<D>, S>
214 template <typename D, typename S> using same_const = copy_const<skstd::remove_co nst_t<D>, S>; 214 template <typename D, typename S> using same_const = copy_const<skstd::remove_co nst_t<D>, S>;
215 template <typename D, typename S> using same_const_t = typename same_const<D, S> ::type; 215 template <typename D, typename S> using same_const_t = typename same_const<D, S> ::type;
216 template <typename D, typename S> using same_volatile =copy_volatile<skstd::remo ve_volatile_t<D>,S>; 216 template <typename D, typename S> using same_volatile =copy_volatile<skstd::remo ve_volatile_t<D>,S>;
217 template <typename D, typename S> using same_volatile_t = typename same_volatile <D, S>::type; 217 template <typename D, typename S> using same_volatile_t = typename same_volatile <D, S>::type;
218 template <typename D, typename S> using same_cv = copy_cv<skstd::remove_cv_t<D>, S>; 218 template <typename D, typename S> using same_cv = copy_cv<skstd::remove_cv_t<D>, S>;
219 template <typename D, typename S> using same_cv_t = typename same_cv<D, S>::type ; 219 template <typename D, typename S> using same_cv_t = typename same_cv<D, S>::type ;
220 220
221 } // namespace sknonstd 221 } // namespace sknonstd
222 222
223 /** Use as a return type to enable a function only when cond_type::value is true , 223 // Just a pithier wrapper for enable_if_t.
224 * like C++14's std::enable_if_t. E.g. (N.B. this is a dumb example.) 224 #define SK_WHEN(condition, T) skstd::enable_if_t<!!(condition), T>
225 * SK_WHEN(true_type, int) f(void* ptr) { return 1; }
226 * SK_WHEN(!true_type, int) f(void* ptr) { return 2; }
227 */
228 #define SK_WHEN(cond_prefix, T) skstd::enable_if_t<cond_prefix::value, T>
229
230 // See http://en.wikibooks.org/wiki/More_C++_Idioms/Member_Detector
231 #define SK_CREATE_MEMBER_DETECTOR(member) \
232 template <typename T> \
233 class HasMember_##member { \
234 struct Fallback { int member; }; \
235 struct Derived : T, Fallback {}; \
236 template <typename U, U> struct Check; \
237 template <typename U> static uint8_t func(Check<int Fallback::*, &U::member> *); \
238 template <typename U> static uint16_t func(...); \
239 public: \
240 typedef HasMember_##member type; \
241 static const bool value = sizeof(func<Derived>(NULL)) == sizeof(uint16_t); \
242 }
243
244 // Same sort of thing as SK_CREATE_MEMBER_DETECTOR, but checks for the existence of a nested type.
245 #define SK_CREATE_TYPE_DETECTOR(type) \
246 template <typename T> \
247 class HasType_##type { \
248 template <typename U> static uint8_t func(typename U::type*); \
249 template <typename U> static uint16_t func(...); \
250 public: \
251 static const bool value = sizeof(func<T>(NULL)) == sizeof(uint8_t); \
252 }
253 225
254 #endif 226 #endif
OLDNEW
« no previous file with comments | « include/private/SkRecords.h ('k') | src/core/SkMiniRecorder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698