let say I have
Code: Select all
class B {....};
class A
{
A() { pb = new(B); };
~A { delete pb; }
B* pb = nullptr;
};
std::vector<A> veca;
As I do not need the copy constructor, to avoid any error of 2 pointers pointing on the same allocated memory, I want to delete the copy constructor.
Code: Select all
A(const A&) = delete;
It seems that it also delete the default move constructor,
Because if I add :
Code: Select all
A(const A&&) = default;
But is it safe ? I suppose it is, but I would like a confirmation from the specialists...
So final result :
Code: Select all
class B {....};
class A
{
A() { pb = new(B); };
~A { delete pb; }
A(const A&) = delete;
A(const A&&) = default;
B* pb = nullptr;
};
std::vector<A> veca;