From 6d370568c3239568f9ba375f521ea84315abace7 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Wed, 18 Mar 2015 22:56:50 +0000 Subject: [libc++] Fix PR22922 - Allocator support for std::function does not know how to rebind. Summary: This patch changes std::function to use allocator_traits to rebind the allocator instead of allocator itself. It also changes most of the tests to use `bare_allocator` where possible instead of `test_allocator`. Reviewers: mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D8391 llvm-svn: 232686 --- .../func.wrap.func/func.wrap.func.con/alloc.pass.cpp | 6 ++++-- .../func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp | 12 ++++++------ .../func.wrap.func.con/alloc_function.pass.cpp | 7 ++++--- .../func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp | 4 ++-- .../func.wrap.func.con/alloc_rfunction.pass.cpp | 4 ++-- 5 files changed, 18 insertions(+), 15 deletions(-) (limited to 'libcxx/test/std/utilities') diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp index 4feac30c300..f97e34d3f2c 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp @@ -16,10 +16,12 @@ #include #include -#include "test_allocator.h" +#include "min_allocator.h" int main() { - std::function f(std::allocator_arg, test_allocator()); + { + std::function f(std::allocator_arg, bare_allocator()); assert(!f); + } } diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp index 28e44a67a71..741a3b9a955 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp @@ -16,7 +16,7 @@ #include #include -#include "test_allocator.h" +#include "min_allocator.h" class A { @@ -57,19 +57,19 @@ public: int main() { { - std::function f(std::allocator_arg, test_allocator(), A()); + std::function f(std::allocator_arg, bare_allocator(), A()); assert(A::count == 1); assert(f.target()); assert(f.target() == 0); } assert(A::count == 0); { - std::function f(std::allocator_arg, test_allocator(), g); + std::function f(std::allocator_arg, bare_allocator(), g); assert(f.target()); assert(f.target() == 0); } { - std::function f(std::allocator_arg, test_allocator(), + std::function f(std::allocator_arg, bare_allocator(), (int (*)(int))0); assert(!f); assert(f.target() == 0); @@ -77,7 +77,7 @@ int main() } { std::function f(std::allocator_arg, - test_allocator(), + bare_allocator(), &A::foo); assert(f); assert(f.target() != 0); @@ -91,7 +91,7 @@ int main() #endif { std::function fun(std::allocator_arg, - test_allocator(), + bare_allocator(), &g); assert(fun); assert(fun.target() != 0); diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp index bb8feff7a16..e89636a69d6 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp @@ -17,6 +17,7 @@ #include #include +#include "min_allocator.h" #include "test_allocator.h" #include "count_new.hpp" @@ -58,7 +59,7 @@ int main() assert(globalMemCounter.checkOutstandingNewEq(1)); assert(f.target()); assert(f.target() == 0); - std::function f2(std::allocator_arg, test_allocator(), f); + std::function f2(std::allocator_arg, bare_allocator(), f); assert(A::count == 2); assert(globalMemCounter.checkOutstandingNewEq(2)); assert(f2.target()); @@ -71,7 +72,7 @@ int main() assert(globalMemCounter.checkOutstandingNewEq(0)); assert(f.target()); assert(f.target() == 0); - std::function f2(std::allocator_arg, test_allocator(), f); + std::function f2(std::allocator_arg, bare_allocator(), f); assert(globalMemCounter.checkOutstandingNewEq(0)); assert(f2.target()); assert(f2.target() == 0); @@ -91,7 +92,7 @@ int main() assert(globalMemCounter.checkOutstandingNewEq(0)); assert(f.target() == 0); assert(f.target() == 0); - std::function f2(std::allocator_arg, test_allocator(), f); + std::function f2(std::allocator_arg, bare_allocator(), f); assert(globalMemCounter.checkOutstandingNewEq(0)); assert(f2.target() == 0); assert(f2.target() == 0); diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp index 956136be021..2350f92f0f8 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp @@ -16,10 +16,10 @@ #include #include -#include "test_allocator.h" +#include "min_allocator.h" int main() { - std::function f(std::allocator_arg, test_allocator(), nullptr); + std::function f(std::allocator_arg, bare_allocator(), nullptr); assert(!f); } diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp index 15b7c8b5aa4..aa6b743b523 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp @@ -16,7 +16,7 @@ #include #include -#include "test_allocator.h" +#include "min_allocator.h" #include "count_new.hpp" class A @@ -56,7 +56,7 @@ int main() assert(globalMemCounter.checkOutstandingNewEq(1)); assert(f.target()); assert(f.target() == 0); - std::function f2(std::allocator_arg, test_allocator(), std::move(f)); + std::function f2(std::allocator_arg, bare_allocator(), std::move(f)); assert(A::count == 1); assert(globalMemCounter.checkOutstandingNewEq(1)); assert(f2.target()); -- cgit v1.2.3