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

Side by Side Diff: src/utils/SkTLogic.h

Issue 269543025: Partially restore small-T optimization for very small (empty) T. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: singletons Created 6 years, 7 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
« no previous file with comments | « src/record/SkRecord.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 * 6 *
7 * 7 *
8 * This header provides some of the helpers (std::integral_constant) and 8 * This header provides some of the helpers (std::integral_constant) and
9 * type transformations (std::conditional) which will become available with 9 * type transformations (std::conditional) which will become available with
10 * C++11 in the type_traits header. 10 * C++11 in the type_traits header.
(...skipping 12 matching lines...) Expand all
23 */ 23 */
24 template <typename T, T v> struct SkTIntegralConstant { 24 template <typename T, T v> struct SkTIntegralConstant {
25 static const T value = v; 25 static const T value = v;
26 typedef T value_type; 26 typedef T value_type;
27 typedef SkTIntegralConstant<T, v> type; 27 typedef SkTIntegralConstant<T, v> type;
28 }; 28 };
29 29
30 /** Convenience specialization of SkTIntegralConstant. */ 30 /** Convenience specialization of SkTIntegralConstant. */
31 template <bool b> struct SkTBool : SkTIntegralConstant<bool, b> { }; 31 template <bool b> struct SkTBool : SkTIntegralConstant<bool, b> { };
32 32
33 /** Pre-C++11 version of std::is_empty<T>. */
34 template <typename T>
35 class SkTIsEmpty {
36 struct Derived : public T { char unused; };
37 public:
38 static const bool value = sizeof(Derived) == sizeof(char);
39 };
40
33 /** Pre-C++11 version of std::true_type. */ 41 /** Pre-C++11 version of std::true_type. */
34 typedef SkTBool<true> SkTrue; 42 typedef SkTBool<true> SkTrue;
35 43
36 /** Pre-C++11 version of std::false_type. */ 44 /** Pre-C++11 version of std::false_type. */
37 typedef SkTBool<false> SkFalse; 45 typedef SkTBool<false> SkFalse;
38 46
39 /** SkTIf_c::type = (condition) ? T : F; 47 /** SkTIf_c::type = (condition) ? T : F;
40 * Pre-C++11 version of std::conditional. 48 * Pre-C++11 version of std::conditional.
41 */ 49 */
42 template <bool condition, typename T, typename F> struct SkTIf_c { 50 template <bool condition, typename T, typename F> struct SkTIf_c {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 #define SK_CREATE_TYPE_DETECTOR(type) \ 101 #define SK_CREATE_TYPE_DETECTOR(type) \
94 template <typename T> \ 102 template <typename T> \
95 class HasType_##type { \ 103 class HasType_##type { \
96 template <typename U> static uint8_t func(typename U::type*); \ 104 template <typename U> static uint8_t func(typename U::type*); \
97 template <typename U> static uint16_t func(...); \ 105 template <typename U> static uint16_t func(...); \
98 public: \ 106 public: \
99 static const bool value = sizeof(func<T>(NULL)) == sizeof(uint8_t); \ 107 static const bool value = sizeof(func<T>(NULL)) == sizeof(uint8_t); \
100 } 108 }
101 109
102 #endif 110 #endif
OLDNEW
« no previous file with comments | « src/record/SkRecord.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698