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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkTLogic_DEFINED
9 #define SkTLogic_DEFINED
10
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
11 /** SkTBool::type = self; SkTBool::value = b; */
12 template <bool b> struct SkTBool {
13 typedef SkTBool type;
14 static const bool value = b;
15 };
16 typedef SkTBool<true> SkTrue;
17 typedef SkTBool<false> SkFalse;
18
19 /** SkTIf_c::type = (condition) ? T : F; */
20 template <bool condition, typename T, typename F> struct SkTIf_c {
21 typedef F type;
22 };
23 template <typename T, typename F> struct SkTIf_c<true, T, F> {
24 typedef T type;
25 };
26
27 /** SkTIf::type = (Condition::value) ? T : F; */
28 template <typename Condition, typename T, typename F> struct SkTIf {
29 typedef typename SkTIf_c<static_cast<bool>(Condition::value), T, F>::type ty pe;
30 };
31
32 /** SkTMux::type = (a && b) ? Both : (a) ? A : (b) ? B : Neither; */
33 template <typename a, typename b, typename Both, typename A, typename B, typenam e Neither>
34 struct SkTMux {
35 typedef typename SkTIf<a, typename SkTIf<b, Both, A>::type,
36 typename SkTIf<b, B, Neither>::type>::type type;
37 };
38
39 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698