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// iterator insert(const_iterator p, initializer_list<value_type> il);
14
15#include <list>
16#include <cassert>
17
18#include "test_macros.h"
19#include "min_allocator.h"
20
21int main(int, char**)
22{
23 {
24 std::list<int> d(10, 1);
25 std::list<int>::iterator i = d.insert(p: std::next(x: d.cbegin(), n: 2), l: {3, 4, 5, 6});
26 assert(d.size() == 14);
27 assert(i == std::next(d.begin(), 2));
28 i = d.begin();
29 assert(*i++ == 1);
30 assert(*i++ == 1);
31 assert(*i++ == 3);
32 assert(*i++ == 4);
33 assert(*i++ == 5);
34 assert(*i++ == 6);
35 assert(*i++ == 1);
36 assert(*i++ == 1);
37 assert(*i++ == 1);
38 assert(*i++ == 1);
39 assert(*i++ == 1);
40 assert(*i++ == 1);
41 assert(*i++ == 1);
42 assert(*i++ == 1);
43 }
44 {
45 std::list<int, min_allocator<int>> d(10, 1);
46 std::list<int, min_allocator<int>>::iterator i = d.insert(std::next(d.cbegin(), 2), {3, 4, 5, 6});
47 assert(d.size() == 14);
48 assert(i == std::next(d.begin(), 2));
49 i = d.begin();
50 assert(*i++ == 1);
51 assert(*i++ == 1);
52 assert(*i++ == 3);
53 assert(*i++ == 4);
54 assert(*i++ == 5);
55 assert(*i++ == 6);
56 assert(*i++ == 1);
57 assert(*i++ == 1);
58 assert(*i++ == 1);
59 assert(*i++ == 1);
60 assert(*i++ == 1);
61 assert(*i++ == 1);
62 assert(*i++ == 1);
63 assert(*i++ == 1);
64 }
65
66 return 0;
67}
68

source code of libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp