
Hi, On 26 Sep 2009, at 23:49, Stefan Strasser wrote:
list.splice(list.end(),otherlist);
boost.intrusive represents the nodes as STL-like containers, if you need to port code that handles nodes directly you might be interested in *list_algorithms of boost.intrusive, but I'd recommend using the containers.
Doesn't splice require otherlist to be a list? This seems to make it somewhat inadequate, as the docs make the list class out to be rather brittle (non-copyable and non-assignable), so returning a list from afunction() is not a option. I guess one can return a pointer to a new- ly allocated list, but that is another pointer to delete and more boilerplate code. I would rather use the containers if at all possible, however, the design seems to be working against me in this scenario.
Secondly, when dealing with heap allocated items, which need to be deleted, the current code uses a while loop to call each nodes destructor. What is the intrusive equivalent?
clear_and_dispose()
Excellent. In the library I am writing/porting it is sometimes necessary to return one of these lists. Naturally, one will want to return a clone of the internal list, however, what would be the nicest way to ensure its disposal? It may be somewhat haphazard to rely on users to call a specific dispose/delete method. Are there any exceptionally neat solutions to this? Regards, Freddie.