2 // { dg-do compile { target c++11 } }
3 // { dg-options "-Wredundant-move" }
8 struct remove_reference
11 template<typename _Tp>
12 struct remove_reference<_Tp&>
13 { typedef _Tp type; };
15 template<typename _Tp>
16 struct remove_reference<_Tp&&>
17 { typedef _Tp type; };
19 template<typename _Tp>
20 constexpr typename std::remove_reference<_Tp>::type&&
21 move(_Tp&& __t) noexcept
22 { return static_cast<typename std::remove_reference<_Tp>::type&&>(__t); }
47 // Will use move even without std::move.
48 return std::move (t); // { dg-warning "redundant move in return statement" }
54 // t is const: will decay into copy.
61 // t is const: will decay into copy despite std::move, so it's redundant.
62 // We used to warn about this, but no longer since c++/87378.
63 // Now we warn again since c++/90428.
64 return std::move (t); // { dg-warning "redundant move" }
79 return std::move (t); // { dg-warning "redundant move in return statement" }
85 // Core 1579 means we'll get a move here.
92 // Core 1579 means we'll get a move here. Even without std::move.
93 return std::move (t); // { dg-warning "redundant move in return statement" }
99 // T is a reference and the move isn't redundant.
100 return std::move (t);
106 // T is a reference and the move isn't redundant.
107 return std::move (t);