Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Nov 2013 09:51:50 -0500
From:      Zhihao Yuan <lichray@gmail.com>
To:        David Chisnall <theraven@freebsd.org>
Cc:        Eitan Adler <lists@eitanadler.com>, FreeBSD current <freebsd-current@freebsd.org>, Steve Kargl <sgk@troutmask.apl.washington.edu>
Subject:   Re: Are clang++ and libc++ compatible?
Message-ID:  <CAGsORuBHmXS9%2B6uwgiUF7mVnMYqoazgX7iYbjF_gS_UxoUmVSg@mail.gmail.com>
In-Reply-To: <9071A5A2-9F8D-4F5A-9EAD-66A680246AFE@FreeBSD.org>
References:  <20131112163219.GA2834@troutmask.apl.washington.edu> <20131112165422.GA2939@troutmask.apl.washington.edu> <CAF6rxgmRb3QALsSyVrpR683%2BVzcUnDN0VQja62xn8FTZaRxOKw@mail.gmail.com> <201311121321.07330.jhb@freebsd.org> <9071A5A2-9F8D-4F5A-9EAD-66A680246AFE@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Nov 13, 2013 at 5:04 AM, David Chisnall <theraven@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/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGsORuBHmXS9%2B6uwgiUF7mVnMYqoazgX7iYbjF_gS_UxoUmVSg>