Boost logo

Boost :

From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2008-04-29 15:47:40


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


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