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// <list>
10
11// ~list()
12
13// no emplace_back in C++03
14// UNSUPPORTED: c++03
15
16#include <list>
17#include <cassert>
18#include <set>
19
20#include "test_macros.h"
21
22
23std::set<int> destroyed;
24
25struct Foo {
26 explicit Foo(int i) : value(i) { }
27 ~Foo() { destroyed.insert(value); }
28 int value;
29};
30
31int main(int, char**)
32{
33 {
34 std::list<Foo> list;
35 list.emplace_back(args: 1);
36 list.emplace_back(args: 2);
37 list.emplace_back(args: 3);
38 assert(destroyed.empty());
39 }
40 assert(destroyed.count(1) == 1);
41 assert(destroyed.count(2) == 1);
42 assert(destroyed.count(3) == 1);
43
44 return 0;
45}
46

source code of libcxx/test/std/containers/sequences/list/list.cons/dtor.pass.cpp