| Index: src/utils/SkTLogic.h
|
| ===================================================================
|
| --- src/utils/SkTLogic.h (revision 0)
|
| +++ src/utils/SkTLogic.h (working copy)
|
| @@ -0,0 +1,49 @@
|
| +/*
|
| + * 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
|
| +
|
| +/** 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;
|
| +};
|
| +
|
| +/** SkTEnableIf_c::type = (condition) ? T : [does not exist]; */
|
| +template <bool condition, class T = void> struct SkTEnableIf_c { };
|
| +template <class T> struct SkTEnableIf_c<true, T> {
|
| + typedef T type;
|
| +};
|
| +
|
| +/** SkTEnableIf::type = (Condition::value) ? T : [does not exist]; */
|
| +template <class Condition, class T = void> struct SkTEnableIf
|
| + : public SkTEnableIf_c<static_cast<bool>(Condition::value), T> { };
|
| +
|
| +#endif
|
|
|