1#include <memory>
2#include <string>
3
4struct Deleter {
5 void operator()(void *) {}
6
7 int a;
8 int b;
9};
10
11struct Foo {
12 int data;
13 std::unique_ptr<Foo> fp;
14};
15
16int main() {
17 std::unique_ptr<char> nup;
18 std::unique_ptr<int> iup(new int{123});
19 std::unique_ptr<std::string> sup(new std::string("foobar"));
20
21 std::unique_ptr<char, Deleter> ndp;
22 std::unique_ptr<int, Deleter> idp(new int{456}, Deleter{.a: 1, .b: 2});
23 std::unique_ptr<std::string, Deleter> sdp(new std::string("baz"),
24 Deleter{.a: 3, .b: 4});
25
26 std::unique_ptr<Foo> fp(new Foo{.data: 3});
27
28 // Set up a structure where we have a loop in the unique_ptr chain.
29 Foo* f1 = new Foo{.data: 1};
30 Foo* f2 = new Foo{.data: 2};
31 f1->fp.reset(p: f2);
32 f2->fp.reset(p: f1);
33
34 return 0; // Set break point at this line.
35}
36

source code of lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp