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
EXPECT_EQ(**p, 5);
}
+TEST(makeMoveWrapper, rvalue) {
+ std::unique_ptr<int> p;
+ makeMoveWrapper(std::move(p));
+}
+
+TEST(makeMoveWrapper, lvalue) {
+ std::unique_ptr<int> p;
+ makeMoveWrapper(p);
+}
+
+TEST(makeMoveWrapper, lvalue_copyable) {
+ std::shared_ptr<int> p;
+ makeMoveWrapper(p);
+}
+
} // namespace