Shared or unique pointer to effects groups

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Post Reply
Message
Author
o01eg
Programmer
Posts: 2004
Joined: Sat Dec 10, 2011 5:46 am

Shared or unique pointer to effects groups

#1 Post by o01eg »

When I implemented effects for techs they accepts vector of shared pointers and store it with moving. Species although accepts vector of unique pointers and copies them into vector of shared pointer in loop. Should it be done same way with accepting vector of shared pointers in species constructor?
Gentoo Linux x64, gcc-11.2, boost-1.78.0
Ubuntu Server 22.04 x64, gcc-12, boost-1.74.0
Welcome to the slow multiplayer game at freeorion-lt.dedyn.io.Version 2024-03-15.b3de094.
Donations're welcome:BTC:bc1q007qldm6eppqcukewtfkfcj0naut9njj7audnm

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Shared or unique pointer to effects groups

#2 Post by Geoff the Medio »

Ideally this should all be held internally with unique_ptr, though I wouldn't be surprised if there are complications to doing that, such as APIs / other code that expects a shared_ptr to be passed to it. Don't switch anything from unique_ptr to shared_ptr unnecessarily, though, as if it's already passing around unique_ptr, that makes it easier to later use them internally as well.

Post Reply