On Wed, Nov 13, 2013 at 5:04 AM, David Chisnall <theraven_at_freebsd.org> wrote: > A deque is more akin to an array, so in C it would be something like: > [...] > This is clearly nonsense - you can't have a structure that contains itself. > [...] > An implementation of the vector class might allocate all of the elements on the heap lazily, but it's not required to and could equally have space for a small number inside the object, expanding to something like this: > > struct Entry { > struct MangledNameOfVectorOfEntry { > size_t size; > Entry small[4]; > Entry *ptr; > }; > }; If you don't learn C++, then just don't make claims like these. If I can not recursively declare std::array<T, N>, which is totally allocated on stack with layout exactly same as T[N], I would say this implementation is mad. > It would make sense to have a std:deque<Entry&> or std:deque<Entry*>, because then you're only storing references or pointers to the outer structure in the inner structure. It makes no sense, since you switched from value semantics to reference semantics. -- Zhihao Yuan, ID lichray The best way to predict the future is to invent it. ___________________________________________________ 4BSD -- http://4bsd.biz/Received on Wed Nov 13 2013 - 13:51:52 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:44 UTC