Many examples of using std::unique_ptr to control ownership of class dependencies are as follows:
class Parent { public: Parent(Child&& child) : _child(std::make_unique<Child>(std::move(child))){} private: std::unique_ptr<Child> _child; };
My question is, are there any unexpected side effects of marking _child member as const ? (Besides reset() , release() , etc. You cannot call on _child ).
I ask because I have not seen it in the example yet and am not doing it intentionally or simply for brevity / generality.
c ++ c ++ 11 smart-pointers unique-ptr
Peet whittaker
source share