boostorg / property_tree

Boost.org property_tree module
http://boost.org/libs/property_tree
55 stars 92 forks source link

Proof-of-concept `splice` operation #30

Closed sehe closed 6 years ago

sehe commented 6 years ago

It's currently not possible to efficiently move nodes between ptrees.

Context/discussion: https://stackoverflow.com/a/29563086/85371

This PR is a DRAFT. It is meant to sollicit interest and quick review (is the idea "sane"? I do not believe any invariants are at risk, but maybe the core maintainers see more).

If there's interest, I'll flesh it out in full.


Multi Index splice overloads: http://www.boost.org/doc/libs/release/libs/multi_index/doc/reference/seq_indices.html#list_operations

reviewer suggestion: Joaquín M López Muñoz

joaquintides commented 6 years ago

I'm afraid this does not work as intended: Boost.MultiIndex splice operations do relink only when the source and destination indices are the same --in all other cases elements are inserted to and erased from one by one, copying along the way.

sehe commented 6 years ago

@joaquintides Thanks for chiming in. That was easy :) I should have looked at the implementation for a bit (it was surprising to me, though, I didn't expect that behaviour just reading the documentation).