[libcxx] r283780 - 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.
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 10 09:47:48 PDT 2016
Author: marshall
Date: Mon Oct 10 11:47:48 2016
New Revision: 283780
URL: http://llvm.org/viewvc/llvm-project?rev=283780&view=rev
Log:
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.
Modified:
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp
Modified: libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp?rev=283780&r1=283779&r2=283780&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp Mon Oct 10 11:47:48 2016
@@ -12,13 +12,14 @@
// class function<R(ArgTypes...)>
// template <MoveConstructible R, MoveConstructible ... ArgTypes>
-// void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
+// void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
#include <functional>
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
#include "count_new.hpp"
class A
@@ -63,6 +64,9 @@ int main()
{
std::function<int(int)> f1 = A(1);
std::function<int(int)> 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<A>()->id() == 1);
@@ -78,6 +82,9 @@ int main()
{
std::function<int(int)> f1 = A(1);
std::function<int(int)> 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<A>()->id() == 1);
@@ -93,6 +100,9 @@ int main()
{
std::function<int(int)> f1 = g;
std::function<int(int)> 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<int(*)(int)>() == g);
@@ -108,6 +118,9 @@ int main()
{
std::function<int(int)> f1 = g;
std::function<int(int)> 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<int(*)(int)>() == g);
More information about the cfe-commits
mailing list