I am trying to use unique_ptr instead of allocating memory myself. I have the following code:
class Album {
...
public:
Add(Song* song);
...
}
void func(){
...
std::unique_ptr<Album> album = std::unique_ptr<Album>{new Album()};
std::unique_ptr<Song> song = std::unique_ptr<Song>{new Song(soundtrack.data(), soundtrack.length())};
album->Add(song.get());
...
}
I get segmentation fault for the line:
album->Add(song.get());
I tried multiple variations to get the pointer, including std::move and make_unique, but maybe I don't understand how unique_ptr works well enough to solve it.
Any ideas?