Chromium Code Reviews| 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 (like std::enable_if_t) which will | 8 * This header provides some of the helpers (like std::enable_if_t) which will |
| 9 * become available with C++14 in the type_traits header (in the skstd | 9 * become available with C++14 in the type_traits header (in the skstd |
| 10 * namespace). This header also provides several Skia specific additions such | 10 * namespace). This header also provides several Skia specific additions such |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 // On all platforms, variadic functions only exist in the c calling convention. | 42 // On all platforms, variadic functions only exist in the c calling convention. |
| 43 // mcvc 2013 introduced __vectorcall, but it wan't until 2015 that it was added to is_function. | 43 // mcvc 2013 introduced __vectorcall, but it wan't until 2015 that it was added to is_function. |
| 44 template <typename> struct is_function : std::false_type {}; | 44 template <typename> struct is_function : std::false_type {}; |
| 45 #if !defined(SK_BUILD_FOR_WIN) | 45 #if !defined(SK_BUILD_FOR_WIN) |
| 46 template <typename R, typename... Args> struct is_function<R(Args...)> : std::tr ue_type {}; | 46 template <typename R, typename... Args> struct is_function<R(Args...)> : std::tr ue_type {}; |
| 47 #else | 47 #else |
| 48 #if defined(_M_IX86) | 48 #if defined(_M_IX86) |
| 49 template <typename R, typename... Args> struct is_function<R __cdecl (Args...)> : std::true_type {}; | 49 template <typename R, typename... Args> struct is_function<R __cdecl (Args...)> : std::true_type {}; |
| 50 template <typename R, typename... Args> struct is_function<R __stdcall (Args...) > : std::true_type {}; | 50 template <typename R, typename... Args> struct is_function<R __stdcall (Args...) > : std::true_type {}; |
| 51 template <typename R, typename... Args> struct is_function<R __fastcall (Args... )> : std::true_type {}; | 51 template <typename R, typename... Args> struct is_function<R __fastcall (Args... )> : std::true_type {}; |
| 52 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 | 52 #if defined(_MSC_VER) && SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 |
| 53 template <typename R, typename... Args> struct is_function<R __vectorcall (Args. ..)> : std::true_type {}; | 53 template <typename R, typename... Args> struct is_function<R __vectorcall (Args. ..)> : std::true_type {}; |
| 54 #endif | 54 #endif |
| 55 #else | 55 #else |
| 56 template <typename R, typename... Args> struct is_function<R __cdecl (Args...)> : std::true_type {}; | 56 template <typename R, typename... Args> struct is_function<R __cdecl (Args...)> : std::true_type {}; |
| 57 #if defined(_MSC_VER) | |
| 57 template <typename R, typename... Args> struct is_function<R __vectorcall (Args. ..)> : std::true_type {}; | 58 template <typename R, typename... Args> struct is_function<R __vectorcall (Args. ..)> : std::true_type {}; |
| 58 #endif | 59 #endif |
| 59 #endif | 60 #endif |
| 61 #endif | |
|
bungeman-skia
2016/01/14 18:04:58
I would really like to avoid another nesting ifdef
| |
| 60 template <typename R, typename... Args> struct is_function<R(Args..., ...)> : st d::true_type {}; | 62 template <typename R, typename... Args> struct is_function<R(Args..., ...)> : st d::true_type {}; |
| 61 | 63 |
| 62 template <typename T> using add_const_t = typename std::add_const<T>::type; | 64 template <typename T> using add_const_t = typename std::add_const<T>::type; |
| 63 template <typename T> using add_volatile_t = typename std::add_volatile<T>::type ; | 65 template <typename T> using add_volatile_t = typename std::add_volatile<T>::type ; |
| 64 template <typename T> using add_cv_t = typename std::add_cv<T>::type; | 66 template <typename T> using add_cv_t = typename std::add_cv<T>::type; |
| 65 template <typename T> using add_pointer_t = typename std::add_pointer<T>::type; | 67 template <typename T> using add_pointer_t = typename std::add_pointer<T>::type; |
| 66 template <typename T> using add_lvalue_reference_t = typename std::add_lvalue_re ference<T>::type; | 68 template <typename T> using add_lvalue_reference_t = typename std::add_lvalue_re ference<T>::type; |
| 67 | 69 |
| 68 template <typename S, typename D, | 70 template <typename S, typename D, |
| 69 bool=std::is_void<S>::value || is_function<D>::value || std::is_array< D>::value> | 71 bool=std::is_void<S>::value || is_function<D>::value || std::is_array< D>::value> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 template <typename D, typename S> using same_volatile_t = typename same_volatile <D, S>::type; | 123 template <typename D, typename S> using same_volatile_t = typename same_volatile <D, S>::type; |
| 122 template <typename D, typename S> using same_cv = copy_cv<skstd::remove_cv_t<D>, S>; | 124 template <typename D, typename S> using same_cv = copy_cv<skstd::remove_cv_t<D>, S>; |
| 123 template <typename D, typename S> using same_cv_t = typename same_cv<D, S>::type ; | 125 template <typename D, typename S> using same_cv_t = typename same_cv<D, S>::type ; |
| 124 | 126 |
| 125 } // namespace sknonstd | 127 } // namespace sknonstd |
| 126 | 128 |
| 127 // Just a pithier wrapper for enable_if_t. | 129 // Just a pithier wrapper for enable_if_t. |
| 128 #define SK_WHEN(condition, T) skstd::enable_if_t<!!(condition), T> | 130 #define SK_WHEN(condition, T) skstd::enable_if_t<!!(condition), T> |
| 129 | 131 |
| 130 #endif | 132 #endif |
| OLD | NEW |