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

Unified Diff: include/private/SkTLogic.h

Issue 1309523003: Remove SK_OFFSETOF from SkTypes, clean up offsetof usage. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Speling Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkTypes.h ('k') | include/private/SkTemplates.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/private/SkTLogic.h
diff --git a/include/private/SkTLogic.h b/include/private/SkTLogic.h
index 2710d6d1cf77f71c123c997d077cb6bacce0d4a9..f93f63b1a2eb16fd6ad713843cdbf4946dff8fc9 100644
--- a/include/private/SkTLogic.h
+++ b/include/private/SkTLogic.h
@@ -112,16 +112,39 @@ public: \
namespace skstd {
-/** SkTRemoveReference<T>::type is the type of T with any top-level lvalue or rvalue removed. */
-template <typename T> struct remove_reference { typedef T type; };
-template <typename T> struct remove_reference<T&> { typedef T type; };
-template <typename T> struct remove_reference<T&&> { typedef T type; };
+template <typename T> struct remove_const { using type = T; };
+template <typename T> struct remove_const<const T> { using type = T; };
+template <typename T> using remove_const_t = typename remove_const<T>::type;
+
+template <typename T> struct remove_volatile { using type = T; };
+template <typename T> struct remove_volatile<volatile T> { using type = T; };
+template <typename T> using remove_volatile_t = typename remove_volatile<T>::type;
+
+template <typename T> struct remove_cv { using type = remove_volatile_t<remove_const_t<T>>; };
+template <typename T> using remove_cv_t = typename remove_cv<T>::type;
+
+template <typename T> struct remove_reference { using type = T; };
+template <typename T> struct remove_reference<T&> { using type = T; };
+template <typename T> struct remove_reference<T&&> { using type = T; };
template <typename T> using remove_reference_t = typename remove_reference<T>::type;
-/** SkTIsLValueReference<T>::value is true if the type T is an lvalue reference. */
+template <typename T, typename U> struct is_same : SkFalse {};
+template <typename T> struct is_same<T, T> : SkTrue {};
+
+template <typename T> struct is_void : is_same<void, remove_cv_t<T>> {};
+
+template <typename T> struct is_reference : SkFalse {};
+template <typename T> struct is_reference<T&> : SkTrue {};
+template <typename T> struct is_reference<T&&> : SkTrue {};
+
template <typename T> struct is_lvalue_reference : SkFalse {};
template <typename T> struct is_lvalue_reference<T&> : SkTrue {};
+template <typename T> struct add_rvalue_reference {
+ using type = typename SkTIf_c<is_void<T>::value || is_reference<T>::value, T, T&&>::type;
+};
+template <typename T> using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;
+
} // namespace skstd
/**
« no previous file with comments | « include/core/SkTypes.h ('k') | include/private/SkTemplates.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698