Hi,
I am trying to convert my program to use smart pointers but am having trouble creating a map of unique pointers. The map contains sf::image and uses the file name as a key. This prevents the same image being loaded in more than once. The map uses unique pointers because the list should have ownership of the data (sf::Image).
A unique_ptr means: The pointee is owned by this pointer. No other pointer shares in ownership. It doesn't make sense to use shared_ptr if you're using unique_ptr. The two represent different ownership strategies.
Would it be better to store sf::image in the list but still return shared_ptr?
Store an sf::Image and return a regular pointer or reference. You could, of course, store a unique_ptr in the map and return a regular pointer or a reference to the image, but I don't see a good reason for an additional level of indirection.