|
|
|
|
|
by SeanCline
3312 days ago
|
|
The idea of a value_ptr is something that's been around in C++ for quite some time, now. It usually goes by the name clone_ptr or copy_ptr. (Googling for either will yield several implementations.) Looking at the author's code on GitHub, this implementation seems decent. One thing to note about this implementation is that it doesn't address the other big reason for doing dynamic allocations: polymorphic types. Value semantics are preserved so faithfully that objects are sliced just as they would be if they weren't dynamically allocated. Consider this example: https://gist.github.com/SeanCline/c81218e4c0208ccb871268aecd... |
|