summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/20_util/scoped_allocator
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2018-06-18 21:17:44 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2018-06-18 21:17:44 +0100
commit05891e9f458cc7e6ba5387c6ac84f4201e40107d (patch)
treeab76f552250e0e08a3463e2120eee14ecf0fd391 /libstdc++-v3/testsuite/20_util/scoped_allocator
parentdf0b55f090b8591746d350a474d5f2291a9202be (diff)
downloadgcc-05891e9f458cc7e6ba5387c6ac84f4201e40107d.tar.gz
LWG 2975 ensure construct(pair<T,U>*, ...) used to construct pairs
* include/std/scoped_allocator (__not_pair): Define SFINAE helper. (construct(_Tp*, _Args&&...)): Remove from overload set when _Tp is a specialization of std::pair. * testsuite/20_util/scoped_allocator/construct_pair.cc: Ensure pair elements are constructed correctly. From-SVN: r261716
Diffstat (limited to 'libstdc++-v3/testsuite/20_util/scoped_allocator')
-rw-r--r--libstdc++-v3/testsuite/20_util/scoped_allocator/construct_pair.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/20_util/scoped_allocator/construct_pair.cc b/libstdc++-v3/testsuite/20_util/scoped_allocator/construct_pair.cc
index 341328e487f..b34efc88798 100644
--- a/libstdc++-v3/testsuite/20_util/scoped_allocator/construct_pair.cc
+++ b/libstdc++-v3/testsuite/20_util/scoped_allocator/construct_pair.cc
@@ -73,9 +73,37 @@ test03()
a.deallocate(ptr, 1);
}
+void
+test04()
+{
+ struct X
+ {
+ using allocator_type = std::allocator<int>;
+ X() = default;
+ X(const X&) { throw 1; }
+ X(const X&, const allocator_type&) { }
+ };
+
+ struct Y
+ {
+ using allocator_type = std::allocator<int>;
+ Y() = default;
+ Y(const Y&) = delete;
+ Y(std::allocator_arg_t, const allocator_type&, const Y&) { }
+ };
+
+ using pair_type = std::pair<X, Y>;
+ std::scoped_allocator_adaptor<std::allocator<pair_type>> a;
+ auto ptr = a.allocate(1);
+ /* not const */ pair_type p;
+ a.construct(ptr, p); // LWG 2975
+ a.deallocate(ptr, 1);
+}
+
int main()
{
test01();
test02();
test03();
+ test04();
}