Title: [274241] trunk/Source/WTF
- Revision
- 274241
- Author
- d...@apple.com
- Date
- 2021-03-10 14:07:50 -0800 (Wed, 10 Mar 2021)
Log Message
Use std::forward for forwarding references instead of WTFMove
https://bugs.webkit.org/show_bug.cgi?id=223040
Reviewed by Darin Adler.
A newer version of clang produced a helpful warning that told
us we were using WTFMove in places where we should use std::forward.
* wtf/Expected.h:
(std::experimental::fundamentals_v3::expected::operator=):
* wtf/Function.h:
(WTF::Function<Out):
* wtf/NeverDestroyed.h:
(WTF::makeNeverDestroyed):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (274240 => 274241)
--- trunk/Source/WTF/ChangeLog 2021-03-10 22:03:14 UTC (rev 274240)
+++ trunk/Source/WTF/ChangeLog 2021-03-10 22:07:50 UTC (rev 274241)
@@ -1,3 +1,20 @@
+2021-03-10 Dean Jackson <d...@apple.com>
+
+ Use std::forward for forwarding references instead of WTFMove
+ https://bugs.webkit.org/show_bug.cgi?id=223040
+
+ Reviewed by Darin Adler.
+
+ A newer version of clang produced a helpful warning that told
+ us we were using WTFMove in places where we should use std::forward.
+
+ * wtf/Expected.h:
+ (std::experimental::fundamentals_v3::expected::operator=):
+ * wtf/Function.h:
+ (WTF::Function<Out):
+ * wtf/NeverDestroyed.h:
+ (WTF::makeNeverDestroyed):
+
2021-03-09 Darin Adler <da...@apple.com>
[Cocoa] Make WebKit API Objective-C objects safe to release on non-main threads
Modified: trunk/Source/WTF/wtf/Expected.h (274240 => 274241)
--- trunk/Source/WTF/wtf/Expected.h 2021-03-10 22:03:14 UTC (rev 274240)
+++ trunk/Source/WTF/wtf/Expected.h 2021-03-10 22:07:50 UTC (rev 274241)
@@ -452,7 +452,7 @@
expected& operator=(const expected& e) { type(e).swap(*this); return *this; }
expected& operator=(expected&& e) { type(std::move(e)).swap(*this); return *this; }
- template<class U> expected& operator=(U&& u) { type(std::move(u)).swap(*this); return *this; }
+ template<class U> expected& operator=(U&& u) { type(std::forward<U>(u)).swap(*this); return *this; }
expected& operator=(const unexpected_type& u) { type(u).swap(*this); return *this; }
expected& operator=(unexpected_type&& u) { type(std::move(u)).swap(*this); return *this; }
// template<class... Args> void emplace(Args&&...);
Modified: trunk/Source/WTF/wtf/Function.h (274240 => 274241)
--- trunk/Source/WTF/wtf/Function.h 2021-03-10 22:03:14 UTC (rev 274240)
+++ trunk/Source/WTF/wtf/Function.h 2021-03-10 22:07:50 UTC (rev 274241)
@@ -71,11 +71,11 @@
template<typename CallableType, class = typename std::enable_if<!(std::is_pointer<CallableType>::value && std::is_function<typename std::remove_pointer<CallableType>::type>::value) && std::is_rvalue_reference<CallableType&&>::value>::type>
Function(CallableType&& callable)
- : m_callableWrapper(makeUnique<Detail::CallableWrapper<CallableType, Out, In...>>(WTFMove(callable))) { }
+ : m_callableWrapper(makeUnique<Detail::CallableWrapper<CallableType, Out, In...>>(std::forward<CallableType>(callable))) { }
template<typename FunctionType, class = typename std::enable_if<std::is_pointer<FunctionType>::value && std::is_function<typename std::remove_pointer<FunctionType>::type>::value>::type>
Function(FunctionType f)
- : m_callableWrapper(makeUnique<Detail::CallableWrapper<FunctionType, Out, In...>>(WTFMove(f))) { }
+ : m_callableWrapper(makeUnique<Detail::CallableWrapper<FunctionType, Out, In...>>(std::forward<FunctionType>(f))) { }
Out operator()(In... in) const
{
@@ -88,7 +88,7 @@
template<typename CallableType, class = typename std::enable_if<!(std::is_pointer<CallableType>::value && std::is_function<typename std::remove_pointer<CallableType>::type>::value) && std::is_rvalue_reference<CallableType&&>::value>::type>
Function& operator=(CallableType&& callable)
{
- m_callableWrapper = makeUnique<Detail::CallableWrapper<CallableType, Out, In...>>(WTFMove(callable));
+ m_callableWrapper = makeUnique<Detail::CallableWrapper<CallableType, Out, In...>>(std::forward<CallableType>(callable));
return *this;
}
@@ -95,7 +95,7 @@
template<typename FunctionType, class = typename std::enable_if<std::is_pointer<FunctionType>::value && std::is_function<typename std::remove_pointer<FunctionType>::type>::value>::type>
Function& operator=(FunctionType f)
{
- m_callableWrapper = makeUnique<Detail::CallableWrapper<FunctionType, Out, In...>>(WTFMove(f));
+ m_callableWrapper = makeUnique<Detail::CallableWrapper<FunctionType, Out, In...>>(std::forward<FunctionType>(f));
return *this;
}
Modified: trunk/Source/WTF/wtf/NeverDestroyed.h (274240 => 274241)
--- trunk/Source/WTF/wtf/NeverDestroyed.h 2021-03-10 22:03:14 UTC (rev 274240)
+++ trunk/Source/WTF/wtf/NeverDestroyed.h 2021-03-10 22:07:50 UTC (rev 274241)
@@ -181,7 +181,7 @@
template<typename T, typename AccessTraits> inline NeverDestroyed<T, AccessTraits> makeNeverDestroyed(T&& argument)
{
- return WTFMove(argument);
+ return std::forward<T>(argument);
}
template<typename T>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes