Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| OLD | NEW |