In the code below, I made p const because it will never point to any other int during Foo's lifetime. This doesn't compile, as the unique_ptr's copy constructor is called, which is obviously deleted. Are there any solutions besides making p non-const? Thanks.
#include <memory>using namespace std;class Foo {public: //x is a large struct in reality Foo(const int* const x) : p(x) {}; Foo(Foo&& foo) : p(std::move(foo.p)) {};private: const unique_ptr<int> p;};