Cleanup move/forward tests and remove references to __rv.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@238270 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8f1d85fde5
commit
ee6bfb2117
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
// test move
|
// test move
|
||||||
|
|
||||||
|
// UNSUPPORTED: c++98, c++03
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
@ -17,25 +19,13 @@ int move_ctor = 0;
|
|||||||
|
|
||||||
class A
|
class A
|
||||||
{
|
{
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
A(const A&) {++copy_ctor;}
|
A(const A&) {++copy_ctor;}
|
||||||
A& operator=(const A&);
|
A& operator=(const A&);
|
||||||
|
|
||||||
A(A&&) {++move_ctor;}
|
A(A&&) {++move_ctor;}
|
||||||
A& operator=(A&&);
|
A& operator=(A&&);
|
||||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
A(const A&) {++copy_ctor;}
|
|
||||||
A& operator=(A&);
|
|
||||||
|
|
||||||
operator std::__rv<A> () {return std::__rv<A>(*this);}
|
|
||||||
A(std::__rv<A>) {++move_ctor;}
|
|
||||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
|
|
||||||
A() {}
|
A() {}
|
||||||
};
|
};
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
|
|
||||||
class A
|
class A
|
||||||
{
|
{
|
||||||
A(const A&);
|
A(const A&);
|
||||||
@ -27,7 +29,7 @@ class A
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
A() {}
|
A() {}
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#if TEST_STD_VER >= 11
|
||||||
A(A&&) {}
|
A(A&&) {}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@ -47,20 +49,23 @@ int main()
|
|||||||
A a;
|
A a;
|
||||||
const A ca;
|
const A ca;
|
||||||
|
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#if TEST_STD_VER >= 11
|
||||||
static_assert((std::is_same<decltype(std::move_if_noexcept(i)), int&&>::value), "");
|
static_assert((std::is_same<decltype(std::move_if_noexcept(i)), int&&>::value), "");
|
||||||
static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int&&>::value), "");
|
static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int&&>::value), "");
|
||||||
static_assert((std::is_same<decltype(std::move_if_noexcept(a)), A&&>::value), "");
|
static_assert((std::is_same<decltype(std::move_if_noexcept(a)), A&&>::value), "");
|
||||||
static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A&&>::value), "");
|
static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A&&>::value), "");
|
||||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::value), "");
|
||||||
|
#else // C++ < 11
|
||||||
|
// libc++ defines decltype to be __typeof__ in C++03. __typeof__ does not
|
||||||
|
// deduce the reference qualifiers.
|
||||||
static_assert((std::is_same<decltype(std::move_if_noexcept(i)), const int>::value), "");
|
static_assert((std::is_same<decltype(std::move_if_noexcept(i)), const int>::value), "");
|
||||||
static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int>::value), "");
|
static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int>::value), "");
|
||||||
static_assert((std::is_same<decltype(std::move_if_noexcept(a)), const A>::value), "");
|
static_assert((std::is_same<decltype(std::move_if_noexcept(a)), const A>::value), "");
|
||||||
static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A>::value), "");
|
static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A>::value), "");
|
||||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy>::value), "");
|
||||||
static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::value), "");
|
#endif
|
||||||
|
|
||||||
#if _LIBCPP_STD_VER > 11
|
#if TEST_STD_VER > 11
|
||||||
constexpr int i1 = 23;
|
constexpr int i1 = 23;
|
||||||
constexpr int i2 = std::move_if_noexcept(i1);
|
constexpr int i2 = std::move_if_noexcept(i1);
|
||||||
static_assert(i2 == 23, "" );
|
static_assert(i2 == 23, "" );
|
||||||
|
@ -9,28 +9,18 @@
|
|||||||
|
|
||||||
// test move
|
// test move
|
||||||
|
|
||||||
|
// UNSUPPORTED: c++98, c++03
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
class move_only
|
class move_only
|
||||||
{
|
{
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
move_only(const move_only&);
|
move_only(const move_only&);
|
||||||
move_only& operator=(const move_only&);
|
move_only& operator=(const move_only&);
|
||||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
move_only(move_only&);
|
|
||||||
move_only& operator=(move_only&);
|
|
||||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
move_only(move_only&&) {}
|
move_only(move_only&&) {}
|
||||||
move_only& operator=(move_only&&) {return *this;}
|
move_only& operator=(move_only&&) {return *this;}
|
||||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
|
|
||||||
move_only(std::__rv<move_only>) {}
|
|
||||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
|
|
||||||
move_only() {}
|
move_only() {}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user