Prev: About Int2Type
Next: RVO
From: Francis Glassborow on
Lance Diduck wrote:
> On Jan 10, 10:08 am, "Victor V. Terber" <VTer...(a)gmail.com> wrote:
>> In existing sources I found a std::list using only methods
>> push_back(), front() and pop_front(). I'm considering to replace the
>> list by std::deque.
>>
>> The usual rule of thumb to use the simplest container that does the
>> job seems to apply here. I'm aware that the standard doesn't say much
>> about performance behavior, but due to various restrictions (client's
>> site, varying compilers, STLs, OS) actual measuring is very hard in
>> this case.
>>
>> Does such a replacement of list by deque seem reasonable? Would you
>> typically expect real-world performance changes?
> In this case it seems like the "simplest" container would be a
> std::queue.
>
> To answer your question more directly, it has a lot to do with just
> how big the "T" is that you are storing. Over a certain size T,
> std::deque typically morphs (internally) into a std::list +
> std::vector combination (the vector is so that std::deque can support
> random access iterators.)

I do not see how it could possibly do that because of the requirement
for fixed location for objects in a deque whilst vector has relocation
semantics. I am not a library expert but I believe that deques are
implemented via an extra layer of indirection and that the blocks
actually used for the base memory of elements is more akin to an array
(i.e. a fixed size and a fixed location)

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

 | 
Pages: 1
Prev: About Int2Type
Next: RVO