xref: /llvm-project/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp (revision 31cbe0f240f660f15602c96b787c58a26f17e179)
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 position, value_type&& x);
14 
15 #include <list>
16 #include <cassert>
17 
18 #include "test_macros.h"
19 #include "MoveOnly.h"
20 #include "min_allocator.h"
21 
main(int,char **)22 int main(int, char**)
23 {
24     {
25     std::list<MoveOnly> l1;
26     l1.insert(l1.cend(), MoveOnly(1));
27     assert(l1.size() == 1);
28     assert(l1.front() == MoveOnly(1));
29     l1.insert(l1.cbegin(), MoveOnly(2));
30     assert(l1.size() == 2);
31     assert(l1.front() == MoveOnly(2));
32     assert(l1.back() == MoveOnly(1));
33     }
34     {
35     std::list<MoveOnly, min_allocator<MoveOnly>> l1;
36     l1.insert(l1.cend(), MoveOnly(1));
37     assert(l1.size() == 1);
38     assert(l1.front() == MoveOnly(1));
39     l1.insert(l1.cbegin(), MoveOnly(2));
40     assert(l1.size() == 2);
41     assert(l1.front() == MoveOnly(2));
42     assert(l1.back() == MoveOnly(1));
43     }
44 
45   return 0;
46 }
47