[interprocess][flat_map/flat_set] provide read access to underlying container

Hi Ion, Sometimes I need to go through all elements in such a container. However, it is know that the number of elements is low, so I unroll the loop manually. In that case I would like to be able to do the following: const T& t1 = flat_set[0u]; const T& t2 = flat_set[1u]; Alternatively, provide a base() function that directly give read access to the underlying container: const T& t1 = flat_set.base()[0u]; Comments? -Thorsten

Thorsten Ottosen wrote:
Hi Ion,
Sometimes I need to go through all elements in such a container. However, it is know that the number of elements is low, so I unroll the loop manually. In that case I would like to be able to do the following:
const T& t1 = flat_set[0u]; const T& t2 = flat_set[1u];
Alternatively, provide a base() function that directly give read access to the underlying container:
const T& t1 = flat_set.base()[0u];
Comments?
I don't see any problem to provide it. I don't like much "base()" name, naybe I should rename the function to internal_container() or something similar. Anyway, are not internal random-access iterators good enough? flat_set_type::iterator itbeg = flat_set.begin(); const T& t1 = itbeg[0]; const T& t2 = itbeg[1]; Regards, Ion
-Thorsten _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Ion Gaztañaga skrev:
Thorsten Ottosen wrote:
Hi Ion,
Sometimes I need to go through all elements in such a container. However, it is know that the number of elements is low, so I unroll the loop manually. In that case I would like to be able to do the following:
const T& t1 = flat_set[0u]; const T& t2 = flat_set[1u];
Alternatively, provide a base() function that directly give read access to the underlying container:
const T& t1 = flat_set.base()[0u];
Comments?
I don't see any problem to provide it. I don't like much "base()" name, naybe I should rename the function to internal_container() or something similar.
Anyway, are not internal random-access iterators good enough?
flat_set_type::iterator itbeg = flat_set.begin(); const T& t1 = itbeg[0]; const T& t2 = itbeg[1];
Yes, they are. I missed that. However, with access to the container I would also be able to use front() and back(). Anyway, not a big issue. Thanks -Thorsten
participants (2)
-
Ion Gaztañaga
-
Thorsten Ottosen