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

Unified 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, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/private/SkRecords.h ('k') | src/core/SkMiniRecorder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/private/SkTLogic.h
diff --git a/include/private/SkTLogic.h b/include/private/SkTLogic.h
index e7fc3dd40d8d0618323717ad662a35ea597442cd..c252001a00f1d4992281a5bd4dbcbf7a92c02bff 100644
--- a/include/private/SkTLogic.h
+++ b/include/private/SkTLogic.h
@@ -220,35 +220,7 @@ template <typename D, typename S> using same_cv_t = typename same_cv<D, S>::type
} // namespace sknonstd
-/** Use as a return type to enable a function only when cond_type::value is true,
- * like C++14's std::enable_if_t. E.g. (N.B. this is a dumb example.)
- * SK_WHEN(true_type, int) f(void* ptr) { return 1; }
- * SK_WHEN(!true_type, int) f(void* ptr) { return 2; }
- */
-#define SK_WHEN(cond_prefix, T) skstd::enable_if_t<cond_prefix::value, T>
-
-// See http://en.wikibooks.org/wiki/More_C++_Idioms/Member_Detector
-#define SK_CREATE_MEMBER_DETECTOR(member) \
-template <typename T> \
-class HasMember_##member { \
- struct Fallback { int member; }; \
- struct Derived : T, Fallback {}; \
- template <typename U, U> struct Check; \
- template <typename U> static uint8_t func(Check<int Fallback::*, &U::member>*); \
- template <typename U> static uint16_t func(...); \
-public: \
- typedef HasMember_##member type; \
- static const bool value = sizeof(func<Derived>(NULL)) == sizeof(uint16_t); \
-}
-
-// Same sort of thing as SK_CREATE_MEMBER_DETECTOR, but checks for the existence of a nested type.
-#define SK_CREATE_TYPE_DETECTOR(type) \
-template <typename T> \
-class HasType_##type { \
- template <typename U> static uint8_t func(typename U::type*); \
- template <typename U> static uint16_t func(...); \
-public: \
- static const bool value = sizeof(func<T>(NULL)) == sizeof(uint8_t); \
-}
+// Just a pithier wrapper for enable_if_t.
+#define SK_WHEN(condition, T) skstd::enable_if_t<!!(condition), T>
#endif
« 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