1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8
9 // UNSUPPORTED: c++03
10
11 // <list>
12
13 // template <class... Args> void emplace(const_iterator p, Args&&... args);
14
15
16 #include <list>
17 #include <cassert>
18
19 #include "test_macros.h"
20 #include "min_allocator.h"
21
22 class A
23 {
24 int i_;
25 double d_;
26
27 A(const A&);
28 A& operator=(const A&);
29 public:
A(int i,double d)30 A(int i, double d)
31 : i_(i), d_(d) {}
32
geti() const33 int geti() const {return i_;}
getd() const34 double getd() const {return d_;}
35 };
36
main(int,char **)37 int main(int, char**)
38 {
39 {
40 std::list<A> c;
41 c.emplace(c.cbegin(), 2, 3.5);
42 assert(c.size() == 1);
43 assert(c.front().geti() == 2);
44 assert(c.front().getd() == 3.5);
45 c.emplace(c.cend(), 3, 4.5);
46 assert(c.size() == 2);
47 assert(c.front().geti() == 2);
48 assert(c.front().getd() == 3.5);
49 assert(c.back().geti() == 3);
50 assert(c.back().getd() == 4.5);
51 }
52 {
53 std::list<A, min_allocator<A>> c;
54 c.emplace(c.cbegin(), 2, 3.5);
55 assert(c.size() == 1);
56 assert(c.front().geti() == 2);
57 assert(c.front().getd() == 3.5);
58 c.emplace(c.cend(), 3, 4.5);
59 assert(c.size() == 2);
60 assert(c.front().geti() == 2);
61 assert(c.front().getd() == 3.5);
62 assert(c.back().geti() == 3);
63 assert(c.back().getd() == 4.5);
64 }
65
66
67 return 0;
68 }
69