From -4703527173574563673
X-Google-Thread: f78e5,3c7d746be594880e,start
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII
Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.speakeasy.net!news.speakeasy.net.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 12 Mar 2007 13:40:05 -0500
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Original-To: std-c++@mailman.ucar.edu
Delivered-To: std-c++@mailman.ucar.edu
From: "=?iso-8859-1?q?Daniel_Kr=FCgler?=" <daniel.kruegler@googlemail.com>
Newsgroups: comp.std.c++
Subject: Concerning n2157 and is_empty specification
Organization: http://groups.google.com
Message-ID: <1173648852.230192.11800@p10g2000cwp.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Complaints-To: groups-abuse@google.com
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: p10g2000cwp.googlegroups.com; posting-host=89.48.199.115;
   posting-account=0YhmiQ0AAABRDjD_6coNmBVB3rgPlaOq
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by mulga.csse.unimelb.edu.au id l2BLYdcG021120
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Date: Mon, 12 Mar 2007 13:36:42 CST
Lines: 59
NNTP-Posting-Host: 65.182.171.162
X-Trace: sv3-eraWippM1btKIOcARXasaX5iVs12qzwepjGFa5cF+dE1GGf97h5RaU5R9+XE3CiWqPvRqTcNP1V7c+n!fzsPidfHgI5wMmbbXoxF2fn4+1c0JS3twBthgVhMMVl26tN+QbBeHVd+8B3upN3ejQyxL9qY+AwG!I4+F1WofdsfNl8l1z0IkNr15pUm9H6wOvqBMUW5CSA==
X-Complaints-To: abuse@speakeasy.net
X-DMCA-Complaints-To: abuse@speakeasy.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.34
Xref: g2news1.google.com comp.std.c++:7971

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:

class Empty {
};

class EmptyToo : public Empty {
};

class NonEmpty : public Empty, public EmptyToo {
};

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.

The revised wording in n2157, found at

http://www2.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2157.html

does *not* exclude the above NonEmpty class from
is_empty categorization, because it says:

"    template <class T> struct is_empty : public
integral_constant<bool, b> {};

If is_class<T>::value is false then b is false. Otherwise T is
considered empty if and only if:

    * 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.

Requires: T shall be a complete type, an array type of unknown bounds,
or is a void type."

Now I wonder whether this is (a) an oversight in the is_empty
specification or (b) a deliberate design decision?

Greetings from Bremen,

Daniel Kr�gler


---
[ 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                      ]



