const unique_ptr<int> upi{new int{4}};
cout << ++*upi << '\n';
Seems upi
is a const smart pointer
. The int
it points to can still be modified. What if I want to declare the int
as const
?
const unqiue_ptr<int> const upi{new int{4}}; //Error: duplicate const
As far as I understand, you want to make the integer const
and not the pointer itself, right? Then you would have to write:
unqiue_ptr<const int> upi{new int{4}};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With