| OLD | NEW |
| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 template <typename T> \ | 105 template <typename T> \ |
| 106 class HasType_##type { \ | 106 class HasType_##type { \ |
| 107 template <typename U> static uint8_t func(typename U::type*); \ | 107 template <typename U> static uint8_t func(typename U::type*); \ |
| 108 template <typename U> static uint16_t func(...); \ | 108 template <typename U> static uint16_t func(...); \ |
| 109 public: \ | 109 public: \ |
| 110 static const bool value = sizeof(func<T>(NULL)) == sizeof(uint8_t); \ | 110 static const bool value = sizeof(func<T>(NULL)) == sizeof(uint8_t); \ |
| 111 } | 111 } |
| 112 | 112 |
| 113 namespace skstd { | 113 namespace skstd { |
| 114 | 114 |
| 115 /** SkTRemoveReference<T>::type is the type of T with any top-level lvalue or rv
alue removed. */ | 115 template <typename T> struct remove_const { using type = T; }; |
| 116 template <typename T> struct remove_reference { typedef T type; }; | 116 template <typename T> struct remove_const<const T> { using type = T; }; |
| 117 template <typename T> struct remove_reference<T&> { typedef T type; }; | 117 template <typename T> using remove_const_t = typename remove_const<T>::type; |
| 118 template <typename T> struct remove_reference<T&&> { typedef T type; }; | 118 |
| 119 template <typename T> struct remove_volatile { using type = T; }; |
| 120 template <typename T> struct remove_volatile<volatile T> { using type = T; }; |
| 121 template <typename T> using remove_volatile_t = typename remove_volatile<T>::typ
e; |
| 122 |
| 123 template <typename T> struct remove_cv { using type = remove_volatile_t<remove_c
onst_t<T>>; }; |
| 124 template <typename T> using remove_cv_t = typename remove_cv<T>::type; |
| 125 |
| 126 template <typename T> struct remove_reference { using type = T; }; |
| 127 template <typename T> struct remove_reference<T&> { using type = T; }; |
| 128 template <typename T> struct remove_reference<T&&> { using type = T; }; |
| 119 template <typename T> using remove_reference_t = typename remove_reference<T>::t
ype; | 129 template <typename T> using remove_reference_t = typename remove_reference<T>::t
ype; |
| 120 | 130 |
| 121 /** SkTIsLValueReference<T>::value is true if the type T is an lvalue reference.
*/ | 131 template <typename T, typename U> struct is_same : SkFalse {}; |
| 132 template <typename T> struct is_same<T, T> : SkTrue {}; |
| 133 |
| 134 template <typename T> struct is_void : is_same<void, remove_cv_t<T>> {}; |
| 135 |
| 136 template <typename T> struct is_reference : SkFalse {}; |
| 137 template <typename T> struct is_reference<T&> : SkTrue {}; |
| 138 template <typename T> struct is_reference<T&&> : SkTrue {}; |
| 139 |
| 122 template <typename T> struct is_lvalue_reference : SkFalse {}; | 140 template <typename T> struct is_lvalue_reference : SkFalse {}; |
| 123 template <typename T> struct is_lvalue_reference<T&> : SkTrue {}; | 141 template <typename T> struct is_lvalue_reference<T&> : SkTrue {}; |
| 124 | 142 |
| 143 template <typename T> struct add_rvalue_reference { |
| 144 using type = typename SkTIf_c<is_void<T>::value || is_reference<T>::value, T
, T&&>::type; |
| 145 }; |
| 146 template <typename T> using add_rvalue_reference_t = typename add_rvalue_referen
ce<T>::type; |
| 147 |
| 125 } // namespace skstd | 148 } // namespace skstd |
| 126 | 149 |
| 127 /** | 150 /** |
| 128 * SkTIsConst<T>::value is true if the type T is const. | 151 * SkTIsConst<T>::value is true if the type T is const. |
| 129 * The type T is constrained not to be an array or reference type. | 152 * The type T is constrained not to be an array or reference type. |
| 130 */ | 153 */ |
| 131 template <typename T> struct SkTIsConst { | 154 template <typename T> struct SkTIsConst { |
| 132 static T* t; | 155 static T* t; |
| 133 static uint16_t test(const volatile void*); | 156 static uint16_t test(const volatile void*); |
| 134 static uint32_t test(volatile void *); | 157 static uint32_t test(volatile void *); |
| 135 static const bool value = (sizeof(uint16_t) == sizeof(test(t))); | 158 static const bool value = (sizeof(uint16_t) == sizeof(test(t))); |
| 136 }; | 159 }; |
| 137 | 160 |
| 138 #endif | 161 #endif |
| OLD | NEW |