Boost logo

Boost :

Subject: Re: [boost] [interprocess] [container] Can iterator hold raw-pointer instead of offset_ptr?
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2013-04-28 07:03:31


El 28/04/2013 9:06, TONGARI escribió:
> Hi there,
>
> When putting containers in shared memory, offset_ptr is used internally,
> and IIUC, the iterator of the container will also use offset_ptr. But it
> seems to me that in most cases we only use iterator locally rather than
> putting those iterators in shared memory as well, so the
> plain-old-raw-pointer is sufficient and hopefully more efficient for
> iterator's usage.
>
> What do you think?

Unless you use vector, the speed improvement might not be very
different, as when iterating with such special "raw iterator", you need
to traverse elements in shared memory that are linked using offset_ptr
(a linked list, tree...). I guess you can get more speed with vector if
a raw iterator is used, but you can always obtain the address of the
first element and use raw pointers.

I agree that assignment, construction, dereference etc. of iterators
with raw pointers will be faster (e.g. you need a container of iterators
pointing to elements stored in shared memory containers). I guess the
speed advantage would be application-dependent.

Best,

Ion


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