I can't get difference between two variants:
class test {
std::unique_ptr<std::vector<float>> m_field;
test(const std::vector<float>&& values) : m_field{std::make_unique<vector<float>>(std::move(values))} {}
};
And
class test {
const std::vector<float>&& m_field;
test(const std::vector<float>&& values) : m_field{std::move(values)} {}
};
In the first variant the default destructor will remove unique_ptr
and inner vector
automatically but what will happen in the second variant how will the default destructor work?
What variant is better?
P.S. Maybe it's easy but I am looking for and can't find. My English isn't good, please, don't send me to hard docs.