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

Unified Diff: src/utils/SkTLogic.h

Issue 18503009: Fix SkTFits in to work properly with signed/unsigned mixtures. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Remove enable_if, use SK_COMPILE_ASSERT instead. Created 7 years, 5 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
Index: src/utils/SkTLogic.h
===================================================================
--- src/utils/SkTLogic.h (revision 0)
+++ src/utils/SkTLogic.h (working copy)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkTLogic_DEFINED
+#define SkTLogic_DEFINED
+
mtklein 2013/07/11 14:56:57 Some sort of high-level what's-going-on-here would
bungeman-skia 2013/07/11 20:22:03 Sure, added comment that this is basically providi
+/** SkTBool::type = self; SkTBool::value = b; */
+template <bool b> struct SkTBool {
+ typedef SkTBool type;
+ static const bool value = b;
+};
+typedef SkTBool<true> SkTrue;
+typedef SkTBool<false> SkFalse;
+
+/** SkTIf_c::type = (condition) ? T : F; */
+template <bool condition, typename T, typename F> struct SkTIf_c {
+ typedef F type;
+};
+template <typename T, typename F> struct SkTIf_c<true, T, F> {
+ typedef T type;
+};
+
+/** SkTIf::type = (Condition::value) ? T : F; */
+template <typename Condition, typename T, typename F> struct SkTIf {
+ typedef typename SkTIf_c<static_cast<bool>(Condition::value), T, F>::type type;
+};
+
+/** SkTMux::type = (a && b) ? Both : (a) ? A : (b) ? B : Neither; */
+template <typename a, typename b, typename Both, typename A, typename B, typename Neither>
+struct SkTMux {
+ typedef typename SkTIf<a, typename SkTIf<b, Both, A>::type,
+ typename SkTIf<b, B, Neither>::type>::type type;
+};
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698