Is it valid to transfer nodes between two boost::intrusive::slist<boost::intrusive::cache_last<true>>
objects? Something like the following
auto one = boost::intrusive::slist<Node, boost::intrusive::cache_last<true>>{};
auto two = boost::intrusive::slist<Node, boost::intrusive::cache_last<true>>{};
auto node = std::make_unique<Node>();
one.push_back(*node);
auto& front = one.front();
one.pop_front();
two.push_back(front);
I'm getting a segmentation fault, and an assertion failure with boost version 1.70.0 https://wandbox.org/permlink/nWHakTYUiVBGKH6I. How can I fix this?
Note: I can't allocate a new node and copy the old one because I am using an intrusive list to have control over when and where the allocation happens.
It seems to be the purpose of the
splice
method:Fully working demo:
When run, will write: