1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: c++98, c++03, c++11, c++14
11 
12 // XFAIL: availability=macosx10.13
13 // XFAIL: availability=macosx10.12
14 // XFAIL: availability=macosx10.11
15 // XFAIL: availability=macosx10.10
16 // XFAIL: availability=macosx10.9
17 // XFAIL: availability=macosx10.8
18 // XFAIL: availability=macosx10.7
19 
20 // <any>
21 
22 // void swap(any &, any &) noexcept
23 
24 // swap(...) just wraps any::swap(...). That function is tested elsewhere.
25 
26 #include <any>
27 #include <cassert>
28 
29 using std::any;
30 using std::any_cast;
31 
main()32 int main()
33 {
34 
35     { // test noexcept
36         any a;
37         static_assert(noexcept(swap(a, a)), "swap(any&, any&) must be noexcept");
38     }
39     {
40         any a1(1);
41         any a2(2);
42 
43         swap(a1, a2);
44 
45         assert(any_cast<int>(a1) == 2);
46         assert(any_cast<int>(a2) == 1);
47     }
48 }
49