c++: Add new std::move test [PR67906]
As discussed in 67906, let's make sure we don't warn about a std::move when initializing when there's a T(const T&&) ctor. PR c++/67906 gcc/testsuite/ChangeLog: * g++.dg/cpp0x/Wredundant-move11.C: New test.
This commit is contained in:
parent
5adfb6540d
commit
177e93e952
1 changed files with 32 additions and 0 deletions
32
gcc/testsuite/g++.dg/cpp0x/Wredundant-move11.C
Normal file
32
gcc/testsuite/g++.dg/cpp0x/Wredundant-move11.C
Normal file
|
@ -0,0 +1,32 @@
|
|||
// PR c++/67906
|
||||
// { dg-do compile { target c++11 } }
|
||||
// { dg-options "-Wall -Wextra" }
|
||||
|
||||
// Define std::move.
|
||||
namespace std {
|
||||
template<typename _Tp>
|
||||
struct remove_reference
|
||||
{ typedef _Tp type; };
|
||||
|
||||
template<typename _Tp>
|
||||
struct remove_reference<_Tp&>
|
||||
{ typedef _Tp type; };
|
||||
|
||||
template<typename _Tp>
|
||||
struct remove_reference<_Tp&&>
|
||||
{ typedef _Tp type; };
|
||||
|
||||
template<typename _Tp>
|
||||
constexpr typename std::remove_reference<_Tp>::type&&
|
||||
move(_Tp&& __t) noexcept
|
||||
{ return static_cast<typename std::remove_reference<_Tp>::type&&>(__t); }
|
||||
}
|
||||
|
||||
struct X {
|
||||
X() { }
|
||||
X(const X&) { }
|
||||
X(const X&&) { }
|
||||
};
|
||||
|
||||
const X x;
|
||||
const X y = std::move(x);
|
Loading…
Add table
Reference in a new issue