Title: [209778] trunk/Source/WTF
Revision
209778
Author
[email protected]
Date
2016-12-13 14:27:48 -0800 (Tue, 13 Dec 2016)

Log Message

std::expected: fix rvalue forwarding issues
https://bugs.webkit.org/show_bug.cgi?id=165812

Reviewed by Mark Lam.

* wtf/Expected.h:
(WTF::UnexpectedType::UnexpectedType):
(WTF::ExpectedDetail::Base::Base):
(WTF::Expected::Expected):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (209777 => 209778)


--- trunk/Source/WTF/ChangeLog	2016-12-13 22:15:13 UTC (rev 209777)
+++ trunk/Source/WTF/ChangeLog	2016-12-13 22:27:48 UTC (rev 209778)
@@ -1,3 +1,15 @@
+2016-12-13  JF Bastien  <[email protected]>
+
+        std::expected: fix rvalue forwarding issues
+        https://bugs.webkit.org/show_bug.cgi?id=165812
+
+        Reviewed by Mark Lam.
+
+        * wtf/Expected.h:
+        (WTF::UnexpectedType::UnexpectedType):
+        (WTF::ExpectedDetail::Base::Base):
+        (WTF::Expected::Expected):
+
 2016-12-13  Chris Dumez  <[email protected]>
 
         Unreviewed, rolling out r209544.

Modified: trunk/Source/WTF/wtf/Expected.h (209777 => 209778)


--- trunk/Source/WTF/wtf/Expected.h	2016-12-13 22:15:13 UTC (rev 209777)
+++ trunk/Source/WTF/wtf/Expected.h	2016-12-13 22:27:48 UTC (rev 209778)
@@ -45,7 +45,7 @@
 public:
     UnexpectedType() = delete;
     constexpr explicit UnexpectedType(const E& e) : val(e) { }
-    constexpr explicit UnexpectedType(E&& e) : val(WTFMove(e)) { }
+    constexpr explicit UnexpectedType(E&& e) : val(std::forward<E>(e)) { }
     constexpr const E& value() const { return val; }
     RELAXED_CONSTEXPR E& value() { return val; }
 
@@ -104,7 +104,9 @@
     constexpr Storage(ValueTagType) : val() { }
     constexpr Storage(ErrorTagType) : err() { }
     constexpr Storage(ValueTagType, const ValueType& val) : val(val) { }
+    constexpr Storage(ValueTagType, ValueType&& val) : val(std::forward<ValueType>(val)) { }
     constexpr Storage(ErrorTagType, const ErrorType& err) : err(err) { }
+    constexpr Storage(ErrorTagType, ErrorType&& err) : err(std::forward<ErrorType>(err)) { }
     ~Storage() { }
 };
 
@@ -131,6 +133,7 @@
     constexpr Storage(ValueTagType) : dummy() { }
     constexpr Storage(ErrorTagType) : err() { }
     constexpr Storage(ErrorTagType, const ErrorType& err) : err(err) { }
+    constexpr Storage(ErrorTagType, ErrorType&& err) : err(std::forward<ErrorType>(err)) { }
     ~Storage() { }
 };
 
@@ -158,7 +161,9 @@
     constexpr Base(ValueTagType tag) : s(tag), has(true) { }
     constexpr Base(ErrorTagType tag) : s(tag), has(false) { }
     constexpr Base(ValueTagType tag, const ValueType& val) : s(tag, val), has(true) { }
+    constexpr Base(ValueTagType tag, ValueType&& val) : s(tag, std::forward<ValueType>(val)), has(true) { }
     constexpr Base(ErrorTagType tag, const ErrorType& err) : s(tag, err), has(false) { }
+    constexpr Base(ErrorTagType tag, ErrorType&& err) : s(tag, std::forward<ErrorType>(err)), has(false) { }
     Base(const Base& o)
         : has(o.has)
     {
@@ -254,7 +259,7 @@
     Expected(const Expected&) = default;
     Expected(Expected&&) = default;
     constexpr Expected(const ValueType& e) : base(ExpectedDetail::ValueTag, e) { }
-    constexpr Expected(ValueType&& e) : base(ExpectedDetail::ValueTag, WTFMove(e)) { }
+    constexpr Expected(ValueType&& e) : base(ExpectedDetail::ValueTag, std::forward<ValueType>(e)) { }
     // template <class... Args> constexpr explicit Expected(in_place_t, Args&&...);
     // template <class U, class... Args> constexpr explicit Expected(in_place_t, std::initializer_list<U>, Args&&...);
     constexpr Expected(UnexpectedType<ErrorType> const& u) : base(ExpectedDetail::ErrorTag, u.value()) { }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to