I'm relatively new to C++ and want to adopt modern practice. I've been trying to understand when it's best to sink a unique_ptr
, here is some code I have:
class SomeClass
{
...
private:
unique_ptr<QStaticText> _text;
}
{
...
void SomeClass::setText(unique_ptr<QStaticText> newText)
{
_text = move(newText);
}
void SomeClass::setText(const QStaticText& newText)
{
_text = make_unique<QStaticText>(newText);
}
...
}
Should I prefer one over the other, either or another?