• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: c++98, c++03
11 
12 // <list>
13 
14 // template <class... Args> void emplace(const_iterator p, Args&&... args);
15 
16 
17 #include <list>
18 #include <cassert>
19 
20 #include "test_macros.h"
21 #include "min_allocator.h"
22 
23 class A
24 {
25     int i_;
26     double d_;
27 
28     A(const A&);
29     A& operator=(const A&);
30 public:
A(int i,double d)31     A(int i, double d)
32         : i_(i), d_(d) {}
33 
geti() const34     int geti() const {return i_;}
getd() const35     double getd() const {return d_;}
36 };
37 
main()38 int main()
39 {
40     {
41     std::list<A> c;
42     c.emplace(c.cbegin(), 2, 3.5);
43     assert(c.size() == 1);
44     assert(c.front().geti() == 2);
45     assert(c.front().getd() == 3.5);
46     c.emplace(c.cend(), 3, 4.5);
47     assert(c.size() == 2);
48     assert(c.front().geti() == 2);
49     assert(c.front().getd() == 3.5);
50     assert(c.back().geti() == 3);
51     assert(c.back().getd() == 4.5);
52     }
53     {
54     std::list<A, min_allocator<A>> c;
55     c.emplace(c.cbegin(), 2, 3.5);
56     assert(c.size() == 1);
57     assert(c.front().geti() == 2);
58     assert(c.front().getd() == 3.5);
59     c.emplace(c.cend(), 3, 4.5);
60     assert(c.size() == 2);
61     assert(c.front().geti() == 2);
62     assert(c.front().getd() == 3.5);
63     assert(c.back().geti() == 3);
64     assert(c.back().getd() == 4.5);
65     }
66 
67 }
68