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
22std::set<int> destroyed;
23
24struct Foo {
25 explicit Foo(int i) : value(i) {}
26 ~Foo() { destroyed.insert(value); }
27 int value;
28};
29
30int main(int, char**) {
31 {
32 std::list<Foo> list;
33 list.emplace_back(args: 1);
34 list.emplace_back(args: 2);
35 list.emplace_back(args: 3);
36 assert(destroyed.empty());
37 }
38 assert(destroyed.count(1) == 1);
39 assert(destroyed.count(2) == 1);
40 assert(destroyed.count(3) == 1);
41
42 return 0;
43}
44

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