[libcxx-commits] [PATCH] D63050: Test that correct value category is used in scoped_allocator_adaptor::construct
Zoe Carver via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jun 8 10:28:59 PDT 2019
zoecarver created this revision.
zoecarver added reviewers: mclow.lists, EricWF, ldionne.
Herald added subscribers: libcxx-commits, dexonsmith.
zoecarver added a comment.
For the pair section of the issue, I ran into a few problems. The genesis of the problem is the fact that this compiles (and I can't figure out why):
struct Foo
{
typedef std::allocator<Foo> allocator_type;
Foo(std::allocator_arg_t, allocator_type&&) { }
Foo(allocator_type&) { }
};
int main()
{
using Alloc1 = std::allocator<pair<Foo, Foo>>;
using Alloc2 = std::allocator<Foo>;
static_assert( std::is_constructible<Foo, std::allocator_arg_t, Alloc1&>::value);
static_assert(!std::is_constructible<Foo, std::allocator_arg_t, Alloc2&>::value);
}
This patch fixes 2586 <https://cplusplus.github.io/LWG/issue2586>. Just tests; NFC.
Repository:
rCXX libc++
https://reviews.llvm.org/D63050
Files:
test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp
www/cxx1z_status.html
Index: www/cxx1z_status.html
===================================================================
--- www/cxx1z_status.html
+++ www/cxx1z_status.html
@@ -308,7 +308,7 @@
<tr><td><a href="https://wg21.link/LWG2582">2582</a></td><td>§[res.on.functions]/2's prohibition against incomplete types shouldn't apply to type traits</td><td>Jacksonville</td><td>Complete</td></tr>
<tr><td><a href="https://wg21.link/LWG2583">2583</a></td><td>There is no way to supply an allocator for <tt>basic_string(str, pos)</tt></td><td>Jacksonville</td><td>Complete</td></tr>
<tr><td><a href="https://wg21.link/LWG2585">2585</a></td><td><tt>forward_list::resize(size_type, const value_type&)</tt> effects incorrect</td><td>Jacksonville</td><td>Complete</td></tr>
- <tr><td><a href="https://wg21.link/LWG2586">2586</a></td><td>Wrong value category used in <tt>scoped_allocator_adaptor::construct()</tt></td><td>Jacksonville</td><td></td></tr>
+ <tr><td><a href="https://wg21.link/LWG2586">2586</a></td><td>Wrong value category used in <tt>scoped_allocator_adaptor::construct()</tt></td><td>Jacksonville</td><td>Complete</td></tr>
<tr><td><a href="https://wg21.link/LWG2590">2590</a></td><td>Aggregate initialization for <tt>std::array</tt></td><td>Jacksonville</td><td>Complete</td></tr>
<tr><td></td><td></td><td></td><td></td></tr>
<tr><td><a href="https://wg21.link/LWG2181">2181</a></td><td>Exceptions from seed sequence operations</td><td>Oulu</td><td>Complete</td></tr>
Index: test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp
===================================================================
--- test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp
+++ test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp
@@ -111,6 +111,18 @@
bool F::constructed = false;
+struct G
+{
+ static bool constructed;
+
+ typedef std::allocator<G> allocator_type;
+
+ G(std::allocator_arg_t, allocator_type&&) { assert(false); }
+ G(allocator_type&) { constructed = true; }
+};
+
+bool G::constructed = false;
+
int main(int, char**)
{
@@ -186,5 +198,15 @@
s->~S();
}
+ // LWG 2586
+ // test that is_constructible uses an lvalue ref so the correct constructor is picked
+ {
+ std::scoped_allocator_adaptor<G::allocator_type> sa;
+ G* ptr = sa.allocate(1);
+ sa.construct(ptr);
+ assert(G::constructed);
+ sa.deallocate(ptr, 1);
+ }
+
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63050.203699.patch
Type: text/x-patch
Size: 2510 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190608/9774d3b3/attachment-0001.bin>
More information about the libcxx-commits
mailing list