Debian Codegraph @

yo/stl/examples/sharedinsert.cc

raw
1 #include <iostream>
2 #include <memory>
3 #include <cstring>
4 using namespace std;
5
6 int main()
7 {
8 shared_ptr<string> sp(new string{ "Hello world" });
9 shared_ptr<string> sp2(sp);
10
11 sp->insert(strlen("Hello "), "C++ ");
12 cout << *sp << '\n' <<
13 *sp2 << '\n';
14 }
15 /*
16 Displays:
17 Hello C++ world
18 Hello C++ world
19 */