Quantcast
Channel: Move constructor involving const unique_ptr - Stack Overflow
Viewing all articles
Browse latest Browse all 6

Answer by szulak for Move constructor involving const unique_ptr

$
0
0

Concept of using std::unique_ptr is representing a sole ownership of an object. What you're trying to achieve is having a Foo class own an object (which is expressed by std::unique_ptr) and making it movable (your move constructor) which makes a contradiction. I would stick with std::unique_ptr or make it shared using std::shared_ptr.

You might want to read this:Smart Pointers: Or who owns you baby?


Viewing all articles
Browse latest Browse all 6

Trending Articles