Since memory is copied, it's really not clear to me what the advantage is of using value_ptr over just using values.
Is it just about heap vs. stack?
Is it just about heap vs. stack?
class Tree { Tree _left, _right; };
Won't compile because it has an infinite size. However class Tree { Tree *_left, *_right; };
Compiles, but the author contends that a more explicit description of the ownership semantics is better: class Tree { value_ptr<Tree> _left, _right; }
This is also why `value_ptr` is different than `optional`. class Tree { Tree *_left, *_right; };
Tree y = x;
makes a shallow copy. class Tree { unique_ptr<Tree> _left, _right; };
Tree y = x;
doesn't compile, but class Tree { value_ptr<Tree> _left, _right; };
Tree y = x;
makes a deep copy.