[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / containers / sequences / list / list.modifiers / emplace.pass.cpp
blob2b6e5999369ae74c0fb04e6bb820b0422f892a76
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03
11 // <list>
13 // template <class... Args> void emplace(const_iterator p, Args&&... args);
16 #include <list>
17 #include <cassert>
19 #include "test_macros.h"
20 #include "min_allocator.h"
22 class A
24 int i_;
25 double d_;
27 A(const A&);
28 A& operator=(const A&);
29 public:
30 A(int i, double d)
31 : i_(i), d_(d) {}
33 int geti() const {return i_;}
34 double getd() const {return d_;}
37 int main(int, char**)
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);
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);
67 return 0;