-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API: consider single parameter NodeRef::duplicate #336
Comments
Might be related to #324, with eager assertions making it impossible. |
Indeed there was a problematic assertion preventing proper use of As for the API suggestion, it is a good point. Passing a parent makes sense in the |
Even within Tree , my 2c: might as well use further, here's my 'armchair proposal' for a more general API:
The
(PS, Thanks for your nice library!) |
NodeRef::duplicate: What's the rationale for having separate parameters
parent
andafter
?Background:
When I wanted to clone the descendants of a NodeRef into a new tree, intuition suggested I do the following:
result:
check failed: parent.m_tree == after.m_tree
Ok, how about...
result:
check failed: (id != NONE && id >= 0 && id < m_size)
I used Tree::duplicate directly instead.
Why not just get the tree and parent from a single NodeRef parameter?
proposed replacements:
NodeRef::duplicate_after(NodeRef const after)
(duplicates after given node) +NodeRef::duplicate_under(NodeRef const parent)
(duplicates as first child of given node)similarly for
NodeRef::move
etc.The text was updated successfully, but these errors were encountered: