makeMoveWrapper(lvalue)
[folly.git] / folly / MoveWrapper.h
index 7300f9a8a7c6c34126e0197f4622af782cfde582..6fbd710e69ab55b75769c9af418c3a8d4458c3b6 100644 (file)
@@ -63,9 +63,12 @@ class MoveWrapper {
   mutable T value;
 };
 
-template <class T>
-MoveWrapper<T> makeMoveWrapper(T&& t) {
-    return MoveWrapper<T>(std::forward<T>(t));
+/// Make a MoveWrapper from the argument. Because the name "makeMoveWrapper"
+/// is already quite transparent in its intent, this will work for lvalues as
+/// if you had wrapped them in std::move.
+template <class T, class T0 = typename std::remove_reference<T>::type>
+MoveWrapper<T0> makeMoveWrapper(T&& t) {
+  return MoveWrapper<T0>(std::forward<T0>(t));
 }
 
 } // namespace