1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 // template <class... Args> reference emplace_front(Args&&... args);
14 // return type is 'reference' in C++17; 'void' before
19 #include "test_macros.h"
20 #include "min_allocator.h"
28 A
& operator=(const A
&);
33 int geti() const {return i_
;}
34 double getd() const {return d_
;}
42 A
& r1
= c
.emplace_front(2, 3.5);
43 assert(c
.size() == 1);
44 assert(&r1
== &c
.front());
45 assert(c
.front().geti() == 2);
46 assert(c
.front().getd() == 3.5);
47 A
& r2
= c
.emplace_front(3, 4.5);
48 assert(c
.size() == 2);
49 assert(&r2
== &c
.front());
51 c
.emplace_front(2, 3.5);
52 assert(c
.size() == 1);
53 assert(c
.front().geti() == 2);
54 assert(c
.front().getd() == 3.5);
55 c
.emplace_front(3, 4.5);
56 assert(c
.size() == 2);
58 assert(c
.front().geti() == 3);
59 assert(c
.front().getd() == 4.5);
60 assert(c
.back().geti() == 2);
61 assert(c
.back().getd() == 3.5);
65 std::list
<A
, min_allocator
<A
>> c
;
67 A
& r1
= c
.emplace_front(2, 3.5);
68 assert(c
.size() == 1);
69 assert(&r1
== &c
.front());
70 assert(c
.front().geti() == 2);
71 assert(c
.front().getd() == 3.5);
72 A
& r2
= c
.emplace_front(3, 4.5);
73 assert(c
.size() == 2);
74 assert(&r2
== &c
.front());
76 c
.emplace_front(2, 3.5);
77 assert(c
.size() == 1);
78 assert(c
.front().geti() == 2);
79 assert(c
.front().getd() == 3.5);
80 c
.emplace_front(3, 4.5);
81 assert(c
.size() == 2);
83 assert(c
.front().geti() == 3);
84 assert(c
.front().getd() == 4.5);
85 assert(c
.back().geti() == 2);
86 assert(c
.back().getd() == 3.5);