1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: c++98, c++03, c++11
12 // XFAIL: with_system_cxx_lib=macosx10.12
13 // XFAIL: with_system_cxx_lib=macosx10.11
14 // XFAIL: with_system_cxx_lib=macosx10.10
15 // XFAIL: with_system_cxx_lib=macosx10.9
16 // XFAIL: with_system_cxx_lib=macosx10.7
17 // XFAIL: with_system_cxx_lib=macosx10.8
21 // any::swap(any &) noexcept
23 // Test swap(large, small) and swap(small, large)
25 #include <experimental/any>
28 #include "experimental_any_helpers.h"
30 using std::experimental::any;
31 using std::experimental::any_cast;
33 template <class LHS, class RHS>
35 assert(LHS::count == 0);
36 assert(RHS::count == 0);
40 assert(LHS::count == 1);
41 assert(RHS::count == 1);
45 assert(LHS::count == 1);
46 assert(RHS::count == 1);
48 assertContains<RHS>(a1, 2);
49 assertContains<LHS>(a2, 1);
51 assert(LHS::count == 0);
52 assert(RHS::count == 0);
53 assert(LHS::copied == 0);
54 assert(RHS::copied == 0);
58 void test_swap_empty() {
59 assert(Tp::count == 0);
63 assert(Tp::count == 1);
67 assert(Tp::count == 1);
69 assertContains<Tp>(a2, 1);
72 assert(Tp::count == 0);
76 assert(Tp::count == 1);
80 assert(Tp::count == 1);
82 assertContains<Tp>(a2, 1);
85 assert(Tp::count == 0);
86 assert(Tp::copied == 0);
95 , "any::swap(any&) must be noexcept"
102 test_swap_empty<small>();
103 test_swap_empty<large>();
104 test_swap<small1, small2>();
105 test_swap<large1, large2>();
106 test_swap<small, large>();
107 test_swap<large, small>();