On Wed, Nov 13, 2013 at 5:04 AM, David Chisnall <thera...@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/
freebsd-current@freebsd.org mailing list
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to