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

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: Don't need to change animator anymore. 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..ddf6681a11fd96cf55eca2c07f5c77f66b483149 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,22 @@
*/
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)));
-};
+namespace skstd {
+
+template <typename T> inline remove_reference_t<T>&& move(T&& t) {
+ return static_cast<remove_reference_t<T>&&>(t);
+}
+
+template <typename T> inline T&& forward(remove_reference_t<T>& t) /*noexcept*/ {
+ return static_cast<T&&>(t);
+}
+template <typename T> inline T&& forward(remove_reference_t<T>&& t) /*noexcept*/ {
+ static_assert(!is_lvalue_reference<T>::value,
+ "Forwarding an rvalue reference as an lvalue reference is not allowed.");
+ return static_cast<T&&>(t);
+}
+
+} // namespace skstd
///@{
/** 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