1 // { dg-do run { target c++11 } }
4 #include <testsuite_hooks.h>
5 #include <testsuite_allocator.h>
10 // LWG 3506 Missing allocator-extended constructors for priority_queue
12 using Alloc
= __gnu_test::uneq_allocator
<int>;
14 using Container
= std::vector
<int, Alloc
>;
16 struct Queue
: std::priority_queue
<int, Container
>
18 using priority_queue::priority_queue
;
20 Alloc
get_allocator() const { return c
.get_allocator(); }
23 using Compare
= Queue::value_compare
;
25 const Alloc
a1(1), a2(2), a3(3), a4(4);
26 const int vals
[] = { 5, 3, 9, 1, 7 };
27 Container
cont({ 20, 30, 40 }, Alloc(99));
29 Queue
q1(vals
, vals
+5, a1
);
30 VERIFY( q1
.get_allocator() == a1
);
31 VERIFY( q1
.size() == 5 );
32 VERIFY( q1
.top() == 9 );
34 Queue
q2(vals
, vals
+5, Compare(), a2
);
35 VERIFY( q2
.get_allocator() == a2
);
36 VERIFY( q2
.size() == 5 );
37 VERIFY( q2
.top() == 9 );
39 Queue
q3(vals
, vals
+5, Compare(), cont
, a3
);
40 VERIFY( q3
.get_allocator() == a3
);
41 VERIFY( q3
.size() == 8 );
42 VERIFY( q3
.top() == 40 );
44 Queue
q4(vals
, vals
+5, Compare(), std::move(cont
), a4
);
45 VERIFY( q4
.get_allocator() == a4
);
46 VERIFY( q4
.size() == 8 );
47 VERIFY( q4
.top() == 40 );
48 VERIFY( cont
.empty() );