Boost logo

Boost :

Subject: [boost] [Intrusive]
From: degski (degski_at_[hidden])
Date: 2017-08-23 07:18:19


I having trouble understanding the documentation of Boost.Intrusive. I'm
referring to this section in particular:
http://www.boost.org/doc/libs/1_65_0/doc/html/intrusive/intrusive_vs_nontrusive.html#intrusive.intrusive_vs_nontrusive.differences_intrusive_vs_nontrusive

"The main difference between intrusive containers and non-intrusive
containers is that in C++ non-intrusive containers store *copies* of values
passed by the user."

This is confusing, as that might not be true in case of C++11 and up. Does
(or rather, can) move-construction invalidate the use case for Intrusive
containers?

"On the other hand, an intrusive container does not store copies of passed
objects, but it stores the objects themselves. The additional data needed
to insert the object in the container must be provided by the object
itself."

But then in the example for slist, it seems from the example code that (a)
pointer(s) to the original object are stored (and makes it look like the
object), but that's not what I read from the quoted text.

class MyClass{
   MyClass *next;
   MyClass *previous;
   //Other members...};
int main(){
   acme_intrusive_list<MyClass> list;

   MyClass myclass;
   list.push_back(myclass);

   //"myclass" object is stored in the list
   assert(&myclass == &list.front());
   return 0;}

I would like to ask for somebody to confirm I'm right, or explain to me in
language (palatable to a thick user) what is actually stored (in terms of
implementation).

Thanks in advance,

degski

-- 
"*Ihre sogenannte Religion wirkt bloß wie ein Opiat reizend, betäubend,
Schmerzen aus Schwäche stillend.*" - Novalis 1798

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk