Skip to content

Commit 80a9c92

Browse files
committed
make_unique<Song> deletes the copy contructor of Song.
Uniform initialization cannot be used at this example.
1 parent 736269d commit 80a9c92

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/cpp/codesnippet/CPP/how-to-create-and-use-unique-ptr-instances_2.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
void SongVector()
22
{
3+
vector<unique_ptr<Song>> songs;
4+
35
// Create a few new unique_ptr<Song> instances
46
// and add them to vector using implicit move semantics.
5-
vector<unique_ptr<Song>> songs {
6-
make_unique<Song>(L"B'z", L"Juice"),
7-
make_unique<Song>(L"Namie Amuro", L"Funky Town"),
8-
make_unique<Song>(L"Kome Kome Club", L"Kimi ga Iru Dake de"),
9-
make_unique<Song>(L"Ayumi Hamasaki", L"Poker Face")
10-
};
7+
songs.push_back(make_unique<Song>(L"B'z", L"Juice"));
8+
songs.push_back(make_unique<Song>(L"Namie Amuro", L"Funky Town"));
9+
songs.push_back(make_unique<Song>(L"Kome Kome Club", L"Kimi ga Iru Dake de"));
10+
songs.push_back(make_unique<Song>(L"Ayumi Hamasaki", L"Poker Face"));
1111

1212
// Pass by const reference when possible to avoid copying.
1313
for (const auto& song : songs)

0 commit comments

Comments
 (0)