What is the most efficient way to give a shared_ptr<void> to an object that passes it to another private method before being stored in it's final destination?
It's difficult to describe... maybe asking with code will illustrate the question better:
class Example{
public:
void give(std::shared_ptr<void> data) { // [A] which signature is best here?
void give(std::shared_ptr<void> & data) { // [B]
// the caller keeps it's shared_ptr
m_give(data); // [A] which of these is preferable?
m_give(std::move(data)); // [B]
}
private:
void m_give(std::shared_ptr<void> data) { // [A] which signature is best here
void m_give(std::shared_ptr<void> & data) { // [B]
void m_give(std::shared_ptr<void> && data) { // [C]
// only `give()` will ever call this
m_data = data; // [A] which of these is preferable?
m_data = std::move(data); // [B]
}
// members
std::shared_ptr<void> m_data;
};
How would you set up a mechanism like this?