Is it possible in C++ to have a constructor that takes a reference to an object, and moves this into a smart pointer? Example:
class A {
public:
A(std::unique_ptr<std::vector<int>>& v_ptr) : v_ptr(std::move(v_ptr)) {};
// TODO: wanted constructor with this signature that ideally calls the first constructor
A(std::vector<int>& v) {}
private:
std::unique_ptr<std::vector<int>> v_ptr;
}
My intended usage of this class should be something like this:
A a({1, 2, 3});