Is it considered good practice to put unique_ptr in an array? Yes, I know, they have unusual copy semantic, but my idea is this:
I have a tiled-based game field. Each pointer in the array points to some game object. When I assign something new to an array element, the previous object is destroyed and a new one is placed.
Another question — the same about shared_ptr, because sometimes I will use flyweight pattern.
One of
unique_ptr‘s biggest advantages is that it’s safe to use in Standard containers likestd::vector.std::vector<std::unique_ptr<T>>is no anti-pattern, it’s perfectly fine and highly recommended.