Move semantics for Grid (and Tree?) #1119
Unanswered
BenFrantzDale
asked this question in
Q&A
Replies: 1 comment 1 reply
-
I don't have a strong opinion on adding move semantics or not, I think we've briefly discussed this in the past but the benefits seemed fairly small for the tree hierarchy or otherwise the changes required to take advantage of this would have meant a significant change to ABI which we steered away from. I can at least speak to the purpose of the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As far as I can tell,
openvdb::Grid
holds astd::shared_ptr<Tree>
. I haven't figured out why the tree needs to be shared (shared non-const is scary!) but at very least that meansGrid
should be movable.Describe the solution you'd like
I think this is just a matter of
and
I suspect
TreeBase
,Tree
,RootNode
, andInternalNode
could get the same treatment. (LeafNode
too although that only matters if people are storing things in leaves that allocate on the heap, so that's probably silly.)Describe alternatives you've considered
At present, the use pattern seems to be very focused on shared pointers to mutable structures. (I've been watching a bunch of Sean Parent talks recently, and he rants about shared_ptr to mutable, particularly in the context of reasoning about thread safety.) There are lots of places (I think!) that I could avoid the extra allocation and get the value semantics and thread safety of a regular type.
Would y'all be open to a PR making the above additions?
Beta Was this translation helpful? Give feedback.
All reactions