Index: include/core/SkTemplates.h |
diff --git a/include/core/SkTemplates.h b/include/core/SkTemplates.h |
index 2ddc5be22525b893a3818059eb450cbb96bfd692..dbb7b6732173b102c3abad0dfacfb75d70e9cc24 100644 |
--- a/include/core/SkTemplates.h |
+++ b/include/core/SkTemplates.h |
@@ -10,6 +10,7 @@ |
#ifndef SkTemplates_DEFINED |
#define SkTemplates_DEFINED |
+#include "../private/SkTLogic.h" |
#include "SkMath.h" |
#include "SkTypes.h" |
#include <limits.h> |
@@ -27,16 +28,18 @@ |
*/ |
template<typename T> inline void sk_ignore_unused_variable(const T&) { } |
-/** |
- * SkTIsConst<T>::value is true if the type T is const. |
- * The type T is constrained not to be an array or reference type. |
- */ |
-template <typename T> struct SkTIsConst { |
- static T* t; |
- static uint16_t test(const volatile void*); |
- static uint32_t test(volatile void *); |
- static const bool value = (sizeof(uint16_t) == sizeof(test(t))); |
-}; |
+template <typename T> inline typename SkTRemoveReference<T>::type&& SkMove(T&& t) { |
mtklein
2015/08/05 17:48:00
I'd personally be satisfied with
// SkMove == std
|
+ return static_cast<typename SkTRemoveReference<T>::type&&>(t); |
+} |
+ |
+template <typename T> inline T&& SkTForward(typename SkTRemoveReference<T>::type& t) /*noexcept*/ { |
+ return static_cast<T&&>(t); |
+} |
+template <typename T> inline T&& SkTForward(typename SkTRemoveReference<T>::type&& t) /*noexcept*/ { |
+ static_assert(!SkTIsLValueReference<T>::value, |
+ "Forwarding an rvalue reference as an lvalue reference is not allowed."); |
+ return static_cast<T&&>(t); |
+} |
///@{ |
/** SkTConstType<T, CONST>::type will be 'const T' if CONST is true, 'T' otherwise. */ |