diff options
Diffstat (limited to 'test/std/utilities/utility')
56 files changed, 0 insertions, 3460 deletions
diff --git a/test/std/utilities/utility/as_const/as_const.fail.cpp b/test/std/utilities/utility/as_const/as_const.fail.cpp deleted file mode 100644 index c28957cfc505..000000000000 --- a/test/std/utilities/utility/as_const/as_const.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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11, c++14 - -// template <class T> constexpr add_const<T>& as_const(T& t) noexcept; // C++17 -// template <class T> add_const<T>& as_const(const T&&) = delete; // C++17 - -#include <utility> - -struct S {int i;}; - -int main() -{ - std::as_const(S{}); -} diff --git a/test/std/utilities/utility/as_const/as_const.pass.cpp b/test/std/utilities/utility/as_const/as_const.pass.cpp deleted file mode 100644 index 268f2d1b04ee..000000000000 --- a/test/std/utilities/utility/as_const/as_const.pass.cpp +++ /dev/null @@ -1,46 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11, c++14 - -// template <class T> constexpr add_const<T>& as_const(T& t) noexcept; // C++17 -// template <class T> add_const<T>& as_const(const T&&) = delete; // C++17 - -#include <utility> -#include <cassert> - -struct S {int i;}; -bool operator==(const S& x, const S& y) { return x.i == y.i; } -bool operator==(const volatile S& x, const volatile S& y) { return x.i == y.i; } - -template<typename T> -void test(T& t) -{ - static_assert(std::is_const<typename std::remove_reference<decltype(std::as_const (t))>::type>::value, ""); - static_assert(std::is_const<typename std::remove_reference<decltype(std::as_const< T>(t))>::type>::value, ""); - static_assert(std::is_const<typename std::remove_reference<decltype(std::as_const<const T>(t))>::type>::value, ""); - static_assert(std::is_const<typename std::remove_reference<decltype(std::as_const<volatile T>(t))>::type>::value, ""); - static_assert(std::is_const<typename std::remove_reference<decltype(std::as_const<const volatile T>(t))>::type>::value, ""); - - assert(std::as_const(t) == t); - assert(std::as_const< T>(t) == t); - assert(std::as_const<const T>(t) == t); - assert(std::as_const<volatile T>(t) == t); - assert(std::as_const<const volatile T>(t) == t); -} - -int main() -{ - int i = 3; - double d = 4.0; - S s{2}; - test(i); - test(d); - test(s); -} diff --git a/test/std/utilities/utility/declval/declval.pass.cpp b/test/std/utilities/utility/declval/declval.pass.cpp deleted file mode 100644 index aabd0e6f6c74..000000000000 --- a/test/std/utilities/utility/declval/declval.pass.cpp +++ /dev/null @@ -1,32 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T> typename add_rvalue_reference<T>::type declval() noexcept; - -#include <utility> -#include <type_traits> - -#include "test_macros.h" - -class A -{ - A(const A&); - A& operator=(const A&); -}; - -int main() -{ -#if TEST_STD_VER >= 11 - static_assert((std::is_same<decltype(std::declval<A>()), A&&>::value), ""); -#else - static_assert((std::is_same<decltype(std::declval<A>()), A&>::value), ""); -#endif -} diff --git a/test/std/utilities/utility/exchange/exchange.pass.cpp b/test/std/utilities/utility/exchange/exchange.pass.cpp deleted file mode 100644 index 1a5007ea41fb..000000000000 --- a/test/std/utilities/utility/exchange/exchange.pass.cpp +++ /dev/null @@ -1,84 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// <utility> - -// exchange - -// template<class T, class U=T> -// constexpr T // constexpr after C++17 -// exchange(T& obj, U&& new_value); - -#include <utility> -#include <cassert> -#include <string> - -#include "test_macros.h" - -#if TEST_STD_VER > 17 -TEST_CONSTEXPR bool test_constexpr() { - int v = 12; - - if (12 != std::exchange(v,23) || v != 23) - return false; - - if (23 != std::exchange(v,static_cast<short>(67)) || v != 67) - return false; - - if (67 != std::exchange<int, short>(v, {}) || v != 0) - return false; - return true; - } -#endif - - - -int main() -{ - { - int v = 12; - assert ( std::exchange ( v, 23 ) == 12 ); - assert ( v == 23 ); - assert ( std::exchange ( v, static_cast<short>(67) ) == 23 ); - assert ( v == 67 ); - - assert ((std::exchange<int, short> ( v, {} )) == 67 ); - assert ( v == 0 ); - - } - - { - bool b = false; - assert ( !std::exchange ( b, true )); - assert ( b ); - } - - { - const std::string s1 ( "Hi Mom!" ); - const std::string s2 ( "Yo Dad!" ); - std::string s3 = s1; // Mom - assert ( std::exchange ( s3, s2 ) == s1 ); - assert ( s3 == s2 ); - assert ( std::exchange ( s3, "Hi Mom!" ) == s2 ); - assert ( s3 == s1 ); - - s3 = s2; // Dad - assert ( std::exchange ( s3, {} ) == s2 ); - assert ( s3.size () == 0 ); - - s3 = s2; // Dad - assert ( std::exchange ( s3, "" ) == s2 ); - assert ( s3.size () == 0 ); - } - -#if TEST_STD_VER > 17 - static_assert(test_constexpr()); -#endif -} diff --git a/test/std/utilities/utility/forward/forward.fail.cpp b/test/std/utilities/utility/forward/forward.fail.cpp deleted file mode 100644 index c845216d86dc..000000000000 --- a/test/std/utilities/utility/forward/forward.fail.cpp +++ /dev/null @@ -1,53 +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> - -#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-re@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/test/std/utilities/utility/forward/forward.pass.cpp b/test/std/utilities/utility/forward/forward.pass.cpp deleted file mode 100644 index afff8d627fad..000000000000 --- a/test/std/utilities/utility/forward/forward.pass.cpp +++ /dev/null @@ -1,91 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// test forward - -#include <utility> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -struct A -{ -}; - -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() -{ - A a; - const A ca = A(); - - ((void)a); // Prevent unused warning - ((void)ca); // Prevent unused warning - - 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(std::forward<int>(42) == 42, "" ); - static_assert(std::forward<const int&>(i2) == 42, ""); - } -#endif -} diff --git a/test/std/utilities/utility/forward/forward_03.pass.cpp b/test/std/utilities/utility/forward/forward_03.pass.cpp deleted file mode 100644 index 7e141bad94e8..000000000000 --- a/test/std/utilities/utility/forward/forward_03.pass.cpp +++ /dev/null @@ -1,58 +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> -#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/test/std/utilities/utility/forward/move.fail.cpp b/test/std/utilities/utility/forward/move.fail.cpp deleted file mode 100644 index bd2126cbaee4..000000000000 --- a/test/std/utilities/utility/forward/move.fail.cpp +++ /dev/null @@ -1,34 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// test move - -#include <utility> -#include <cassert> - -struct move_only { - move_only() {} - move_only(move_only&&) = default; - move_only& operator=(move_only&&) = default; -}; - -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)); // c -} diff --git a/test/std/utilities/utility/forward/move.pass.cpp b/test/std/utilities/utility/forward/move.pass.cpp deleted file mode 100644 index e2edc2a2afad..000000000000 --- a/test/std/utilities/utility/forward/move.pass.cpp +++ /dev/null @@ -1,121 +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 <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 y = 42; - const int cy = y; - return std::move(y) == 42 - && std::move(cy) == 42 - && std::move(static_cast<int&&>(y)) == 42 - && std::move(static_cast<int const&&>(y)) == 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 y = 42; - static_assert(std::move(y) == 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 y = 42; - static_assert(std::move(y) == 42, ""); - } -#endif -} diff --git a/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp b/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp deleted file mode 100644 index bc60d3d27614..000000000000 --- a/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp +++ /dev/null @@ -1,75 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T> -// typename conditional -// < -// !is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value, -// const T&, -// T&& -// >::type -// move_if_noexcept(T& x); - -#include <utility> - -#include "test_macros.h" - -class A -{ - A(const A&); - A& operator=(const A&); -public: - - A() {} -#if TEST_STD_VER >= 11 - A(A&&) {} -#endif -}; - -struct legacy -{ - legacy() {} - legacy(const legacy&); -}; - -int main() -{ - int i = 0; - const int ci = 0; - - legacy l; - A a; - const A ca; - -#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(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(ca)), const A&&>::value), ""); - static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::value), ""); -#else // C++ < 11 - // In C++03 libc++ #define's decltype to be __decltype on clang and - // __typeof__ for other compilers. __typeof__ does not deduce the reference - // qualifiers and will cause this test to fail. - 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(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(l)), const legacy&>::value), ""); -#endif - -#if TEST_STD_VER > 11 - constexpr int i1 = 23; - constexpr int i2 = std::move_if_noexcept(i1); - static_assert(i2 == 23, "" ); -#endif - -} diff --git a/test/std/utilities/utility/operators/rel_ops.pass.cpp b/test/std/utilities/utility/operators/rel_ops.pass.cpp deleted file mode 100644 index 26e766592f2b..000000000000 --- a/test/std/utilities/utility/operators/rel_ops.pass.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 rel_ops - -#include <utility> -#include <cassert> - -struct A -{ - int data_; - - explicit A(int data = -1) : data_(data) {} -}; - -inline -bool -operator == (const A& x, const A& y) -{ - return x.data_ == y.data_; -} - -inline -bool -operator < (const A& x, const A& y) -{ - return x.data_ < y.data_; -} - -int main() -{ - using namespace std::rel_ops; - A a1(1); - A a2(2); - assert(a1 == a1); - assert(a1 != a2); - assert(a1 < a2); - assert(a2 > a1); - assert(a1 <= a1); - assert(a1 <= a2); - assert(a2 >= a2); - assert(a2 >= a1); -} diff --git a/test/std/utilities/utility/pairs/nothing_to_do.pass.cpp b/test/std/utilities/utility/pairs/nothing_to_do.pass.cpp deleted file mode 100644 index b58f5c55b643..000000000000 --- a/test/std/utilities/utility/pairs/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/test/std/utilities/utility/pairs/pair.astuple/get_const.fail.cpp b/test/std/utilities/utility/pairs/pair.astuple/get_const.fail.cpp deleted file mode 100644 index dbe1c2668665..000000000000 --- a/test/std/utilities/utility/pairs/pair.astuple/get_const.fail.cpp +++ /dev/null @@ -1,30 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// template<size_t I, class T1, class T2> -// const typename tuple_element<I, std::pair<T1, T2> >::type& -// get(const pair<T1, T2>&); - -#include <utility> -#include <cassert> - -int main() -{ - { - typedef std::pair<int, short> P; - const P p(3, 4); - assert(std::get<0>(p) == 3); - assert(std::get<1>(p) == 4); - std::get<0>(p) = 5; - } -} diff --git a/test/std/utilities/utility/pairs/pair.astuple/get_const.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/get_const.pass.cpp deleted file mode 100644 index c09c8815e16f..000000000000 --- a/test/std/utilities/utility/pairs/pair.astuple/get_const.pass.cpp +++ /dev/null @@ -1,40 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// template<size_t I, class T1, class T2> -// const typename tuple_element<I, std::pair<T1, T2> >::type& -// get(const pair<T1, T2>&); - -#include <utility> -#include <cassert> - -#include "test_macros.h" - -int main() -{ - { - typedef std::pair<int, short> P; - const P p(3, static_cast<short>(4)); - assert(std::get<0>(p) == 3); - assert(std::get<1>(p) == 4); - } - -#if TEST_STD_VER > 11 - { - typedef std::pair<int, short> P; - constexpr P p1(3, static_cast<short>(4)); - static_assert(std::get<0>(p1) == 3, ""); - static_assert(std::get<1>(p1) == 4, ""); - } -#endif -} diff --git a/test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp deleted file mode 100644 index 5c38318d26da..000000000000 --- a/test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp +++ /dev/null @@ -1,66 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// template<size_t I, class T1, class T2> -// const typename tuple_element<I, std::pair<T1, T2> >::type&& -// get(const pair<T1, T2>&&); - -// UNSUPPORTED: c++98, c++03 - -#include <utility> -#include <memory> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -int main() -{ - { - typedef std::pair<std::unique_ptr<int>, short> P; - const P p(std::unique_ptr<int>(new int(3)), static_cast<short>(4)); - static_assert(std::is_same<const std::unique_ptr<int>&&, decltype(std::get<0>(std::move(p)))>::value, ""); - static_assert(noexcept(std::get<0>(std::move(p))), ""); - const std::unique_ptr<int>&& ptr = std::get<0>(std::move(p)); - assert(*ptr == 3); - } - - { - int x = 42; - int const y = 43; - std::pair<int&, int const&> const p(x, y); - static_assert(std::is_same<int&, decltype(std::get<0>(std::move(p)))>::value, ""); - static_assert(noexcept(std::get<0>(std::move(p))), ""); - static_assert(std::is_same<int const&, decltype(std::get<1>(std::move(p)))>::value, ""); - static_assert(noexcept(std::get<1>(std::move(p))), ""); - } - - { - int x = 42; - int const y = 43; - std::pair<int&&, int const&&> const p(std::move(x), std::move(y)); - static_assert(std::is_same<int&&, decltype(std::get<0>(std::move(p)))>::value, ""); - static_assert(noexcept(std::get<0>(std::move(p))), ""); - static_assert(std::is_same<int const&&, decltype(std::get<1>(std::move(p)))>::value, ""); - static_assert(noexcept(std::get<1>(std::move(p))), ""); - } - -#if TEST_STD_VER > 11 - { - typedef std::pair<int, short> P; - constexpr const P p1(3, static_cast<short>(4)); - static_assert(std::get<0>(std::move(p1)) == 3, ""); - static_assert(std::get<1>(std::move(p1)) == 4, ""); - } -#endif -} diff --git a/test/std/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp deleted file mode 100644 index 2f8b6c1e8497..000000000000 --- a/test/std/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp +++ /dev/null @@ -1,53 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// template<size_t I, class T1, class T2> -// typename tuple_element<I, std::pair<T1, T2> >::type& -// get(pair<T1, T2>&); - -#include <utility> -#include <cassert> - -#include "test_macros.h" - -#if TEST_STD_VER > 11 -struct S { - std::pair<int, int> a; - int k; - constexpr S() : a{1,2}, k(std::get<0>(a)) {} - }; - -constexpr std::pair<int, int> getP () { return { 3, 4 }; } -#endif - -int main() -{ - { - typedef std::pair<int, short> P; - P p(3, static_cast<short>(4)); - assert(std::get<0>(p) == 3); - assert(std::get<1>(p) == 4); - std::get<0>(p) = 5; - std::get<1>(p) = 6; - assert(std::get<0>(p) == 5); - assert(std::get<1>(p) == 6); - } - -#if TEST_STD_VER > 11 - { - static_assert(S().k == 1, ""); - static_assert(std::get<1>(getP()) == 4, ""); - } -#endif - -} diff --git a/test/std/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp deleted file mode 100644 index 0601e4e73a74..000000000000 --- a/test/std/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp +++ /dev/null @@ -1,32 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <utility> - -// template <class T1, class T2> struct pair - -// template<size_t I, class T1, class T2> -// typename tuple_element<I, std::pair<T1, T2> >::type&& -// get(pair<T1, T2>&&); - -#include <utility> -#include <memory> -#include <cassert> - -int main() -{ - { - typedef std::pair<std::unique_ptr<int>, short> P; - P p(std::unique_ptr<int>(new int(3)), static_cast<short>(4)); - std::unique_ptr<int> ptr = std::get<0>(std::move(p)); - assert(*ptr == 3); - } -} diff --git a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp deleted file mode 100644 index f4a6232266bb..000000000000 --- a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp +++ /dev/null @@ -1,85 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -#include <utility> -#include <string> -#include <type_traits> -#include <complex> -#include <memory> - -#include <cassert> - -int main() -{ - typedef std::complex<float> cf; - { - auto t1 = std::make_pair<int, cf> ( 42, { 1,2 } ); - assert ( std::get<int>(t1) == 42 ); - assert ( std::get<cf>(t1).real() == 1 ); - assert ( std::get<cf>(t1).imag() == 2 ); - } - - { - const std::pair<int, const int> p1 { 1, 2 }; - const int &i1 = std::get<int>(p1); - const int &i2 = std::get<const int>(p1); - assert ( i1 == 1 ); - assert ( i2 == 2 ); - } - - { - typedef std::unique_ptr<int> upint; - std::pair<upint, int> t(upint(new int(4)), 42); - upint p = std::get<upint>(std::move(t)); // get rvalue - assert(*p == 4); - assert(std::get<upint>(t) == nullptr); // has been moved from - } - - { - typedef std::unique_ptr<int> upint; - const std::pair<upint, int> t(upint(new int(4)), 42); - static_assert(std::is_same<const upint&&, decltype(std::get<upint>(std::move(t)))>::value, ""); - static_assert(noexcept(std::get<upint>(std::move(t))), ""); - static_assert(std::is_same<const int&&, decltype(std::get<int>(std::move(t)))>::value, ""); - static_assert(noexcept(std::get<int>(std::move(t))), ""); - auto&& p = std::get<upint>(std::move(t)); // get const rvalue - auto&& i = std::get<int>(std::move(t)); // get const rvalue - assert(*p == 4); - assert(i == 42); - assert(std::get<upint>(t) != nullptr); - } - - { - int x = 42; - int const y = 43; - std::pair<int&, int const&> const p(x, y); - static_assert(std::is_same<int&, decltype(std::get<int&>(std::move(p)))>::value, ""); - static_assert(noexcept(std::get<int&>(std::move(p))), ""); - static_assert(std::is_same<int const&, decltype(std::get<int const&>(std::move(p)))>::value, ""); - static_assert(noexcept(std::get<int const&>(std::move(p))), ""); - } - - { - int x = 42; - int const y = 43; - std::pair<int&&, int const&&> const p(std::move(x), std::move(y)); - static_assert(std::is_same<int&&, decltype(std::get<int&&>(std::move(p)))>::value, ""); - static_assert(noexcept(std::get<int&&>(std::move(p))), ""); - static_assert(std::is_same<int const&&, decltype(std::get<int const&&>(std::move(p)))>::value, ""); - static_assert(noexcept(std::get<int const&&>(std::move(p))), ""); - } - - { - constexpr const std::pair<int, const int> p { 1, 2 }; - static_assert(std::get<int>(std::move(p)) == 1, ""); - static_assert(std::get<const int>(std::move(p)) == 2, ""); - } -} diff --git a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type1.fail.cpp b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type1.fail.cpp deleted file mode 100644 index f0d55a661822..000000000000 --- a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type1.fail.cpp +++ /dev/null @@ -1,21 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -#include <utility> -#include <complex> - -#include <cassert> - -int main() -{ - typedef std::complex<float> cf; - auto t1 = std::make_pair<int, double> ( 42, 3.4 ); - assert (( std::get<cf>(t1) == cf {1,2} )); // no such type -} diff --git a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type2.fail.cpp b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type2.fail.cpp deleted file mode 100644 index 72e637592483..000000000000 --- a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type2.fail.cpp +++ /dev/null @@ -1,21 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -#include <utility> -#include <complex> - -#include <cassert> - -int main() -{ - typedef std::complex<float> cf; - auto t1 = std::make_pair<int, int> ( 42, 43 ); - assert ( std::get<int>(t1) == 42 ); // two ints -} diff --git a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type3.fail.cpp b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type3.fail.cpp deleted file mode 100644 index d5179e4355b9..000000000000 --- a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type3.fail.cpp +++ /dev/null @@ -1,21 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -#include <utility> -#include <complex> - -#include <cassert> - -int main() -{ - typedef std::unique_ptr<int> upint; - std::pair<upint, int> t(upint(new int(4)), 23); - upint p = std::get<upint>(t); -} diff --git a/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp b/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp deleted file mode 100644 index 4ca31f7debe8..000000000000 --- a/test/std/utilities/utility/pairs/pair.astuple/tuple_element.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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// tuple_element<I, pair<T1, T2> >::type - -#include <utility> - -int main() -{ - typedef std::pair<int, short> T; - std::tuple_element<2, T>::type foo; // expected-error@utility:* {{Index out of bounds in std::tuple_element<std::pair<T1, T2>>}} -} diff --git a/test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp deleted file mode 100644 index 5ac838b37429..000000000000 --- a/test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp +++ /dev/null @@ -1,55 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// tuple_element<I, pair<T1, T2> >::type - -#include <utility> - -template <class T1, class T2> -void test() -{ - { - typedef T1 Exp1; - typedef T2 Exp2; - typedef std::pair<T1, T2> P; - static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), ""); - static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), ""); - } - { - typedef T1 const Exp1; - typedef T2 const Exp2; - typedef std::pair<T1, T2> const P; - static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), ""); - static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), ""); - } - { - typedef T1 volatile Exp1; - typedef T2 volatile Exp2; - typedef std::pair<T1, T2> volatile P; - static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), ""); - static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), ""); - } - { - typedef T1 const volatile Exp1; - typedef T2 const volatile Exp2; - typedef std::pair<T1, T2> const volatile P; - static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), ""); - static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), ""); - } -} - -int main() -{ - test<int, short>(); - test<int*, char>(); -} diff --git a/test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp deleted file mode 100644 index 3756e963fa35..000000000000 --- a/test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp +++ /dev/null @@ -1,36 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// tuple_size<pair<T1, T2> >::value - -#include <utility> - -int main() -{ - { - typedef std::pair<int, short> P1; - static_assert((std::tuple_size<P1>::value == 2), ""); - } - { - typedef std::pair<int, short> const P1; - static_assert((std::tuple_size<P1>::value == 2), ""); - } - { - typedef std::pair<int, short> volatile P1; - static_assert((std::tuple_size<P1>::value == 2), ""); - } - { - typedef std::pair<int, short> const volatile P1; - static_assert((std::tuple_size<P1>::value == 2), ""); - } -} diff --git a/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp b/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp deleted file mode 100644 index 12968de2dd47..000000000000 --- a/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp +++ /dev/null @@ -1,55 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <utility> - -// template <class T1, class T2> struct pair - -// struct piecewise_construct_t { }; -// constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); - -#include <utility> -#include <tuple> -#include <cassert> - -class A -{ - int i_; - char c_; -public: - A(int i, char c) : i_(i), c_(c) {} - int get_i() const {return i_;} - char get_c() const {return c_;} -}; - -class B -{ - double d_; - unsigned u1_; - unsigned u2_; -public: - B(double d, unsigned u1, unsigned u2) : d_(d), u1_(u1), u2_(u2) {} - double get_d() const {return d_;} - unsigned get_u1() const {return u1_;} - unsigned get_u2() const {return u2_;} -}; - -int main() -{ - std::pair<A, B> p(std::piecewise_construct, - std::make_tuple(4, 'a'), - std::make_tuple(3.5, 6u, 2u)); - assert(p.first.get_i() == 4); - assert(p.first.get_c() == 'a'); - assert(p.second.get_d() == 3.5); - assert(p.second.get_u1() == 6u); - assert(p.second.get_u2() == 2u); -} diff --git a/test/std/utilities/utility/pairs/pairs.general/nothing_to_do.pass.cpp b/test/std/utilities/utility/pairs/pairs.general/nothing_to_do.pass.cpp deleted file mode 100644 index b58f5c55b643..000000000000 --- a/test/std/utilities/utility/pairs/pairs.general/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/U_V.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/U_V.pass.cpp deleted file mode 100644 index 1ef2d9402fc3..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/U_V.pass.cpp +++ /dev/null @@ -1,100 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <utility> - -// template <class T1, class T2> struct pair - -// template<class U, class V> pair(U&& x, V&& y); - - -#include <utility> -#include <memory> -#include <cassert> - -#include "archetypes.hpp" -#include "test_convertible.hpp" -using namespace ImplicitTypes; // Get implicitly archetypes - -template <class T1, class T1Arg, - bool CanCopy = true, bool CanConvert = CanCopy> -void test_sfinae() { - using P1 = std::pair<T1, int>; - using P2 = std::pair<int, T1>; - using T2 = int const&; - static_assert(std::is_constructible<P1, T1Arg, T2>::value == CanCopy, ""); - static_assert(test_convertible<P1, T1Arg, T2>() == CanConvert, ""); - static_assert(std::is_constructible<P2, T2, T1Arg>::value == CanCopy, ""); - static_assert(test_convertible<P2, T2, T1Arg>() == CanConvert, ""); -} - -struct ExplicitT { - constexpr explicit ExplicitT(int x) : value(x) {} - int value; -}; - -struct ImplicitT { - constexpr ImplicitT(int x) : value(x) {} - int value; -}; - - -int main() -{ - { - typedef std::pair<std::unique_ptr<int>, short*> P; - P p(std::unique_ptr<int>(new int(3)), nullptr); - assert(*p.first == 3); - assert(p.second == nullptr); - } - { - // Test non-const lvalue and rvalue types - test_sfinae<AllCtors, AllCtors&>(); - test_sfinae<AllCtors, AllCtors&&>(); - test_sfinae<ExplicitTypes::AllCtors, ExplicitTypes::AllCtors&, true, false>(); - test_sfinae<ExplicitTypes::AllCtors, ExplicitTypes::AllCtors&&, true, false>(); - test_sfinae<CopyOnly, CopyOnly&>(); - test_sfinae<CopyOnly, CopyOnly&&>(); - test_sfinae<ExplicitTypes::CopyOnly, ExplicitTypes::CopyOnly&, true, false>(); - test_sfinae<ExplicitTypes::CopyOnly, ExplicitTypes::CopyOnly&&, true, false>(); - test_sfinae<MoveOnly, MoveOnly&, false>(); - test_sfinae<MoveOnly, MoveOnly&&>(); - test_sfinae<ExplicitTypes::MoveOnly, ExplicitTypes::MoveOnly&, false>(); - test_sfinae<ExplicitTypes::MoveOnly, ExplicitTypes::MoveOnly&&, true, false>(); - test_sfinae<NonCopyable, NonCopyable&, false>(); - test_sfinae<NonCopyable, NonCopyable&&, false>(); - test_sfinae<ExplicitTypes::NonCopyable, ExplicitTypes::NonCopyable&, false>(); - test_sfinae<ExplicitTypes::NonCopyable, ExplicitTypes::NonCopyable&&, false>(); - } - { - // Test converting types - test_sfinae<ConvertingType, int&>(); - test_sfinae<ConvertingType, const int&>(); - test_sfinae<ConvertingType, int&&>(); - test_sfinae<ConvertingType, const int&&>(); - test_sfinae<ExplicitTypes::ConvertingType, int&, true, false>(); - test_sfinae<ExplicitTypes::ConvertingType, const int&, true, false>(); - test_sfinae<ExplicitTypes::ConvertingType, int&&, true, false>(); - test_sfinae<ExplicitTypes::ConvertingType, const int&&, true, false>(); - } -#if TEST_STD_VER > 11 - { // explicit constexpr test - constexpr std::pair<ExplicitT, ExplicitT> p(42, 43); - static_assert(p.first.value == 42, ""); - static_assert(p.second.value == 43, ""); - } - { // implicit constexpr test - constexpr std::pair<ImplicitT, ImplicitT> p = {42, 43}; - static_assert(p.first.value == 42, ""); - static_assert(p.second.value == 43, ""); - } -#endif -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp deleted file mode 100644 index 90722c393c68..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// template<class U, class V> pair& operator=(const pair<U, V>& p); - -#include <utility> -#include <cassert> - -#include "test_macros.h" -#if TEST_STD_VER >= 11 -#include "archetypes.hpp" -#endif - -int main() -{ - { - typedef std::pair<int, short> P1; - typedef std::pair<double, long> P2; - P1 p1(3, static_cast<short>(4)); - P2 p2; - p2 = p1; - assert(p2.first == 3); - assert(p2.second == 4); - } -#if TEST_STD_VER >= 11 - { - using C = TestTypes::TestType; - using P = std::pair<int, C>; - using T = std::pair<long, C>; - const T t(42, -42); - P p(101, 101); - C::reset_constructors(); - p = t; - assert(C::constructed == 0); - assert(C::assigned == 1); - assert(C::copy_assigned == 1); - assert(C::move_assigned == 0); - assert(p.first == 42); - assert(p.second.value == -42); - } -#endif -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/assign_pair.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/assign_pair.pass.cpp deleted file mode 100644 index 3f7066310002..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/assign_pair.pass.cpp +++ /dev/null @@ -1,101 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <utility> - -// template <class T1, class T2> struct pair - -// pair& operator=(pair const& p); - -#include <utility> -#include <memory> -#include <cassert> - - -struct NonAssignable { - NonAssignable& operator=(NonAssignable const&) = delete; - NonAssignable& operator=(NonAssignable&&) = delete; -}; -struct CopyAssignable { - CopyAssignable() = default; - CopyAssignable(CopyAssignable const&) = default; - CopyAssignable& operator=(CopyAssignable const&) = default; - CopyAssignable& operator=(CopyAssignable&&) = delete; -}; -struct MoveAssignable { - MoveAssignable() = default; - MoveAssignable& operator=(MoveAssignable const&) = delete; - MoveAssignable& operator=(MoveAssignable&&) = default; -}; - -struct CountAssign { - static int copied; - static int moved; - static void reset() { copied = moved = 0; } - CountAssign() = default; - CountAssign& operator=(CountAssign const&) { ++copied; return *this; } - CountAssign& operator=(CountAssign&&) { ++moved; return *this; } -}; -int CountAssign::copied = 0; -int CountAssign::moved = 0; - -struct Incomplete; -extern Incomplete inc_obj; - -int main() -{ - { - typedef std::pair<CopyAssignable, short> P; - const P p1(CopyAssignable(), 4); - P p2; - p2 = p1; - assert(p2.second == 4); - } - { - using P = std::pair<int&, int&&>; - int x = 42; - int y = 101; - int x2 = -1; - int y2 = 300; - P p1(x, std::move(y)); - P p2(x2, std::move(y2)); - p1 = p2; - assert(p1.first == x2); - assert(p1.second == y2); - } - { - using P = std::pair<int, NonAssignable>; - static_assert(!std::is_copy_assignable<P>::value, ""); - } - { - CountAssign::reset(); - using P = std::pair<CountAssign, CopyAssignable>; - static_assert(std::is_copy_assignable<P>::value, ""); - P p; - P p2; - p = p2; - assert(CountAssign::copied == 1); - assert(CountAssign::moved == 0); - } - { - using P = std::pair<int, MoveAssignable>; - static_assert(!std::is_copy_assignable<P>::value, ""); - } - { - using P = std::pair<int, Incomplete&>; - static_assert(!std::is_copy_assignable<P>::value, ""); - P p(42, inc_obj); - assert(&p.second == &inc_obj); - } -} - -struct Incomplete {}; -Incomplete inc_obj; diff --git a/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.cpp deleted file mode 100644 index cf1afff90cda..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/assign_pair_cxx03.pass.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. -// -//===----------------------------------------------------------------------===// - -// REQUIRES: c++98 || c++03 - -// <utility> - -// template <class T1, class T2> struct pair - -// pair& operator=(pair const& p); - -#include <utility> -#include <memory> -#include <cassert> - -struct NonAssignable { - NonAssignable() {} -private: - NonAssignable& operator=(NonAssignable const&); -}; - -struct Incomplete; -extern Incomplete inc_obj; - -int main() -{ - { - // Test that we don't constrain the assignment operator in C++03 mode. - // Since we don't have access control SFINAE having pair evaluate SFINAE - // may cause a hard error. - typedef std::pair<int, NonAssignable> P; - static_assert(std::is_copy_assignable<P>::value, ""); - } - { - typedef std::pair<int, Incomplete&> P; - static_assert(std::is_copy_assignable<P>::value, ""); - P p(42, inc_obj); - assert(&p.second == &inc_obj); - } -} - -struct Incomplete {}; -Incomplete inc_obj; diff --git a/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp deleted file mode 100644 index f02e24b24140..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp +++ /dev/null @@ -1,96 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <utility> - -// template <class T1, class T2> struct pair - -// pair& operator=(pair&& p); - -#include <utility> -#include <memory> -#include <cassert> - - -struct NonAssignable { - NonAssignable& operator=(NonAssignable const&) = delete; - NonAssignable& operator=(NonAssignable&&) = delete; -}; -struct CopyAssignable { - CopyAssignable() = default; - CopyAssignable& operator=(CopyAssignable const&) = default; - CopyAssignable& operator=(CopyAssignable&&) = delete; -}; -struct MoveAssignable { - MoveAssignable() = default; - MoveAssignable& operator=(MoveAssignable const&) = delete; - MoveAssignable& operator=(MoveAssignable&&) = default; -}; - -struct CountAssign { - static int copied; - static int moved; - static void reset() { copied = moved = 0; } - CountAssign() = default; - CountAssign& operator=(CountAssign const&) { ++copied; return *this; } - CountAssign& operator=(CountAssign&&) { ++moved; return *this; } -}; -int CountAssign::copied = 0; -int CountAssign::moved = 0; - -int main() -{ - { - typedef std::pair<std::unique_ptr<int>, int> P; - P p1(std::unique_ptr<int>(new int(3)), 4); - P p2; - p2 = std::move(p1); - assert(*p2.first == 3); - assert(p2.second == 4); - } - { - using P = std::pair<int&, int&&>; - int x = 42; - int y = 101; - int x2 = -1; - int y2 = 300; - P p1(x, std::move(y)); - P p2(x2, std::move(y2)); - p1 = std::move(p2); - assert(p1.first == x2); - assert(p1.second == y2); - } - { - using P = std::pair<int, NonAssignable>; - static_assert(!std::is_move_assignable<P>::value, ""); - } - { - // The move decays to the copy constructor - CountAssign::reset(); - using P = std::pair<CountAssign, CopyAssignable>; - static_assert(std::is_move_assignable<P>::value, ""); - P p; - P p2; - p = std::move(p2); - assert(CountAssign::moved == 0); - assert(CountAssign::copied == 1); - } - { - CountAssign::reset(); - using P = std::pair<CountAssign, MoveAssignable>; - static_assert(std::is_move_assignable<P>::value, ""); - P p; - P p2; - p = std::move(p2); - assert(CountAssign::moved == 1); - assert(CountAssign::copied == 0); - } -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp deleted file mode 100644 index b7a89a84460d..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp +++ /dev/null @@ -1,59 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <utility> - -// template <class T1, class T2> struct pair - -// template<class U, class V> pair& operator=(pair<U, V>&& p); - -#include <utility> -#include <memory> -#include <cassert> -#include <archetypes.hpp> - -struct Base -{ - virtual ~Base() {} -}; - -struct Derived - : public Base -{ -}; - -int main() -{ - { - typedef std::pair<std::unique_ptr<Derived>, short> P1; - typedef std::pair<std::unique_ptr<Base>, long> P2; - P1 p1(std::unique_ptr<Derived>(), static_cast<short>(4)); - P2 p2; - p2 = std::move(p1); - assert(p2.first == nullptr); - assert(p2.second == 4); - } - { - using C = TestTypes::TestType; - using P = std::pair<int, C>; - using T = std::pair<long, C>; - T t(42, -42); - P p(101, 101); - C::reset_constructors(); - p = std::move(t); - assert(C::constructed == 0); - assert(C::assigned == 1); - assert(C::copy_assigned == 0); - assert(C::move_assigned == 1); - assert(p.first == 42); - assert(p.second.value == -42); - } -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp deleted file mode 100644 index bf19d1abe4c5..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp +++ /dev/null @@ -1,98 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <utility> - -// template <class T1, class T2> struct pair - -// pair(const T1& x, const T2& y); - -#include <utility> -#include <cassert> - -#include "archetypes.hpp" -#include "test_convertible.hpp" -using namespace ImplicitTypes; // Get implicitly archetypes - -struct ExplicitT { - constexpr explicit ExplicitT(int x) : value(x) {} - constexpr explicit ExplicitT(ExplicitT const& o) : value(o.value) {} - int value; -}; - -struct ImplicitT { - constexpr ImplicitT(int x) : value(x) {} - constexpr ImplicitT(ImplicitT const& o) : value(o.value) {} - int value; -}; - -template <class T1, - bool CanCopy = true, bool CanConvert = CanCopy> -void test_sfinae() { - using P1 = std::pair<T1, int>; - using P2 = std::pair<int, T1>; - using T1Arg = T1 const&; - using T2 = int const&; - static_assert(std::is_constructible<P1, T1Arg, T2>::value == CanCopy, ""); - static_assert(test_convertible<P1, T1Arg, T2>() == CanConvert, ""); - static_assert(std::is_constructible<P2, T2, T1Arg>::value == CanCopy, ""); - static_assert(test_convertible<P2, T2, T1Arg>() == CanConvert, ""); -} - -int main() -{ - { - typedef std::pair<float, short*> P; - P p(3.5f, 0); - assert(p.first == 3.5f); - assert(p.second == nullptr); - } - { - typedef std::pair<ImplicitT, int> P; - P p(1, 2); - assert(p.first.value == 1); - assert(p.second == 2); - } - { - test_sfinae<AllCtors>(); - test_sfinae<ExplicitTypes::AllCtors, true, false>(); - test_sfinae<CopyOnly>(); - test_sfinae<ExplicitTypes::CopyOnly, true, false>(); - test_sfinae<MoveOnly, false>(); - test_sfinae<ExplicitTypes::MoveOnly, false>(); - test_sfinae<NonCopyable, false>(); - test_sfinae<ExplicitTypes::NonCopyable, false>(); - } -#if TEST_STD_VER > 11 - { - typedef std::pair<float, short*> P; - constexpr P p(3.5f, 0); - static_assert(p.first == 3.5f, ""); - static_assert(p.second == nullptr, ""); - } - { - using P = std::pair<ExplicitT, int>; - constexpr ExplicitT e(42); - constexpr int x = 10; - constexpr P p(e, x); - static_assert(p.first.value == 42, ""); - static_assert(p.second == 10, ""); - } - { - using P = std::pair<ImplicitT, int>; - constexpr ImplicitT e(42); - constexpr int x = 10; - constexpr P p = {e, x}; - static_assert(p.first.value == 42, ""); - static_assert(p.second == 10, ""); - } -#endif -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/const_first_const_second_cxx03.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/const_first_const_second_cxx03.pass.cpp deleted file mode 100644 index 8c56c2003460..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/const_first_const_second_cxx03.pass.cpp +++ /dev/null @@ -1,42 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// pair(const T1& x, const T2& y); - -#include <utility> -#include <cassert> - -class A -{ - int data_; -public: - A(int data) : data_(data) {} - - bool operator==(const A& a) const {return data_ == a.data_;} -}; - -int main() -{ - { - typedef std::pair<float, short*> P; - P p(3.5f, 0); - assert(p.first == 3.5f); - assert(p.second == nullptr); - } - { - typedef std::pair<A, int> P; - P p(1, 2); - assert(p.first == A(1)); - assert(p.second == 2); - } -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp deleted file mode 100644 index d2cb6b10984e..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp +++ /dev/null @@ -1,181 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <utility> - -// template <class T1, class T2> struct pair - -// template <class U, class V> EXPLICIT constexpr pair(const pair<U, V>& p); - -#include <utility> -#include <cassert> - -#include "archetypes.hpp" -#include "test_convertible.hpp" -using namespace ImplicitTypes; // Get implicitly archetypes - -template <class T1, class U1, - bool CanCopy = true, bool CanConvert = CanCopy> -void test_pair_const() -{ - using P1 = std::pair<T1, int>; - using P2 = std::pair<int, T1>; - using UP1 = std::pair<U1, int> const&; - using UP2 = std::pair<int, U1> const&; - static_assert(std::is_constructible<P1, UP1>::value == CanCopy, ""); - static_assert(test_convertible<P1, UP1>() == CanConvert, ""); - static_assert(std::is_constructible<P2, UP2>::value == CanCopy, ""); - static_assert(test_convertible<P2, UP2>() == CanConvert, ""); -} - -template <class T, class U> -struct DPair : public std::pair<T, U> { - using Base = std::pair<T, U>; - using Base::Base; -}; - -struct ExplicitT { - constexpr explicit ExplicitT(int x) : value(x) {} - constexpr explicit ExplicitT(ExplicitT const& o) : value(o.value) {} - int value; -}; - -struct ImplicitT { - constexpr ImplicitT(int x) : value(x) {} - constexpr ImplicitT(ImplicitT const& o) : value(o.value) {} - int value; -}; - -int main() -{ - { - typedef std::pair<int, int> P1; - typedef std::pair<double, long> P2; - const P1 p1(3, 4); - const P2 p2 = p1; - assert(p2.first == 3); - assert(p2.second == 4); - } - { - // We allow derived types to use this constructor - using P1 = DPair<long, long>; - using P2 = std::pair<int, int>; - P1 p1(42, 101); - P2 p2(p1); - assert(p2.first == 42); - assert(p2.second == 101); - } - { - test_pair_const<AllCtors, AllCtors>(); // copy construction - test_pair_const<AllCtors, AllCtors&>(); - test_pair_const<AllCtors, AllCtors&&>(); - test_pair_const<AllCtors, const AllCtors&>(); - test_pair_const<AllCtors, const AllCtors&&>(); - - test_pair_const<ExplicitTypes::AllCtors, ExplicitTypes::AllCtors>(); // copy construction - test_pair_const<ExplicitTypes::AllCtors, ExplicitTypes::AllCtors&, true, false>(); - test_pair_const<ExplicitTypes::AllCtors, ExplicitTypes::AllCtors&&, true, false>(); - test_pair_const<ExplicitTypes::AllCtors, const ExplicitTypes::AllCtors&, true, false>(); - test_pair_const<ExplicitTypes::AllCtors, const ExplicitTypes::AllCtors&&, true, false>(); - - test_pair_const<MoveOnly, MoveOnly, false>(); // copy construction - test_pair_const<MoveOnly, MoveOnly&, false>(); - test_pair_const<MoveOnly, MoveOnly&&, false>(); - - test_pair_const<ExplicitTypes::MoveOnly, ExplicitTypes::MoveOnly, false>(); // copy construction - test_pair_const<ExplicitTypes::MoveOnly, ExplicitTypes::MoveOnly&, false>(); - test_pair_const<ExplicitTypes::MoveOnly, ExplicitTypes::MoveOnly&&, false>(); - - test_pair_const<CopyOnly, CopyOnly>(); - test_pair_const<CopyOnly, CopyOnly&>(); - test_pair_const<CopyOnly, CopyOnly&&>(); - - test_pair_const<ExplicitTypes::CopyOnly, ExplicitTypes::CopyOnly>(); - test_pair_const<ExplicitTypes::CopyOnly, ExplicitTypes::CopyOnly&, true, false>(); - test_pair_const<ExplicitTypes::CopyOnly, ExplicitTypes::CopyOnly&&, true, false>(); - - test_pair_const<NonCopyable, NonCopyable, false>(); - test_pair_const<NonCopyable, NonCopyable&, false>(); - test_pair_const<NonCopyable, NonCopyable&&, false>(); - test_pair_const<NonCopyable, const NonCopyable&, false>(); - test_pair_const<NonCopyable, const NonCopyable&&, false>(); - } - - { // Test construction of references - test_pair_const<NonCopyable&, NonCopyable&>(); - test_pair_const<NonCopyable&, NonCopyable&&>(); - test_pair_const<NonCopyable&, NonCopyable const&, false>(); - test_pair_const<NonCopyable const&, NonCopyable&&>(); - test_pair_const<NonCopyable&&, NonCopyable&&, false>(); - - test_pair_const<ConvertingType&, int, false>(); - test_pair_const<ExplicitTypes::ConvertingType&, int, false>(); - // Unfortunately the below conversions are allowed and create dangling - // references. - //test_pair_const<ConvertingType&&, int>(); - //test_pair_const<ConvertingType const&, int>(); - //test_pair_const<ConvertingType const&&, int>(); - // But these are not because the converting constructor is explicit. - test_pair_const<ExplicitTypes::ConvertingType&&, int, false>(); - test_pair_const<ExplicitTypes::ConvertingType const&, int, false>(); - test_pair_const<ExplicitTypes::ConvertingType const&&, int, false>(); - - } - { - test_pair_const<AllCtors, int, false>(); - test_pair_const<ExplicitTypes::AllCtors, int, false>(); - test_pair_const<ConvertingType, int>(); - test_pair_const<ExplicitTypes::ConvertingType, int, true, false>(); - - test_pair_const<ConvertingType, int>(); - test_pair_const<ConvertingType, ConvertingType>(); - test_pair_const<ConvertingType, ConvertingType const&>(); - test_pair_const<ConvertingType, ConvertingType&>(); - test_pair_const<ConvertingType, ConvertingType&&>(); - - test_pair_const<ExplicitTypes::ConvertingType, int, true, false>(); - test_pair_const<ExplicitTypes::ConvertingType, int&, true, false>(); - test_pair_const<ExplicitTypes::ConvertingType, const int&, true, false>(); - test_pair_const<ExplicitTypes::ConvertingType, int&&, true, false>(); - test_pair_const<ExplicitTypes::ConvertingType, const int&&, true, false>(); - - test_pair_const<ExplicitTypes::ConvertingType, ExplicitTypes::ConvertingType>(); - test_pair_const<ExplicitTypes::ConvertingType, ExplicitTypes::ConvertingType const&, true, false>(); - test_pair_const<ExplicitTypes::ConvertingType, ExplicitTypes::ConvertingType&, true, false>(); - test_pair_const<ExplicitTypes::ConvertingType, ExplicitTypes::ConvertingType&&, true, false>(); - } -#if TEST_STD_VER > 11 - { - typedef std::pair<int, int> P1; - typedef std::pair<double, long> P2; - constexpr P1 p1(3, 4); - constexpr P2 p2 = p1; - static_assert(p2.first == 3, ""); - static_assert(p2.second == 4, ""); - } - { - using P1 = std::pair<int, int>; - using P2 = std::pair<ExplicitT, ExplicitT>; - constexpr P1 p1(42, 101); - constexpr P2 p2(p1); - static_assert(p2.first.value == 42, ""); - static_assert(p2.second.value == 101, ""); - } - { - using P1 = std::pair<int, int>; - using P2 = std::pair<ImplicitT, ImplicitT>; - constexpr P1 p1(42, 101); - constexpr P2 p2 = p1; - static_assert(p2.first.value == 42, ""); - static_assert(p2.second.value == 101, ""); - } -#endif -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V_cxx03.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V_cxx03.pass.cpp deleted file mode 100644 index fbf461f9b7e0..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V_cxx03.pass.cpp +++ /dev/null @@ -1,29 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// template <class U, class V> pair(const pair<U, V>& p); - -#include <utility> -#include <cassert> - -int main() -{ - { - typedef std::pair<int, short> P1; - typedef std::pair<double, long> P2; - const P1 p1(3, static_cast<short>(4)); - const P2 p2 = p1; - assert(p2.first == 3); - assert(p2.second == 4); - } -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp deleted file mode 100644 index 1003f3c8b68f..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp +++ /dev/null @@ -1,39 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// pair(const pair&) = default; - -#include <utility> -#include <cassert> - -#include "test_macros.h" - -int main() -{ - { - typedef std::pair<int, short> P1; - P1 p1(3, static_cast<short>(4)); - P1 p2 = p1; - assert(p2.first == 3); - assert(p2.second == 4); - } -#if TEST_STD_VER > 11 - { - typedef std::pair<int, short> P1; - constexpr P1 p1(3, static_cast<short>(4)); - constexpr P1 p2 = p1; - static_assert(p2.first == 3, ""); - static_assert(p2.second == 4, ""); - } -#endif -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp deleted file mode 100644 index d5e1e232f86f..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp +++ /dev/null @@ -1,164 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// Test the SFINAE required by LWG Issue #2367. -// is_default_constructible<pair> - -// UNSUPPORTED: c++98, c++03 - -#include <utility> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" - -#if TEST_STD_VER > 11 -#define CONSTEXPR_CXX14 constexpr -#define STATIC_ASSERT_CXX14(Pred) static_assert(Pred, "") -#else -#define CONSTEXPR_CXX14 -#define STATIC_ASSERT_CXX14(Pred) assert(Pred) -#endif - -struct DeletedDefault { - // A class with a deleted default constructor. Used to test the SFINAE - // on std::pair's default constructor. - constexpr explicit DeletedDefault(int x) : value(x) {} - constexpr DeletedDefault() = delete; - int value; -}; - -template <class Tp, bool> -struct DependantType: public Tp {}; - -template <class T, bool Val> -using DependantIsDefault = DependantType<std::is_default_constructible<T>, Val>; - -template <class T> -struct DefaultSFINAES { - template <bool Dummy = false, class = typename std::enable_if< - DependantIsDefault<T, Dummy>::value - >::type - > - constexpr DefaultSFINAES() : value() {} - constexpr explicit DefaultSFINAES(T const& x) : value(x) {} - T value; -}; - -struct NoDefault { - constexpr NoDefault(int v) : value(v) {} - int value; -}; - -template <class Tp> -void test_not_is_default_constructible() -{ - { - typedef std::pair<int, Tp> P; - static_assert(!std::is_default_constructible<P>::value, ""); - static_assert(std::is_constructible<P, int, Tp>::value, ""); - } - { - typedef std::pair<Tp, int> P; - static_assert(!std::is_default_constructible<P>::value, ""); - static_assert(std::is_constructible<P, Tp, int>::value, ""); - } - { - typedef std::pair<Tp, Tp> P; - static_assert(!std::is_default_constructible<P>::value, ""); - static_assert(std::is_constructible<P, Tp, Tp>::value, ""); - } -} - -template <class Tp> -void test_is_default_constructible() -{ - { - typedef std::pair<int, Tp> P; - static_assert(std::is_default_constructible<P>::value, ""); - } - { - typedef std::pair<Tp, int> P; - static_assert(std::is_default_constructible<P>::value, ""); - } - { - typedef std::pair<Tp, Tp> P; - static_assert(std::is_default_constructible<P>::value, ""); - } -} - -template <class T> -struct IllFormedDefaultImp { - constexpr explicit IllFormedDefaultImp(int v) : value(v) {} - constexpr IllFormedDefaultImp() : value(T::DoesNotExistAndShouldNotCompile) {} - int value; -}; - -typedef IllFormedDefaultImp<int> IllFormedDefault; - // A class which provides a constexpr default constructor with a valid - // signature but an ill-formed body. The A compile error will be emitted if - // the default constructor is instantiated. - - -// Check that the SFINAE on the default constructor is not evaluated when -// it isn't needed. If the default constructor of 'IllFormedDefault' is evaluated -// in C++11, even with is_default_constructible, then this test should fail to -// compile. In C++14 and greater evaluate each test is evaluated as a constant -// expression. -// See LWG issue #2367 -void test_illformed_default() -{ - { - typedef std::pair<IllFormedDefault, int> P; - static_assert((std::is_constructible<P, IllFormedDefault, int>::value), ""); - CONSTEXPR_CXX14 P p(IllFormedDefault(42), -5); - STATIC_ASSERT_CXX14(p.first.value == 42 && p.second == -5); - } - { - typedef std::pair<int, IllFormedDefault> P; - static_assert((std::is_constructible<P, int, IllFormedDefault>::value), ""); - CONSTEXPR_CXX14 IllFormedDefault dd(-5); - CONSTEXPR_CXX14 P p(42, dd); - STATIC_ASSERT_CXX14(p.first == 42 && p.second.value == -5); - } - { - typedef std::pair<IllFormedDefault, IllFormedDefault> P; - static_assert((std::is_constructible<P, IllFormedDefault, IllFormedDefault>::value), ""); - CONSTEXPR_CXX14 P p(IllFormedDefault(42), IllFormedDefault(-5)); - STATIC_ASSERT_CXX14(p.first.value == 42 && p.second.value == -5); - } -} - - -int main() -{ - { - // Check that pair<T, U> can still be used even if - // is_default_constructible<T> or is_default_constructible<U> cause - // a compilation error. - test_illformed_default(); - } - { - // pair::pair() is only disable in C++11 and beyond. - test_not_is_default_constructible<NoDefault>(); - test_not_is_default_constructible<DeletedDefault>(); - test_not_is_default_constructible<DefaultSFINAES<int&>>(); - test_not_is_default_constructible<DefaultSFINAES<int&&>>(); - test_not_is_default_constructible<int&>(); - test_not_is_default_constructible<int&&>(); - } - { - test_is_default_constructible<int>(); - test_is_default_constructible<DefaultSFINAES<int>>(); - } -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp deleted file mode 100644 index af91abe74e1e..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp +++ /dev/null @@ -1,55 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// constexpr pair(); - -// This test doesn't pass due to a constexpr bug in GCC 4.9 that fails -// to initialize any type without a user provided constructor in a constant -// expression (e.g. float). -// XFAIL: gcc-4.9 - -// NOTE: The SFINAE on the default constructor is tested in -// default-sfinae.pass.cpp - - -#include <utility> -#include <type_traits> -#include <cassert> - -#include "test_macros.h" -#include "archetypes.hpp" - -int main() -{ - { - typedef std::pair<float, short*> P; - P p; - assert(p.first == 0.0f); - assert(p.second == nullptr); - } -#if TEST_STD_VER >= 11 - { - typedef std::pair<float, short*> P; - constexpr P p; - static_assert(p.first == 0.0f, ""); - static_assert(p.second == nullptr, ""); - } - { - using NoDefault = ImplicitTypes::NoDefault; - using P = std::pair<int, NoDefault>; - static_assert(!std::is_default_constructible<P>::value, ""); - using P2 = std::pair<NoDefault, int>; - static_assert(!std::is_default_constructible<P2>::value, ""); - } -#endif -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp deleted file mode 100644 index b25099f4d2e8..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp +++ /dev/null @@ -1,36 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <utility> - -// template <class T1, class T2> struct pair - -// ~pair() - -// C++17 added: -// The destructor of pair shall be a trivial destructor -// if (is_trivially_destructible_v<T1> && is_trivially_destructible_v<T2>) is true. - - -#include <utility> -#include <type_traits> -#include <string> -#include <cassert> - -#include "test_macros.h" - -int main() -{ - static_assert((std::is_trivially_destructible< - std::pair<int, float> >::value), ""); - static_assert((!std::is_trivially_destructible< - std::pair<int, std::string> >::value), ""); -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/implicit_deduction_guides.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/implicit_deduction_guides.pass.cpp deleted file mode 100644 index 7933dd99c1f4..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/implicit_deduction_guides.pass.cpp +++ /dev/null @@ -1,80 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11, c++14 -// UNSUPPORTED: libcpp-no-deduction-guides - -// GCC's implementation of class template deduction is still immature and runs -// into issues with libc++. However GCC accepts this code when compiling -// against libstdc++. -// XFAIL: gcc - -// <utility> - -// Test that the constructors offered by std::pair are formulated -// so they're compatible with implicit deduction guides, or if that's not -// possible that they provide explicit guides to make it work. - -#include <utility> -#include <memory> -#include <string> -#include <cassert> - -#include "test_macros.h" -#include "archetypes.hpp" - - -// Overloads -// --------------- -// (1) pair(const T1&, const T2&) -> pair<T1, T2> -// (2) explicit pair(const T1&, const T2&) -> pair<T1, T2> -// (3) pair(pair const& t) -> decltype(t) -// (4) pair(pair&& t) -> decltype(t) -// (5) pair(pair<U1, U2> const&) -> pair<U1, U2> -// (6) explicit pair(pair<U1, U2> const&) -> pair<U1, U2> -// (7) pair(pair<U1, U2> &&) -> pair<U1, U2> -// (8) explicit pair(pair<U1, U2> &&) -> pair<U1, U2> -int main() -{ - using E = ExplicitTestTypes::TestType; - static_assert(!std::is_convertible<E const&, E>::value, ""); - { // Testing (1) - int const x = 42; - std::pair t1("abc", x); - ASSERT_SAME_TYPE(decltype(t1), std::pair<const char*, int>); - } - { // Testing (2) - std::pair p1(E{}, 42); - ASSERT_SAME_TYPE(decltype(p1), std::pair<E, int>); - - const E t{}; - std::pair p2(t, E{}); - ASSERT_SAME_TYPE(decltype(p2), std::pair<E, E>); - } - { // Testing (3, 5) - std::pair<double, decltype(nullptr)> const p(0.0, nullptr); - std::pair p1(p); - ASSERT_SAME_TYPE(decltype(p1), std::pair<double, decltype(nullptr)>); - } - { // Testing (3, 6) - std::pair<E, decltype(nullptr)> const p(E{}, nullptr); - std::pair p1(p); - ASSERT_SAME_TYPE(decltype(p1), std::pair<E, decltype(nullptr)>); - } - { // Testing (4, 7) - std::pair<std::string, void*> p("abc", nullptr); - std::pair p1(std::move(p)); - ASSERT_SAME_TYPE(decltype(p1), std::pair<std::string, void*>); - } - { // Testing (4, 8) - std::pair<std::string, E> p("abc", E{}); - std::pair p1(std::move(p)); - ASSERT_SAME_TYPE(decltype(p1), std::pair<std::string, E>); - } -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/move_ctor.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/move_ctor.pass.cpp deleted file mode 100644 index 99e00b025da2..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/move_ctor.pass.cpp +++ /dev/null @@ -1,44 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <utility> - -// template <class T1, class T2> struct pair - -// pair(pair&&) = default; - -#include <utility> -#include <memory> -#include <cassert> - -#include "test_macros.h" - -struct Dummy { - Dummy(Dummy const&) = delete; - Dummy(Dummy &&) = default; -}; - -int main() -{ - { - typedef std::pair<int, short> P1; - static_assert(std::is_move_constructible<P1>::value, ""); - P1 p1(3, static_cast<short>(4)); - P1 p2 = std::move(p1); - assert(p2.first == 3); - assert(p2.second == 4); - } - { - using P = std::pair<Dummy, int>; - static_assert(!std::is_copy_constructible<P>::value, ""); - static_assert(std::is_move_constructible<P>::value, ""); - } -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/not_constexpr_cxx11.fail.cpp b/test/std/utilities/utility/pairs/pairs.pair/not_constexpr_cxx11.fail.cpp deleted file mode 100644 index 3704dcc32edc..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/not_constexpr_cxx11.fail.cpp +++ /dev/null @@ -1,57 +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. -// -//===----------------------------------------------------------------------===// - -// REQUIRES: c++11 - -// <utility> - -// Test that only the default constructor is constexpr in C++11 - -#include <utility> -#include <cassert> - -struct ExplicitT { - constexpr explicit ExplicitT(int x) : value(x) {} - constexpr explicit ExplicitT(ExplicitT const& o) : value(o.value) {} - int value; -}; - -struct ImplicitT { - constexpr ImplicitT(int x) : value(x) {} - constexpr ImplicitT(ImplicitT const& o) : value(o.value) {} - int value; -}; - -int main() -{ - { - using P = std::pair<int, int>; - constexpr int x = 42; - constexpr P default_p{}; - constexpr P copy_p(default_p); - constexpr P const_U_V(x, x); // expected-error {{must be initialized by a constant expression}} - constexpr P U_V(42, 101); // expected-error {{must be initialized by a constant expression}} - } - { - using P = std::pair<ExplicitT, ExplicitT>; - constexpr std::pair<int, int> other; - constexpr ExplicitT e(99); - constexpr P const_U_V(e, e); // expected-error {{must be initialized by a constant expression}} - constexpr P U_V(42, 101); // expected-error {{must be initialized by a constant expression}} - constexpr P pair_U_V(other); // expected-error {{must be initialized by a constant expression}} - } - { - using P = std::pair<ImplicitT, ImplicitT>; - constexpr std::pair<int, int> other; - constexpr ImplicitT i = 99; - constexpr P const_U_V = {i, i}; // expected-error {{must be initialized by a constant expression}} - constexpr P U_V = {42, 101}; // expected-error {{must be initialized by a constant expression}} - constexpr P pair_U_V = other; // expected-error {{must be initialized by a constant expression}} - } -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp deleted file mode 100644 index aa86949dd5b3..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp +++ /dev/null @@ -1,36 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <utility> - -// template <class T1, class T2> struct pair - -// template <class... Args1, class... Args2> -// pair(piecewise_construct_t, tuple<Args1...> first_args, -// tuple<Args2...> second_args); - -#include <cassert> -#include <tuple> -#include <utility> - - -int main() -{ - { - typedef std::pair<int, int*> P1; - typedef std::pair<int*, int> P2; - typedef std::pair<P1, P2> P3; - P3 p3(std::piecewise_construct, std::tuple<int, int*>(3, nullptr), - std::tuple<int*, int>(nullptr, 4)); - assert(p3.first == P1(3, nullptr)); - assert(p3.second == P2(nullptr, 4)); - } -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp deleted file mode 100644 index 7e40bed21820..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp +++ /dev/null @@ -1,177 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <utility> - -// template <class T1, class T2> struct pair - -// template <class U, class V> pair(pair<U, V>&& p); - -#include <utility> -#include <memory> -#include <cassert> - -#include "archetypes.hpp" -#include "test_convertible.hpp" -using namespace ImplicitTypes; // Get implicitly archetypes - -template <class T1, class U1, - bool CanCopy = true, bool CanConvert = CanCopy> -void test_pair_rv() -{ - using P1 = std::pair<T1, int>; - using P2 = std::pair<int, T1>; - using UP1 = std::pair<U1, int>&&; - using UP2 = std::pair<int, U1>&&; - static_assert(std::is_constructible<P1, UP1>::value == CanCopy, ""); - static_assert(test_convertible<P1, UP1>() == CanConvert, ""); - static_assert(std::is_constructible<P2, UP2>::value == CanCopy, ""); - static_assert(test_convertible<P2, UP2>() == CanConvert, ""); -} - -struct Base -{ - virtual ~Base() {} -}; - -struct Derived - : public Base -{ -}; - - -template <class T, class U> -struct DPair : public std::pair<T, U> { - using Base = std::pair<T, U>; - using Base::Base; -}; - -struct ExplicitT { - constexpr explicit ExplicitT(int x) : value(x) {} - int value; -}; - -struct ImplicitT { - constexpr ImplicitT(int x) : value(x) {} - int value; -}; - -int main() -{ - { - typedef std::pair<std::unique_ptr<Derived>, int> P1; - typedef std::pair<std::unique_ptr<Base>, long> P2; - P1 p1(std::unique_ptr<Derived>(), 4); - P2 p2 = std::move(p1); - assert(p2.first == nullptr); - assert(p2.second == 4); - } - { - // We allow derived types to use this constructor - using P1 = DPair<long, long>; - using P2 = std::pair<int, int>; - P1 p1(42, 101); - P2 p2(std::move(p1)); - assert(p2.first == 42); - assert(p2.second == 101); - } - { - test_pair_rv<AllCtors, AllCtors>(); - test_pair_rv<AllCtors, AllCtors&>(); - test_pair_rv<AllCtors, AllCtors&&>(); - test_pair_rv<AllCtors, const AllCtors&>(); - test_pair_rv<AllCtors, const AllCtors&&>(); - - test_pair_rv<ExplicitTypes::AllCtors, ExplicitTypes::AllCtors>(); - test_pair_rv<ExplicitTypes::AllCtors, ExplicitTypes::AllCtors&, true, false>(); - test_pair_rv<ExplicitTypes::AllCtors, ExplicitTypes::AllCtors&&, true, false>(); - test_pair_rv<ExplicitTypes::AllCtors, const ExplicitTypes::AllCtors&, true, false>(); - test_pair_rv<ExplicitTypes::AllCtors, const ExplicitTypes::AllCtors&&, true, false>(); - - test_pair_rv<MoveOnly, MoveOnly>(); - test_pair_rv<MoveOnly, MoveOnly&, false>(); - test_pair_rv<MoveOnly, MoveOnly&&>(); - - test_pair_rv<ExplicitTypes::MoveOnly, ExplicitTypes::MoveOnly>(); // copy construction - test_pair_rv<ExplicitTypes::MoveOnly, ExplicitTypes::MoveOnly&, false>(); - test_pair_rv<ExplicitTypes::MoveOnly, ExplicitTypes::MoveOnly&&, true, false>(); - - test_pair_rv<CopyOnly, CopyOnly>(); - test_pair_rv<CopyOnly, CopyOnly&>(); - test_pair_rv<CopyOnly, CopyOnly&&>(); - - test_pair_rv<ExplicitTypes::CopyOnly, ExplicitTypes::CopyOnly>(); - test_pair_rv<ExplicitTypes::CopyOnly, ExplicitTypes::CopyOnly&, true, false>(); - test_pair_rv<ExplicitTypes::CopyOnly, ExplicitTypes::CopyOnly&&, true, false>(); - - test_pair_rv<NonCopyable, NonCopyable, false>(); - test_pair_rv<NonCopyable, NonCopyable&, false>(); - test_pair_rv<NonCopyable, NonCopyable&&, false>(); - test_pair_rv<NonCopyable, const NonCopyable&, false>(); - test_pair_rv<NonCopyable, const NonCopyable&&, false>(); - } - { // Test construction of references - test_pair_rv<NonCopyable&, NonCopyable&>(); - test_pair_rv<NonCopyable&, NonCopyable&&>(); - test_pair_rv<NonCopyable&, NonCopyable const&, false>(); - test_pair_rv<NonCopyable const&, NonCopyable&&>(); - test_pair_rv<NonCopyable&&, NonCopyable&&>(); - - test_pair_rv<ConvertingType&, int, false>(); - test_pair_rv<ExplicitTypes::ConvertingType&, int, false>(); - // Unfortunately the below conversions are allowed and create dangling - // references. - //test_pair_rv<ConvertingType&&, int>(); - //test_pair_rv<ConvertingType const&, int>(); - //test_pair_rv<ConvertingType const&&, int>(); - // But these are not because the converting constructor is explicit. - test_pair_rv<ExplicitTypes::ConvertingType&&, int, false>(); - test_pair_rv<ExplicitTypes::ConvertingType const&, int, false>(); - test_pair_rv<ExplicitTypes::ConvertingType const&&, int, false>(); - } - { - test_pair_rv<AllCtors, int, false>(); - test_pair_rv<ExplicitTypes::AllCtors, int, false>(); - test_pair_rv<ConvertingType, int>(); - test_pair_rv<ExplicitTypes::ConvertingType, int, true, false>(); - - test_pair_rv<ConvertingType, int>(); - test_pair_rv<ConvertingType, ConvertingType>(); - test_pair_rv<ConvertingType, ConvertingType const&>(); - test_pair_rv<ConvertingType, ConvertingType&>(); - test_pair_rv<ConvertingType, ConvertingType&&>(); - - test_pair_rv<ExplicitTypes::ConvertingType, int, true, false>(); - test_pair_rv<ExplicitTypes::ConvertingType, int&, true, false>(); - test_pair_rv<ExplicitTypes::ConvertingType, const int&, true, false>(); - test_pair_rv<ExplicitTypes::ConvertingType, int&&, true, false>(); - test_pair_rv<ExplicitTypes::ConvertingType, const int&&, true, false>(); - - test_pair_rv<ExplicitTypes::ConvertingType, ExplicitTypes::ConvertingType>(); - test_pair_rv<ExplicitTypes::ConvertingType, ExplicitTypes::ConvertingType const&, true, false>(); - test_pair_rv<ExplicitTypes::ConvertingType, ExplicitTypes::ConvertingType&, true, false>(); - test_pair_rv<ExplicitTypes::ConvertingType, ExplicitTypes::ConvertingType&&, true, false>(); - } -#if TEST_STD_VER > 11 - { // explicit constexpr test - constexpr std::pair<int, int> p1(42, 43); - constexpr std::pair<ExplicitT, ExplicitT> p2(std::move(p1)); - static_assert(p2.first.value == 42, ""); - static_assert(p2.second.value == 43, ""); - } - { // implicit constexpr test - constexpr std::pair<int, int> p1(42, 43); - constexpr std::pair<ImplicitT, ImplicitT> p2 = std::move(p1); - static_assert(p2.first.value == 42, ""); - static_assert(p2.second.value == 43, ""); - } -#endif -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/special_member_generation_test.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/special_member_generation_test.pass.cpp deleted file mode 100644 index 1331a3153641..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/special_member_generation_test.pass.cpp +++ /dev/null @@ -1,127 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <utility> - -// template <class T, class U> struct pair; - -// pair(pair const&) = default; -// pair(pair &&) = default; -// pair& operator=(pair const&); -// pair& operator=(pair&&); - -// Test that the copy/move constructors and assignment operators are -// correctly defined or deleted based on the properties of `T` and `U`. - -#include <cassert> -#include <string> -#include <tuple> - -#include "archetypes.hpp" -using namespace ImplicitTypes; // Get implicitly archetypes - -namespace ConstructorTest { - -template <class T1, bool CanCopy = true, bool CanMove = CanCopy> void test() { - using P1 = std::pair<T1, int>; - using P2 = std::pair<int, T1>; - static_assert(std::is_copy_constructible<P1>::value == CanCopy, ""); - static_assert(std::is_move_constructible<P1>::value == CanMove, ""); - static_assert(std::is_copy_constructible<P2>::value == CanCopy, ""); - static_assert(std::is_move_constructible<P2>::value == CanMove, ""); -}; - -} // namespace ConstructorTest - -void test_constructors_exist() { - using namespace ConstructorTest; - { - test<int>(); - test<int &>(); - test<int &&, false, true>(); - test<const int>(); - test<const int &>(); - test<const int &&, false, true>(); - } - { - test<Copyable>(); - test<Copyable &>(); - test<Copyable &&, false, true>(); - } - { - test<NonCopyable, false>(); - test<NonCopyable &, true>(); - test<NonCopyable &&, false, true>(); - } - { - // Even though CopyOnly has an explicitly deleted move constructor - // pair's move constructor is only implicitly deleted and therefore - // it doesn't participate in overload resolution. - test<CopyOnly, true, true>(); - test<CopyOnly &, true>(); - test<CopyOnly &&, false, true>(); - } - { - test<MoveOnly, false, true>(); - test<MoveOnly &, true>(); - test<MoveOnly &&, false, true>(); - } -} - -namespace AssignmentOperatorTest { - -template <class T1, bool CanCopy = true, bool CanMove = CanCopy> void test() { - using P1 = std::pair<T1, int>; - using P2 = std::pair<int, T1>; - static_assert(std::is_copy_assignable<P1>::value == CanCopy, ""); - static_assert(std::is_move_assignable<P1>::value == CanMove, ""); - static_assert(std::is_copy_assignable<P2>::value == CanCopy, ""); - static_assert(std::is_move_assignable<P2>::value == CanMove, ""); -}; - -} // namespace AssignmentOperatorTest - -void test_assignment_operator_exists() { - using namespace AssignmentOperatorTest; - { - test<int>(); - test<int &>(); - test<int &&>(); - test<const int, false>(); - test<const int &, false>(); - test<const int &&, false>(); - } - { - test<Copyable>(); - test<Copyable &>(); - test<Copyable &&>(); - } - { - test<NonCopyable, false>(); - test<NonCopyable &, false>(); - test<NonCopyable &&, false>(); - } - { - test<CopyOnly, true>(); - test<CopyOnly &, true>(); - test<CopyOnly &&, true>(); - } - { - test<MoveOnly, false, true>(); - test<MoveOnly &, false, false>(); - test<MoveOnly &&, false, true>(); - } -} - -int main() { - test_constructors_exist(); - test_assignment_operator_exists(); -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp deleted file mode 100644 index 95b1f66d64aa..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp +++ /dev/null @@ -1,50 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// void swap(pair& p); - -#include <utility> -#include <cassert> - -struct S { - int i; - S() : i(0) {} - S(int j) : i(j) {} - S * operator& () { assert(false); return this; } - S const * operator& () const { assert(false); return this; } - bool operator==(int x) const { return i == x; } - }; - -int main() -{ - { - typedef std::pair<int, short> P1; - P1 p1(3, static_cast<short>(4)); - P1 p2(5, static_cast<short>(6)); - p1.swap(p2); - assert(p1.first == 5); - assert(p1.second == 6); - assert(p2.first == 3); - assert(p2.second == 4); - } - { - typedef std::pair<int, S> P1; - P1 p1(3, S(4)); - P1 p2(5, S(6)); - p1.swap(p2); - assert(p1.first == 5); - assert(p1.second == 6); - assert(p2.first == 3); - assert(p2.second == 4); - } -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/trivial_copy_move.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/trivial_copy_move.pass.cpp deleted file mode 100644 index 200f044c6359..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/trivial_copy_move.pass.cpp +++ /dev/null @@ -1,56 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// pair(pair const&) = default; -// pair(pair&&) = default; - -// Doesn't pass due to use of is_trivially_* trait. -// XFAIL: gcc-4.9 - -#include <utility> -#include <cassert> - -#include "test_macros.h" - -struct Dummy { - Dummy(Dummy const&) = delete; - Dummy(Dummy &&) = default; -}; - -int main() -{ - typedef std::pair<int, short> P; - { - static_assert(std::is_copy_constructible<P>::value, ""); -#if !defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) - static_assert(std::is_trivially_copy_constructible<P>::value, ""); -#endif - } -#if TEST_STD_VER >= 11 - { - static_assert(std::is_move_constructible<P>::value, ""); -#if !defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) - static_assert(std::is_trivially_move_constructible<P>::value, ""); -#endif - } - { - using P1 = std::pair<Dummy, int>; - static_assert(!std::is_copy_constructible<P1>::value, ""); - static_assert(!std::is_trivially_copy_constructible<P1>::value, ""); - static_assert(std::is_move_constructible<P1>::value, ""); -#if !defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) - static_assert(std::is_trivially_move_constructible<P1>::value, ""); -#endif - } -#endif -} diff --git a/test/std/utilities/utility/pairs/pairs.pair/types.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/types.pass.cpp deleted file mode 100644 index c16bd71ffcb2..000000000000 --- a/test/std/utilities/utility/pairs/pairs.pair/types.pass.cpp +++ /dev/null @@ -1,26 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> -// struct pair -// { -// typedef T1 first_type; -// typedef T2 second_type; - -#include <utility> -#include <type_traits> - -int main() -{ - typedef std::pair<float, short*> P; - static_assert((std::is_same<P::first_type, float>::value), ""); - static_assert((std::is_same<P::second_type, short*>::value), ""); -} diff --git a/test/std/utilities/utility/pairs/pairs.spec/comparison.pass.cpp b/test/std/utilities/utility/pairs/pairs.spec/comparison.pass.cpp deleted file mode 100644 index 3b994dfd4dfe..000000000000 --- a/test/std/utilities/utility/pairs/pairs.spec/comparison.pass.cpp +++ /dev/null @@ -1,97 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); -// template <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&); -// template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&); -// template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&); -// template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&); -// template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&); - -#include <utility> -#include <cassert> - -#include "test_macros.h" - -int main() -{ - { - typedef std::pair<int, short> P; - P p1(3, static_cast<short>(4)); - P p2(3, static_cast<short>(4)); - assert( (p1 == p2)); - assert(!(p1 != p2)); - assert(!(p1 < p2)); - assert( (p1 <= p2)); - assert(!(p1 > p2)); - assert( (p1 >= p2)); - } - { - typedef std::pair<int, short> P; - P p1(2, static_cast<short>(4)); - P p2(3, static_cast<short>(4)); - assert(!(p1 == p2)); - assert( (p1 != p2)); - assert( (p1 < p2)); - assert( (p1 <= p2)); - assert(!(p1 > p2)); - assert(!(p1 >= p2)); - } - { - typedef std::pair<int, short> P; - P p1(3, static_cast<short>(2)); - P p2(3, static_cast<short>(4)); - assert(!(p1 == p2)); - assert( (p1 != p2)); - assert( (p1 < p2)); - assert( (p1 <= p2)); - assert(!(p1 > p2)); - assert(!(p1 >= p2)); - } - { - typedef std::pair<int, short> P; - P p1(3, static_cast<short>(4)); - P p2(2, static_cast<short>(4)); - assert(!(p1 == p2)); - assert( (p1 != p2)); - assert(!(p1 < p2)); - assert(!(p1 <= p2)); - assert( (p1 > p2)); - assert( (p1 >= p2)); - } - { - typedef std::pair<int, short> P; - P p1(3, static_cast<short>(4)); - P p2(3, static_cast<short>(2)); - assert(!(p1 == p2)); - assert( (p1 != p2)); - assert(!(p1 < p2)); - assert(!(p1 <= p2)); - assert( (p1 > p2)); - assert( (p1 >= p2)); - } - -#if TEST_STD_VER > 11 - { - typedef std::pair<int, short> P; - constexpr P p1(3, static_cast<short>(4)); - constexpr P p2(3, static_cast<short>(2)); - static_assert(!(p1 == p2), ""); - static_assert( (p1 != p2), ""); - static_assert(!(p1 < p2), ""); - static_assert(!(p1 <= p2), ""); - static_assert( (p1 > p2), ""); - static_assert( (p1 >= p2), ""); - } -#endif -} diff --git a/test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp b/test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp deleted file mode 100644 index 3586243f8bac..000000000000 --- a/test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&); - -#include <utility> -#include <memory> -#include <cassert> - -#include "test_macros.h" - -int main() -{ - { - typedef std::pair<int, short> P1; - P1 p1 = std::make_pair(3, static_cast<short>(4)); - assert(p1.first == 3); - assert(p1.second == 4); - } - -#if TEST_STD_VER >= 11 - { - typedef std::pair<std::unique_ptr<int>, short> P1; - P1 p1 = std::make_pair(std::unique_ptr<int>(new int(3)), static_cast<short>(4)); - assert(*p1.first == 3); - assert(p1.second == 4); - } - { - typedef std::pair<std::unique_ptr<int>, short> P1; - P1 p1 = std::make_pair(nullptr, static_cast<short>(4)); - assert(p1.first == nullptr); - assert(p1.second == 4); - } -#endif -#if TEST_STD_VER >= 14 - { - typedef std::pair<int, short> P1; - constexpr P1 p1 = std::make_pair(3, static_cast<short>(4)); - static_assert(p1.first == 3, ""); - static_assert(p1.second == 4, ""); - } -#endif - -} diff --git a/test/std/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp b/test/std/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp deleted file mode 100644 index 62fa94247946..000000000000 --- a/test/std/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp +++ /dev/null @@ -1,31 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template <class T1, class T2> struct pair - -// template <class T1, class T2> void swap(pair<T1, T2>& x, pair<T1, T2>& y); - -#include <utility> -#include <cassert> - -int main() -{ - { - typedef std::pair<int, short> P1; - P1 p1(3, static_cast<short>(4)); - P1 p2(5, static_cast<short>(6)); - swap(p1, p2); - assert(p1.first == 5); - assert(p1.second == 6); - assert(p2.first == 3); - assert(p2.second == 4); - } -} diff --git a/test/std/utilities/utility/synopsis.pass.cpp b/test/std/utilities/utility/synopsis.pass.cpp deleted file mode 100644 index 009b65cbbe53..000000000000 --- a/test/std/utilities/utility/synopsis.pass.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. -// -//===----------------------------------------------------------------------===// - -// <utility> -// XFAIL: c++98, c++03 - -// #include <initializer_list> - -#include <utility> - -int main() -{ - std::initializer_list<int> x; - (void)x; -} - diff --git a/test/std/utilities/utility/utility.inplace/inplace.pass.cpp b/test/std/utilities/utility/utility.inplace/inplace.pass.cpp deleted file mode 100644 index e87c6f399e93..000000000000 --- a/test/std/utilities/utility/utility.inplace/inplace.pass.cpp +++ /dev/null @@ -1,74 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11, c++14 - -// <utility> - -// struct in_place_t { -// explicit in_place_t() = default; -// }; -// inline constexpr in_place_t in_place{}; - -// template <class T> -// struct in_place_type_t { -// explicit in_place_type_t() = default; -// }; -// template <class T> -// inline constexpr in_place_type_t<T> in_place_type{}; - -// template <size_t I> -// struct in_place_index_t { -// explicit in_place_index_t() = default; -// }; -// template <size_t I> -// inline constexpr in_place_index_t<I> in_place_index{}; - -#include <utility> -#include <cassert> -#include <memory> - -#include "test_macros.h" -#include "type_id.h" - -template <class Tp, class Up> -constexpr bool check_tag(Up) { - return std::is_same<Tp, std::decay_t<Tp>>::value - && std::is_same<Tp, Up>::value; -} - -int main() { - // test in_place_t - { - using T = std::in_place_t; - static_assert(check_tag<T>(std::in_place)); - } - // test in_place_type_t - { - using T1 = std::in_place_type_t<void>; - using T2 = std::in_place_type_t<int>; - using T3 = std::in_place_type_t<const int>; - static_assert(!std::is_same<T1, T2>::value && !std::is_same<T1, T3>::value); - static_assert(!std::is_same<T2, T3>::value); - static_assert(check_tag<T1>(std::in_place_type<void>)); - static_assert(check_tag<T2>(std::in_place_type<int>)); - static_assert(check_tag<T3>(std::in_place_type<const int>)); - } - // test in_place_index_t - { - using T1 = std::in_place_index_t<0>; - using T2 = std::in_place_index_t<1>; - using T3 = std::in_place_index_t<static_cast<size_t>(-1)>; - static_assert(!std::is_same<T1, T2>::value && !std::is_same<T1, T3>::value); - static_assert(!std::is_same<T2, T3>::value); - static_assert(check_tag<T1>(std::in_place_index<0>)); - static_assert(check_tag<T2>(std::in_place_index<1>)); - static_assert(check_tag<T3>(std::in_place_index<static_cast<size_t>(-1)>)); - } -} diff --git a/test/std/utilities/utility/utility.swap/swap.pass.cpp b/test/std/utilities/utility/utility.swap/swap.pass.cpp deleted file mode 100644 index c9c9f3b52760..000000000000 --- a/test/std/utilities/utility/utility.swap/swap.pass.cpp +++ /dev/null @@ -1,103 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template<class T> -// requires MoveAssignable<T> && MoveConstructible<T> -// void -// swap(T& a, T& b); - -#include <utility> -#include <cassert> -#include <memory> - -#include "test_macros.h" - -#if TEST_STD_VER >= 11 -struct CopyOnly { - CopyOnly() {} - CopyOnly(CopyOnly const&) noexcept {} - CopyOnly& operator=(CopyOnly const&) { return *this; } -}; - -struct MoveOnly { - MoveOnly() {} - MoveOnly(MoveOnly&&) {} - MoveOnly& operator=(MoveOnly&&) noexcept { return *this; } -}; - -struct NoexceptMoveOnly { - NoexceptMoveOnly() {} - NoexceptMoveOnly(NoexceptMoveOnly&&) noexcept {} - NoexceptMoveOnly& operator=(NoexceptMoveOnly&&) noexcept { return *this; } -}; - -struct NotMoveConstructible { - NotMoveConstructible& operator=(NotMoveConstructible&&) { return *this; } -private: - NotMoveConstructible(NotMoveConstructible&&); -}; - -struct NotMoveAssignable { - NotMoveAssignable(NotMoveAssignable&&); -private: - NotMoveAssignable& operator=(NotMoveAssignable&&); -}; - -template <class Tp> -auto can_swap_test(int) -> decltype(std::swap(std::declval<Tp>(), std::declval<Tp>())); - -template <class Tp> -auto can_swap_test(...) -> std::false_type; - -template <class Tp> -constexpr bool can_swap() { - return std::is_same<decltype(can_swap_test<Tp>(0)), void>::value; -} -#endif - -int main() -{ - - { - int i = 1; - int j = 2; - std::swap(i, j); - assert(i == 2); - assert(j == 1); - } -#if TEST_STD_VER >= 11 - { - - std::unique_ptr<int> i(new int(1)); - std::unique_ptr<int> j(new int(2)); - std::swap(i, j); - assert(*i == 2); - assert(*j == 1); - - } - { - // test that the swap - static_assert(can_swap<CopyOnly&>(), ""); - static_assert(can_swap<MoveOnly&>(), ""); - static_assert(can_swap<NoexceptMoveOnly&>(), ""); - - static_assert(!can_swap<NotMoveConstructible&>(), ""); - static_assert(!can_swap<NotMoveAssignable&>(), ""); - - CopyOnly c; - MoveOnly m; - NoexceptMoveOnly nm; - static_assert(!noexcept(std::swap(c, c)), ""); - static_assert(!noexcept(std::swap(m, m)), ""); - static_assert(noexcept(std::swap(nm, nm)), ""); - } -#endif -} diff --git a/test/std/utilities/utility/utility.swap/swap_array.pass.cpp b/test/std/utilities/utility/utility.swap/swap_array.pass.cpp deleted file mode 100644 index ad39934b20ca..000000000000 --- a/test/std/utilities/utility/utility.swap/swap_array.pass.cpp +++ /dev/null @@ -1,101 +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. -// -//===----------------------------------------------------------------------===// - -// <utility> - -// template<ValueType T, size_t N> -// requires Swappable<T> -// void -// swap(T (&a)[N], T (&b)[N]); - -#include <utility> -#include <cassert> -#include <memory> - -#include "test_macros.h" - - -#if TEST_STD_VER >= 11 -struct CopyOnly { - CopyOnly() {} - CopyOnly(CopyOnly const&) noexcept {} - CopyOnly& operator=(CopyOnly const&) { return *this; } -}; - - -struct NoexceptMoveOnly { - NoexceptMoveOnly() {} - NoexceptMoveOnly(NoexceptMoveOnly&&) noexcept {} - NoexceptMoveOnly& operator=(NoexceptMoveOnly&&) noexcept { return *this; } -}; - -struct NotMoveConstructible { - NotMoveConstructible() {} - NotMoveConstructible& operator=(NotMoveConstructible&&) { return *this; } -private: - NotMoveConstructible(NotMoveConstructible&&); -}; - -template <class Tp> -auto can_swap_test(int) -> decltype(std::swap(std::declval<Tp>(), std::declval<Tp>())); - -template <class Tp> -auto can_swap_test(...) -> std::false_type; - -template <class Tp> -constexpr bool can_swap() { - return std::is_same<decltype(can_swap_test<Tp>(0)), void>::value; -} -#endif - - -int main() -{ - { - int i[3] = {1, 2, 3}; - int j[3] = {4, 5, 6}; - std::swap(i, j); - assert(i[0] == 4); - assert(i[1] == 5); - assert(i[2] == 6); - assert(j[0] == 1); - assert(j[1] == 2); - assert(j[2] == 3); - } -#if TEST_STD_VER >= 11 - { - std::unique_ptr<int> i[3]; - for (int k = 0; k < 3; ++k) - i[k].reset(new int(k+1)); - std::unique_ptr<int> j[3]; - for (int k = 0; k < 3; ++k) - j[k].reset(new int(k+4)); - std::swap(i, j); - assert(*i[0] == 4); - assert(*i[1] == 5); - assert(*i[2] == 6); - assert(*j[0] == 1); - assert(*j[1] == 2); - assert(*j[2] == 3); - } - { - using CA = CopyOnly[42]; - using MA = NoexceptMoveOnly[42]; - using NA = NotMoveConstructible[42]; - static_assert(can_swap<CA&>(), ""); - static_assert(can_swap<MA&>(), ""); - static_assert(!can_swap<NA&>(), ""); - - CA ca; - MA ma; - static_assert(!noexcept(std::swap(ca, ca)), ""); - static_assert(noexcept(std::swap(ma, ma)), ""); - } -#endif -} |
