Сус амогус
On Thu, 21 Oct 2021 at 11:09, John W via Boost-users<boost-users@lists.boost.org> wrote:With a traditional "hand-rolled" doubly-linked list, if you have areference to a Node, you can traverse from that node to the end of thelist easily. Just check for "pNext == NULL" to know when you're at theend. You don't need any reference to the owning "list container"object.However, I can't seem to accomplish the same with boost::intrusive::list.Traversal with an intrusive::list's iterator is done STL-style, andfor that you need to compare to the container's ".end()" value.I am aware of the "s_iterator_to" function[1], which can staticallyget an iterator from a node, but there doesn't seem to be any way tostatically get a usable ".end()" value to compare to. There is also"container_from_end_iterator"[2], which gives the container if youhave "end()" available already — not quite what I want, but I guessshows that end() is intimately tied to the container.I also notice that if I have an iterator to the last element in alist, and I increment it (++iterator), no error is given. But if I tryto dereference it, I get garbage data.Peeking into the implementation, from what I can tell,boost::intrusive::list is actually a circular list, with a special"root node" that the container owns, and which represents the "end".So, iterating beyond the end gives you that root node.I guess my questions are:(1) Is my analysis above correct? I feel I might have missed somethingwading through all the templates, and the docs I've found don'tdiscuss these implementation details.(2) Is there any way to accomplish what I want? That is: iteratingfrom an arbitrary node to the end of the list, *without* a referenceto the owning container?(3) [aside] If the answer to the above is "no", does anyone know whatthe rationale is for this design choice? It seems odd that such abasic feature of a traditional hand-made intrusive list would bedropped if there were no benefit.Thanks-John_______________________________________________Boost-users mailing list