summaryrefslogtreecommitdiff
path: root/test/std/experimental/any/any.nonmembers/swap.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/experimental/any/any.nonmembers/swap.pass.cpp')
-rw-r--r--test/std/experimental/any/any.nonmembers/swap.pass.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/std/experimental/any/any.nonmembers/swap.pass.cpp b/test/std/experimental/any/any.nonmembers/swap.pass.cpp
new file mode 100644
index 000000000000..a3fbd43d9247
--- /dev/null
+++ b/test/std/experimental/any/any.nonmembers/swap.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/any>
+
+// void swap(any &, any &) noexcept
+
+// swap(...) just wraps any::swap(...). That function is tested elsewhere.
+
+#include <experimental/any>
+#include <cassert>
+
+using std::experimental::any;
+using std::experimental::any_cast;
+
+int main()
+{
+
+ { // test noexcept
+ any a;
+ static_assert(noexcept(swap(a, a)), "swap(any&, any&) must be noexcept");
+ }
+ {
+ any a1(1);
+ any a2(2);
+
+ swap(a1, a2);
+
+ assert(any_cast<int>(a1) == 2);
+ assert(any_cast<int>(a2) == 1);
+ }
+}