From owner-freebsd-current@FreeBSD.ORG Wed Nov 13 10:04:44 2013 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B134B307; Wed, 13 Nov 2013 10:04:44 +0000 (UTC) Received: from theravensnest.org (theraven.freebsd.your.org [216.14.102.27]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7FCEC23B0; Wed, 13 Nov 2013 10:04:44 +0000 (UTC) Received: from [192.168.0.2] (cpc27-cmbg15-2-0-cust235.5-4.cable.virginm.net [86.27.188.236]) (authenticated bits=0) by theravensnest.org (8.14.5/8.14.5) with ESMTP id rADA4eWo014235 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Wed, 13 Nov 2013 10:04:41 GMT (envelope-from theraven@FreeBSD.org) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) Subject: Re: Are clang++ and libc++ compatible? From: David Chisnall In-Reply-To: <201311121321.07330.jhb@freebsd.org> Date: Wed, 13 Nov 2013 10:04:36 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: <9071A5A2-9F8D-4F5A-9EAD-66A680246AFE@FreeBSD.org> References: <20131112163219.GA2834@troutmask.apl.washington.edu> <20131112165422.GA2939@troutmask.apl.washington.edu> <201311121321.07330.jhb@freebsd.org> To: John Baldwin X-Mailer: Apple Mail (2.1508) Cc: Eitan Adler , freebsd-current@FreeBSD.org, Steve Kargl X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Nov 2013 10:04:44 -0000 On 12 Nov 2013, at 18:21, John Baldwin wrote: >> struct foo { >> struct foo bar; >> } >=20 > Except it isn't. It's declaring the head of a container. This is = more > like: >=20 > struct foo { > TAILQ_HEAD(, foo) messages; > }; Eitan is correct here. The definition of std::deque is that it copies = the value that is the template argument and does not require = modifications to the layout. A deque is more akin to an array, so in C = it would be something like: struct foo { struct foo bar[10]; }; This is clearly nonsense - you can't have a structure that contains = itself. The same is true for the deque. It's not clear what the pan = people actually wanted, but an efficient implementation of a deque would = most likely contain space for a small number of the template argument = elements, so they are literally defining a structure containing a = structure containing the parent structure. The same would be true if = they did: struct Entry { std::vector v; }; 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; }; }; It would make sense to have a std:deque or std:deque, = because then you're only storing references or pointers to the outer = structure in the inner structure. =20 David