I am writing a class for my SLAM algorithm and this is my first large C++ project!
I do remember that std::unique_ptr
should be used when I want to keep some object which should have a dynamic memory, one owner and a long lifetime. So when designing a specific class which its object is being created only once and should have a global lifetime (it is the core class object that holds the map). So my idea was to create the std::unique_ptr which will hold that object:
class Backend
{
private:
std::vector<double> values;
/// some members
public:
Backend() : values{0} {}
~Backend(){}
// some functions
};
auto backend_ptr = std::make_unique(Backend());
So my question is: Does the size of backend_ptr
will grow if I will increase the size of its private member values
overtime? And with your suggestion, do I even need this unique_ptr
at all?