• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: 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
18 
19 // <any>
20 
21 // void swap(any &, any &) noexcept
22 
23 // swap(...) just wraps any::swap(...). That function is tested elsewhere.
24 
25 #include <any>
26 #include <cassert>
27 
28 using std::any;
29 using std::any_cast;
30 
main()31 int main()
32 {
33 
34     { // test noexcept
35         any a;
36         static_assert(noexcept(swap(a, a)), "swap(any&, any&) must be noexcept");
37     }
38     {
39         any a1(1);
40         any a2(2);
41 
42         swap(a1, a2);
43 
44         assert(any_cast<int>(a1) == 2);
45         assert(any_cast<int>(a2) == 1);
46     }
47 }
48