From 4404890062892277276
X-Google-Thread: f78e5,3c7d746be594880e
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII
Path: g2news1.google.com!news2.google.com!news.germany.com!news.osn.de!diablo2.news.osn.de!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsinpeer00.lnd.ops.eu.uu.net!emea.uu.net!peer-uk.news.demon.net!kibo.news.demon.net!mutlu.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: howard.hinnant@gmail.com (Howard Hinnant)
Newsgroups: comp.std.c++
Subject: Re: Concerning n2157 and is_empty specification
Date: Mon, 12 Mar 2007 19:21:47 GMT
Organization: Road Runner High Speed Online http://www.rr.com
Lines: 72
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <howard.hinnant-B96105.15010612032007@johnf2.biosci.ohio-state.edu>
References: <1173648852.230192.11800@p10g2000cwp.googlegroups.com>
NNTP-Posting-Host: news.news.demon.net
Mime-Version: 1.0
Content-Type: text/plain; charset=unknown-8bit
Content-Transfer-Encoding: quoted-printable
X-Trace: news.demon.co.uk 1173727318 20174 158.152.254.254 (12 Mar 2007 19:21:58 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Mon, 12 Mar 2007 19:21:58 +0000 (UTC)
X-Original-To: std-c++@mailman.ucar.edu
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: MT-NewsWatcher/3.5.2 (Intel Mac OS X)
X-MIME-Autoconverted: from 8bit to quoted-printable by mulga.csse.unimelb.edu.au id l2CJLsRr011882
X-Source: 
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-Source-Dir: 
X-Path: comp-std-cpp-robomod!not-for-mail
X-Received: (from fjh@localhost)
	by mulga.csse.unimelb.edu.au (8.13.8+Sun/8.13.8/Submit) id l2CJLl6k011810;
	Tue, 13 Mar 2007 06:21:47 +1100 (EST)
X-Delivered-To: std-c++@mailman.ucar.edu
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Source-Args: 
X-AntiAbuse: Sender Address Domain - gmail.com
X-Newsgroups: comp.std.c++
Xref: g2news1.google.com comp.std.c++:7973

In article <1173648852.230192.11800@p10g2000cwp.googlegroups.com>,
 "Daniel Kr=FCgler" <daniel.kruegler@googlemail.com> wrote:

> Just recently I stumbled once again since a longer
> time across chapter 16.2.1 of the first edition of
> "C++ Templates" from Vandevoorde/Josuttis, which
> explains the Empty Base Class Optimization (EBCO)
> principle as well as its limits.
> One interesting example is given, which must necessarily
> forbid EBCO:
>=20
> class Empty {
> };
>=20
> class EmptyToo : public Empty {
> };
>=20
> class NonEmpty : public Empty, public EmptyToo {
> };
>=20
> The reasoning is that NonEmpty cannot be an empty
> class, because this would have the effect that two
> subobjects of the same type would end up at the same
> offset, which is not permitted by C++ object layout
> rules.
>=20
> The revised wording in n2157, found at
>=20
> http://www2.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2157.html
>=20
> does *not* exclude the above NonEmpty class from
> is_empty categorization, because it says:
>=20
> "    template <class T> struct is_empty : public
> integral_constant<bool, b> {};
>=20
> If is_class<T>::value is false then b is false. Otherwise T is
> considered empty if and only if:
>=20
>     * T has no non-static data members, or all non-static data
> members, if any, are bit-fields of length 0, and
>     * T has no virtual members, and
>     * T has no virtual base classes, and
>     * T has no base classes B for which is_empty<B>::value is false.
>=20
> Requires: T shall be a complete type, an array type of unknown bounds,
> or is a void type."
>=20
> Now I wonder whether this is (a) an oversight in the is_empty
> specification or (b) a deliberate design decision?

It is an oversight.  This was an attempt to give meaning to "empty=20
class".  Note the (marked out) definition it is replacing. =20
Unfortunately "empty class" isn't defined elsewhere in the standard,=20
though the phrase is occasionally used.

Perhaps the best thing to do would be to go back to the old definition=20
for is_empty, but insist that it be defined somewhere in the language=20
spec.  And then is_empty can refer to that spec.  That makes it somebody=20
else's problem. :-)  Although, that definition may not be compatible=20
with our intent for is_empty...

Suggestions for better wording welcome.

-Howard

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



