summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libcxx/include/type_traits8
-rw-r--r--libcxx/test/std/utilities/utility/forward/forward.fail.cpp53
-rw-r--r--libcxx/test/std/utilities/utility/forward/forward.pass.cpp114
-rw-r--r--libcxx/test/std/utilities/utility/forward/forward1.fail.cpp24
-rw-r--r--libcxx/test/std/utilities/utility/forward/forward2.fail.cpp25
-rw-r--r--libcxx/test/std/utilities/utility/forward/forward3.fail.cpp24
-rw-r--r--libcxx/test/std/utilities/utility/forward/forward4.fail.cpp25
-rw-r--r--libcxx/test/std/utilities/utility/forward/forward5.fail.cpp25
-rw-r--r--libcxx/test/std/utilities/utility/forward/forward6.fail.cpp22
-rw-r--r--libcxx/test/std/utilities/utility/forward/forward_03.pass.cpp58
-rw-r--r--libcxx/test/std/utilities/utility/forward/move.fail.cpp (renamed from libcxx/test/std/utilities/utility/forward/move_only.pass.cpp)21
-rw-r--r--libcxx/test/std/utilities/utility/forward/move.pass.cpp121
-rw-r--r--libcxx/test/std/utilities/utility/forward/move_copy.pass.cpp61
-rw-r--r--libcxx/test/std/utilities/utility/forward/move_only1.fail.cpp52
-rw-r--r--libcxx/test/std/utilities/utility/forward/move_only2.fail.cpp52
-rw-r--r--libcxx/test/std/utilities/utility/forward/move_only3.fail.cpp49
-rw-r--r--libcxx/test/std/utilities/utility/forward/move_only4.fail.cpp52
17 files changed, 305 insertions, 481 deletions
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index c777f451ec7..26165713a24 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -2155,7 +2155,7 @@ template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
typename remove_reference<_Tp>::type&&
move(_Tp&& __t) _NOEXCEPT
{
@@ -2164,7 +2164,7 @@ move(_Tp&& __t) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
_Tp&&
forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
{
@@ -2172,12 +2172,12 @@ forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
_Tp&&
forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
{
static_assert(!is_lvalue_reference<_Tp>::value,
- "Can not forward an rvalue as an lvalue.");
+ "can not forward an rvalue as an lvalue");
return static_cast<_Tp&&>(__t);
}
diff --git a/libcxx/test/std/utilities/utility/forward/forward.fail.cpp b/libcxx/test/std/utilities/utility/forward/forward.fail.cpp
new file mode 100644
index 00000000000..a3bb890482e
--- /dev/null
+++ b/libcxx/test/std/utilities/utility/forward/forward.fail.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+#include "test_macros.h"
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+#if TEST_STD_VER >= 11
+ {
+ std::forward<A&>(source()); // expected-note {{requested here}}
+ // expected-error@type_traits:* 1 {{static_assert failed "can not forward an rvalue as an lvalue"}}
+ }
+#else
+ {
+ std::forward<A&>(source()); // expected-error {{no matching function for call to 'forward'}}
+ }
+#endif
+ {
+ const A ca = A();
+ std::forward<A&>(ca); // expected-error {{no matching function for call to 'forward'}}
+ }
+ {
+ std::forward<A&>(csource()); // expected-error {{no matching function for call to 'forward'}}
+ }
+ {
+ const A ca = A();
+ std::forward<A>(ca); // expected-error {{no matching function for call to 'forward'}}
+ }
+ {
+ std::forward<A>(csource()); // expected-error {{no matching function for call to 'forward'}}
+ }
+ {
+ A a;
+ std::forward(a); // expected-error {{no matching function for call to 'forward'}}
+ }
+}
diff --git a/libcxx/test/std/utilities/utility/forward/forward.pass.cpp b/libcxx/test/std/utilities/utility/forward/forward.pass.cpp
index 94575485df0..afff8d627fa 100644
--- a/libcxx/test/std/utilities/utility/forward/forward.pass.cpp
+++ b/libcxx/test/std/utilities/utility/forward/forward.pass.cpp
@@ -7,32 +7,40 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// test forward
#include <utility>
+#include <type_traits>
#include <cassert>
+#include "test_macros.h"
+
struct A
{
};
-A source() {return A();}
-const A csource() {return A();}
-
-typedef char one;
-struct two {one _[2];};
-struct four {one _[4];};
-struct eight {one _[8];};
-
-one test(A&);
-two test(const A&);
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
-four test(A&&);
-eight test(const A&&);
-
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+A source() noexcept {return A();}
+const A csource() noexcept {return A();}
+
+
+constexpr bool test_constexpr_forward() {
+#if TEST_STD_VER > 11
+ int x = 42;
+ const int cx = 101;
+ return std::forward<int&>(x) == 42
+ && std::forward<int>(x) == 42
+ && std::forward<const int&>(x) == 42
+ && std::forward<const int>(x) == 42
+ && std::forward<int&&>(x) == 42
+ && std::forward<const int&&>(x) == 42
+ && std::forward<const int&>(cx) == 101
+ && std::forward<const int>(cx) == 101;
+#else
+ return true;
+#endif
+}
int main()
{
@@ -42,42 +50,42 @@ int main()
((void)a); // Prevent unused warning
((void)ca); // Prevent unused warning
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- static_assert(sizeof(test(std::forward<A&>(a))) == 1, "");
- static_assert(sizeof(test(std::forward<A>(a))) == 4, "");
- static_assert(sizeof(test(std::forward<A>(source()))) == 4, "");
-
- static_assert(sizeof(test(std::forward<const A&>(a))) == 2, "");
-// static_assert(sizeof(test(std::forward<const A&>(source()))) == 2, "");
- static_assert(sizeof(test(std::forward<const A>(a))) == 8, "");
- static_assert(sizeof(test(std::forward<const A>(source()))) == 8, "");
-
- static_assert(sizeof(test(std::forward<const A&>(ca))) == 2, "");
-// static_assert(sizeof(test(std::forward<const A&>(csource()))) == 2, "");
- static_assert(sizeof(test(std::forward<const A>(ca))) == 8, "");
- static_assert(sizeof(test(std::forward<const A>(csource()))) == 8, "");
-
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
- static_assert(sizeof(test(std::forward<A&>(a))) == 1, "");
- static_assert(sizeof(test(std::forward<A>(a))) == 1, "");
-// static_assert(sizeof(test(std::forward<A>(source()))) == 2, "");
-
- static_assert(sizeof(test(std::forward<const A&>(a))) == 2, "");
- static_assert(sizeof(test(std::forward<const A&>(source()))) == 2, "");
- static_assert(sizeof(test(std::forward<const A>(a))) == 2, "");
- static_assert(sizeof(test(std::forward<const A>(source()))) == 2, "");
-
- static_assert(sizeof(test(std::forward<const A&>(ca))) == 2, "");
- static_assert(sizeof(test(std::forward<const A&>(csource()))) == 2, "");
- static_assert(sizeof(test(std::forward<const A>(ca))) == 2, "");
- static_assert(sizeof(test(std::forward<const A>(csource()))) == 2, "");
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
-#if _LIBCPP_STD_VER > 11
- constexpr int i1 = std::move(23);
- static_assert(i1 == 23, "" );
+ static_assert(std::is_same<decltype(std::forward<A&>(a)), A&>::value, "");
+ static_assert(std::is_same<decltype(std::forward<A>(a)), A&&>::value, "");
+ static_assert(std::is_same<decltype(std::forward<A>(source())), A&&>::value, "");
+ static_assert(noexcept(std::forward<A&>(a)), "");
+ static_assert(noexcept(std::forward<A>(a)), "");
+ static_assert(noexcept(std::forward<A>(source())), "");
+
+ static_assert(std::is_same<decltype(std::forward<const A&>(a)), const A&>::value, "");
+ static_assert(std::is_same<decltype(std::forward<const A>(a)), const A&&>::value, "");
+ static_assert(std::is_same<decltype(std::forward<const A>(source())), const A&&>::value, "");
+ static_assert(noexcept(std::forward<const A&>(a)), "");
+ static_assert(noexcept(std::forward<const A>(a)), "");
+ static_assert(noexcept(std::forward<const A>(source())), "");
+
+ static_assert(std::is_same<decltype(std::forward<const A&>(ca)), const A&>::value, "");
+ static_assert(std::is_same<decltype(std::forward<const A>(ca)), const A&&>::value, "");
+ static_assert(std::is_same<decltype(std::forward<const A>(csource())), const A&&>::value, "");
+ static_assert(noexcept(std::forward<const A&>(ca)), "");
+ static_assert(noexcept(std::forward<const A>(ca)), "");
+ static_assert(noexcept(std::forward<const A>(csource())), "");
+
+#if TEST_STD_VER > 11
+ {
+ constexpr int i2 = std::forward<int>(42);
+ static_assert(std::forward<int>(42) == 42, "");
+ static_assert(std::forward<const int&>(i2) == 42, "");
+ static_assert(test_constexpr_forward(), "");
+ }
+#endif
+#if TEST_STD_VER == 11 && defined(_LIBCPP_VERSION)
+ // Test that std::forward is constexpr in C++11. This is an extension
+ // provided by both libc++ and libstdc++.
+ {
constexpr int i2 = std::forward<int>(42);
- static_assert(i2 == 42, "" );
+ static_assert(std::forward<int>(42) == 42, "" );
+ static_assert(std::forward<const int&>(i2) == 42, "");
+ }
#endif
}
diff --git a/libcxx/test/std/utilities/utility/forward/forward1.fail.cpp b/libcxx/test/std/utilities/utility/forward/forward1.fail.cpp
deleted file mode 100644
index 43884d54bf8..00000000000
--- a/libcxx/test/std/utilities/utility/forward/forward1.fail.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// test forward
-
-#include <utility>
-
-struct A
-{
-};
-
-A source() {return A();}
-const A csource() {return A();}
-
-int main()
-{
- std::forward<A&>(source()); // error
-}
diff --git a/libcxx/test/std/utilities/utility/forward/forward2.fail.cpp b/libcxx/test/std/utilities/utility/forward/forward2.fail.cpp
deleted file mode 100644
index 9ff07233fee..00000000000
--- a/libcxx/test/std/utilities/utility/forward/forward2.fail.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// test forward
-
-#include <utility>
-
-struct A
-{
-};
-
-A source() {return A();}
-const A csource() {return A();}
-
-int main()
-{
- const A ca = A();
- std::forward<A&>(ca); // error
-}
diff --git a/libcxx/test/std/utilities/utility/forward/forward3.fail.cpp b/libcxx/test/std/utilities/utility/forward/forward3.fail.cpp
deleted file mode 100644
index 7e1e9b38fdc..00000000000
--- a/libcxx/test/std/utilities/utility/forward/forward3.fail.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// test forward
-
-#include <utility>
-
-struct A
-{
-};
-
-A source() {return A();}
-const A csource() {return A();}
-
-int main()
-{
- std::forward<A&>(csource()); // error
-}
diff --git a/libcxx/test/std/utilities/utility/forward/forward4.fail.cpp b/libcxx/test/std/utilities/utility/forward/forward4.fail.cpp
deleted file mode 100644
index 276506f811b..00000000000
--- a/libcxx/test/std/utilities/utility/forward/forward4.fail.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// test forward
-
-#include <utility>
-
-struct A
-{
-};
-
-A source() {return A();}
-const A csource() {return A();}
-
-int main()
-{
- const A ca = A();
- std::forward<A>(ca); // error
-}
diff --git a/libcxx/test/std/utilities/utility/forward/forward5.fail.cpp b/libcxx/test/std/utilities/utility/forward/forward5.fail.cpp
deleted file mode 100644
index 86c2b5651b9..00000000000
--- a/libcxx/test/std/utilities/utility/forward/forward5.fail.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// test forward
-
-#include <utility>
-
-struct A
-{
-};
-
-A source() {return A();}
-const A csource() {return A();}
-
-int main()
-{
- const A ca = A();
- std::forward<A>(csource()); // error
-}
diff --git a/libcxx/test/std/utilities/utility/forward/forward6.fail.cpp b/libcxx/test/std/utilities/utility/forward/forward6.fail.cpp
deleted file mode 100644
index 1f4b37d946c..00000000000
--- a/libcxx/test/std/utilities/utility/forward/forward6.fail.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// test forward
-
-#include <utility>
-
-struct A
-{
-};
-
-int main()
-{
- A a;
- std::forward(a); // error
-}
diff --git a/libcxx/test/std/utilities/utility/forward/forward_03.pass.cpp b/libcxx/test/std/utilities/utility/forward/forward_03.pass.cpp
new file mode 100644
index 00000000000..7e141bad94e
--- /dev/null
+++ b/libcxx/test/std/utilities/utility/forward/forward_03.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+#include <cassert>
+
+#include "test_macros.h"
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+typedef char one;
+struct two {one _[2];};
+struct four {one _[4];};
+struct eight {one _[8];};
+
+one test(A&);
+two test(const A&);
+
+int main()
+{
+ A a;
+ const A ca = A();
+
+ ((void)a); // Prevent unused warning
+ ((void)ca); // Prevent unused warning
+
+#if TEST_STD_VER < 11
+ static_assert(sizeof(test(std::forward<A&>(a))) == 1, "");
+ static_assert(sizeof(test(std::forward<A>(a))) == 1, "");
+
+ // Libc++'s C++03 implementation of 'forward' cannot accept true non-const
+ // rvalues.
+ // static_assert(sizeof(test(std::forward<A>(source()))) == 2, "");
+
+ static_assert(sizeof(test(std::forward<const A&>(a))) == 2, "");
+ static_assert(sizeof(test(std::forward<const A&>(source()))) == 2, "");
+ static_assert(sizeof(test(std::forward<const A>(a))) == 2, "");
+ static_assert(sizeof(test(std::forward<const A>(source()))) == 2, "");
+
+ static_assert(sizeof(test(std::forward<const A&>(ca))) == 2, "");
+ static_assert(sizeof(test(std::forward<const A&>(csource()))) == 2, "");
+ static_assert(sizeof(test(std::forward<const A>(ca))) == 2, "");
+ static_assert(sizeof(test(std::forward<const A>(csource()))) == 2, "");
+#endif
+}
diff --git a/libcxx/test/std/utilities/utility/forward/move_only.pass.cpp b/libcxx/test/std/utilities/utility/forward/move.fail.cpp
index 520bf5e5b6a..bd2126cbaee 100644
--- a/libcxx/test/std/utilities/utility/forward/move_only.pass.cpp
+++ b/libcxx/test/std/utilities/utility/forward/move.fail.cpp
@@ -7,22 +7,17 @@
//
//===----------------------------------------------------------------------===//
-// test move
-
// UNSUPPORTED: c++98, c++03
+// test move
+
#include <utility>
#include <cassert>
-class move_only
-{
- move_only(const move_only&);
- move_only& operator=(const move_only&);
-public:
- move_only(move_only&&) {}
- move_only& operator=(move_only&&) {return *this;}
-
+struct move_only {
move_only() {}
+ move_only(move_only&&) = default;
+ move_only& operator=(move_only&&) = default;
};
move_only source() {return move_only();}
@@ -32,8 +27,8 @@ void test(move_only) {}
int main()
{
- move_only mo;
+ move_only a;
+ const move_only ca = move_only();
- test(std::move(mo));
- test(source());
+ test(std::move(ca)); // c
}
diff --git a/libcxx/test/std/utilities/utility/forward/move.pass.cpp b/libcxx/test/std/utilities/utility/forward/move.pass.cpp
new file mode 100644
index 00000000000..9dfebcc5cc2
--- /dev/null
+++ b/libcxx/test/std/utilities/utility/forward/move.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+// UNSUPPORTED: c++98, c++03
+
+#include <utility>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+class move_only
+{
+ move_only(const move_only&);
+ move_only& operator=(const move_only&);
+public:
+ move_only(move_only&&) {}
+ move_only& operator=(move_only&&) {return *this;}
+
+ move_only() {}
+};
+
+move_only source() {return move_only();}
+const move_only csource() {return move_only();}
+
+void test(move_only) {}
+
+int x = 42;
+const int& cx = x;
+
+template <class QualInt>
+QualInt get() noexcept { return static_cast<QualInt>(x); }
+
+
+int copy_ctor = 0;
+int move_ctor = 0;
+
+struct A {
+ A() {}
+ A(const A&) {++copy_ctor;}
+ A(A&&) {++move_ctor;}
+ A& operator=(const A&) = delete;
+};
+
+constexpr bool test_constexpr_move() {
+#if TEST_STD_VER > 11
+ int x = 42;
+ const int cx = x;
+ return std::move(x) == 42
+ && std::move(cx) == 42
+ && std::move(static_cast<int&&>(x)) == 42
+ && std::move(static_cast<int const&&>(x)) == 42;
+#else
+ return true;
+#endif
+}
+
+int main()
+{
+ { // Test return type and noexcept.
+ static_assert(std::is_same<decltype(std::move(x)), int&&>::value, "");
+ static_assert(noexcept(std::move(x)), "");
+ static_assert(std::is_same<decltype(std::move(cx)), const int&&>::value, "");
+ static_assert(noexcept(std::move(cx)), "");
+ static_assert(std::is_same<decltype(std::move(42)), int&&>::value, "");
+ static_assert(noexcept(std::move(42)), "");
+ static_assert(std::is_same<decltype(std::move(get<const int&&>())), const int&&>::value, "");
+ static_assert(noexcept(std::move(get<int const&&>())), "");
+ }
+ { // test copy and move semantics
+ A a;
+ const A ca = A();
+
+ assert(copy_ctor == 0);
+ assert(move_ctor == 0);
+
+ A a2 = a;
+ assert(copy_ctor == 1);
+ assert(move_ctor == 0);
+
+ A a3 = std::move(a);
+ assert(copy_ctor == 1);
+ assert(move_ctor == 1);
+
+ A a4 = ca;
+ assert(copy_ctor == 2);
+ assert(move_ctor == 1);
+
+ A a5 = std::move(ca);
+ assert(copy_ctor == 3);
+ assert(move_ctor == 1);
+ }
+ { // test on a move only type
+ move_only mo;
+ test(std::move(mo));
+ test(source());
+ }
+#if TEST_STD_VER > 11
+ {
+ constexpr int x = 42;
+ static_assert(std::move(x) == 42, "");
+ static_assert(test_constexpr_move(), "");
+ }
+#endif
+#if TEST_STD_VER == 11 && defined(_LIBCPP_VERSION)
+ // Test that std::forward is constexpr in C++11. This is an extension
+ // provided by both libc++ and libstdc++.
+ {
+ constexpr int x = 42;
+ static_assert(std::move(x) == 42, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/utilities/utility/forward/move_copy.pass.cpp b/libcxx/test/std/utilities/utility/forward/move_copy.pass.cpp
deleted file mode 100644
index fa15553f669..00000000000
--- a/libcxx/test/std/utilities/utility/forward/move_copy.pass.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// test move
-
-// UNSUPPORTED: c++98, c++03
-
-#include <utility>
-#include <cassert>
-
-int copy_ctor = 0;
-int move_ctor = 0;
-
-class A
-{
-public:
-
- A(const A&) {++copy_ctor;}
- A& operator=(const A&);
-
- A(A&&) {++move_ctor;}
- A& operator=(A&&);
-
- A() {}
-};
-
-A source() {return A();}
-const A csource() {return A();}
-
-void test(A) {}
-
-int main()
-{
- A a;
- const A ca = A();
-
- assert(copy_ctor == 0);
- assert(move_ctor == 0);
-
- A a2 = a;
- assert(copy_ctor == 1);
- assert(move_ctor == 0);
-
- A a3 = std::move(a);
- assert(copy_ctor == 1);
- assert(move_ctor == 1);
-
- A a4 = ca;
- assert(copy_ctor == 2);
- assert(move_ctor == 1);
-
- A a5 = std::move(ca);
- assert(copy_ctor == 3);
- assert(move_ctor == 1);
-}
diff --git a/libcxx/test/std/utilities/utility/forward/move_only1.fail.cpp b/libcxx/test/std/utilities/utility/forward/move_only1.fail.cpp
deleted file mode 100644
index 5e7623a1bd1..00000000000
--- a/libcxx/test/std/utilities/utility/forward/move_only1.fail.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// test move
-
-#include <utility>
-#include <cassert>
-
-#include <typeinfo>
-#include <stdio.h>
-
-class move_only
-{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- move_only(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:
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- move_only(move_only&&) {}
- move_only& operator=(move_only&&) {}
-#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 source() {return move_only();}
-const move_only csource() {return move_only();}
-
-void test(move_only) {}
-
-int main()
-{
- move_only a;
- const move_only ca = move_only();
-
- test(a);
-}
diff --git a/libcxx/test/std/utilities/utility/forward/move_only2.fail.cpp b/libcxx/test/std/utilities/utility/forward/move_only2.fail.cpp
deleted file mode 100644
index 2043f3d4bde..00000000000
--- a/libcxx/test/std/utilities/utility/forward/move_only2.fail.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// test move
-
-#include <utility>
-#include <cassert>
-
-#include <typeinfo>
-#include <stdio.h>
-
-class move_only
-{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- move_only(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:
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- move_only(move_only&&) {}
- move_only& operator=(move_only&&) {}
-#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 source() {return move_only();}
-const move_only csource() {return move_only();}
-
-void test(move_only) {}
-
-int main()
-{
- move_only a;
- const move_only ca = move_only();
-
- test(ca);
-}
diff --git a/libcxx/test/std/utilities/utility/forward/move_only3.fail.cpp b/libcxx/test/std/utilities/utility/forward/move_only3.fail.cpp
deleted file mode 100644
index 84c83ae48f8..00000000000
--- a/libcxx/test/std/utilities/utility/forward/move_only3.fail.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// test move
-
-#include <utility>
-#include <cassert>
-
-class move_only
-{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- move_only(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:
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- move_only(move_only&&) {}
- move_only& operator=(move_only&&) {}
-#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 source() {return move_only();}
-const move_only csource() {return move_only();}
-
-void test(move_only) {}
-
-int main()
-{
- move_only a;
- const move_only ca = move_only();
-
- test(std::move(ca));
-}
diff --git a/libcxx/test/std/utilities/utility/forward/move_only4.fail.cpp b/libcxx/test/std/utilities/utility/forward/move_only4.fail.cpp
deleted file mode 100644
index 5eeca89abe3..00000000000
--- a/libcxx/test/std/utilities/utility/forward/move_only4.fail.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// test move
-
-#include <utility>
-#include <cassert>
-
-#include <typeinfo>
-#include <stdio.h>
-
-class move_only
-{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- move_only(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:
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- move_only(move_only&&) {}
- move_only& operator=(move_only&&) {}
-#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 source() {return move_only();}
-const move_only csource() {return move_only();}
-
-void test(move_only) {}
-
-int main()
-{
- move_only a;
- const move_only ca = move_only();
-
- test(csource());
-}
OpenPOWER on IntegriCloud