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

Unified Diff: include/core/SkTemplates.h

Issue 1273813002: Add skstd::move and skstd::forward. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: No need to change the string. 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 | « no previous file | include/private/SkFunction.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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. */
« no previous file with comments | « no previous file | include/private/SkFunction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698