From e9115a1b416a659a5265e94b866617c44ba4eecb Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 10 Oct 2016 16:47:48 +0000 Subject: [PATCH] Add tests to check that swap(std::function, std::function) is noexcept. This is LWG#2062, but we already do this. No changes to the library, just adding tests. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283780 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../func.wrap.func.alg/swap.pass.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp index 58192c928..1a9206e0e 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp @@ -12,13 +12,14 @@ // class function // template -// void swap(function&, function&); +// void swap(function&, function&) noexcept; #include #include #include +#include "test_macros.h" #include "count_new.hpp" class A @@ -63,6 +64,9 @@ int main() { std::function f1 = A(1); std::function f2 = A(2); +#if TEST_STD_VER >= 11 + static_assert(noexcept(swap(f1, f2)), "" ); +#endif assert(A::count == 2); assert(globalMemCounter.checkOutstandingNewEq(2)); assert(f1.target()->id() == 1); @@ -78,6 +82,9 @@ int main() { std::function f1 = A(1); std::function f2 = g; +#if TEST_STD_VER >= 11 + static_assert(noexcept(swap(f1, f2)), "" ); +#endif assert(A::count == 1); assert(globalMemCounter.checkOutstandingNewEq(1)); assert(f1.target()->id() == 1); @@ -93,6 +100,9 @@ int main() { std::function f1 = g; std::function f2 = A(1); +#if TEST_STD_VER >= 11 + static_assert(noexcept(swap(f1, f2)), "" ); +#endif assert(A::count == 1); assert(globalMemCounter.checkOutstandingNewEq(1)); assert(*f1.target() == g); @@ -108,6 +118,9 @@ int main() { std::function f1 = g; std::function f2 = h; +#if TEST_STD_VER >= 11 + static_assert(noexcept(swap(f1, f2)), "" ); +#endif assert(A::count == 0); assert(globalMemCounter.checkOutstandingNewEq(0)); assert(*f1.target() == g);