220 35269 <1540337.mpxU4uUWLP@tjmaciei-mobl1> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Thiago Macieira <thiago@macieira.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Overriding virtual functions of member class
Date: Sat, 04 Nov 2017 12:25:53 -0700
Lines: 60
Approved: news@gmane.org
Message-ID: <1540337.mpxU4uUWLP@tjmaciei-mobl1>
References: <26216c34-9ff6-435b-8da5-9b21460fee1c@isocpp.org> <389229bd-7f50-4efa-b6c9-177df26bcd0a@isocpp.org> <5b06f168-cde4-45a9-8614-6025c8b16e85@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: blaine.gmane.org 1509823557 5999 195.159.176.226 (4 Nov 2017 19:25:57 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sat, 4 Nov 2017 19:25:57 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCB4TK757YBRBQ5I7DHQKGQE4RD5UGY@isocpp.org Sat Nov 04 20:25:51 2017
Return-path: <std-proposals+bncBCB4TK757YBRBQ5I7DHQKGQE4RD5UGY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wr0-f200.google.com ([209.85.128.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCB4TK757YBRBQ5I7DHQKGQE4RD5UGY@isocpp.org>)
	id 1eB44j-0000ya-Dy
	for gclcip-std-proposals@m.gmane.org; Sat, 04 Nov 2017 20:25:49 +0100
Original-Received: by mail-wr0-f200.google.com with SMTP id o44sf3586827wrf.0
        for <gclcip-std-proposals@m.gmane.org>; Sat, 04 Nov 2017 12:25:57 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1509823557; cv=pass;
        d=google.com; s=arc-20160816;
        b=QdbyziHf6t1fGFhbgmNw5SwzkceKGDohPGAH4hWOqsGXiNZ6pg/VoVspY5R2JUnzzw
         3WxJ2mxBkWcihukPPt7yxdL2/QBgKtXwxi92RLPbXim6iSBzaS2QMIyygblH4BVwwGNE
         rFSywPgzvUGZKihOrUrGyL/85MiFfndkkh+bqT+S2/5CfXdSr6NdtBzXjDVO3Ah93sQu
         MLZDH73vqnvwPlsk2VeHnr2QrI7aV/DD8HIT4GyZ7P9WIukPDJXzk8aGU1TTfBhwxwpp
         MrpzzYEAjR2DkHtkW207QkICgUQ161e77dg5vyn4Hn4j5Ni5uG0VLgCFgt1BCx+mTVYK
         JUPw==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:content-transfer-encoding
         :mime-version:references:in-reply-to:message-id:date:subject:to:from
         :arc-authentication-results:arc-message-signature:dkim-signature
         :arc-authentication-results;
        bh=qbEiRr3SAVOt+QmtweO9SF5r6ARqqVRBFqSTqlwffGE=;
        b=Nwx2p2fMjjj8o7ioJmT6beIuMBJV43KYpOyAj4BBDezAaCkWwaH/nyrtUoSJUFsoKQ
         5FsHyDBFma8erly67G7CtrFI10Bz8SuP/bhiIMBCQoKwGneQCdpH+Gz0JjXXJvlujDgz
         SfaB+1qFPZwuTTL3pcITBfyto0deLqrOYk1QRR3TDJe4bNHQmJq4KasdJ2maTitMeWgf
         nYHNMnPXV1+2B4sCNnSoOL24CEJaOprZc35VjvfoJmdsNwaInKAb4ek9SZCqzRoOui8Q
         tk0PgVncMP5/Cpw4b2Ka8MtDNhFlAC3/1K3/SWYjyfjvhcMC+iX+0Lyy2X29TrA5hnA2
         iHKw==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3 as permitted sender) smtp.mailfrom=thiago@macieira.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=from:to:subject:date:message-id:in-reply-to:references:mime-version
         :content-transfer-encoding:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=qbEiRr3SAVOt+QmtweO9SF5r6ARqqVRBFqSTqlwffGE=;
        b=MzDErwPAuA2laTq3OqSatvbGSu2m+eHF7gSrEoiviq0iBzEJr7q/wD1L3w28O6odSg
         cwffyZbZgze4z3IJLOoO/jdjA8i9je+p1jwGRYtODM7byP4AUIpzOCLDgiN2yU1bVJG6
         p823oi4BKPj9Jq7eAUzT/HdW0Of9ysiTgujavXRhKXBnRj0Fm4DeULyCPxwLHK5GDL1l
         b9UrAaiQc6PD364cvUC+1OsW1r9VptiaYqyNSxgQhzarBPNlx1x44pU5Yc/2bs56e3Ag
         8yploxEs9iPpsJBDF5L4C/xfHxbZUKyzycVdn+WKqPra4KQDS2N5yycKI1WX9lNN7vnw
         Q+Fw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to
         :references:mime-version:content-transfer-encoding:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=qbEiRr3SAVOt+QmtweO9SF5r6ARqqVRBFqSTqlwffGE=;
        b=HBUNUQspfU7Hf0vJb6wEYJvmMEwU/7Sh09E4EUaJHicufM1C7Y5AezRQJByWuYG9rP
         xQO6neZjhkrVSFPgMzuFBxPlfbwdSA3mDPHAbzuGAAGgjNL3xsiMzlWg0GCVN4SUQy4S
         gRym0/O7NdPRWMB57BUC41sNh0pf6xFFe6C2AbH6w8C5QWtEJxZJuCgbjVAwuiEs49Lp
         CgczLiW2qPWrDxzySYCr5NUUtrsUk8/p8dy/YpdsYravbhiKuOiZkUCJIW8ukGaCvTx7
         tR87tw9Fn4l0M6Y09HZzwosuvAPF0BgPEPxi7PHZSd8B4pUH6eE+U+ePZovywTVyt/+Y
         ayW 
X-Gm-Message-State: AJaThX4UxWrn3QvuoKLG5UQh2io1jB1dgv0vS+7OC05NsTIs30zTqak8
	lPq4++zkHab+Q91ctyaFKwhsMg==
X-Google-Smtp-Source: ABhQp+RlC0hFhjj7gesk8nsAzVGnJth+SsmlSyO5dI1yOiF0OsQlrnw7/vdf/4nmtaoear2vp8T7rQ==
X-Received: by 10.28.7.75 with SMTP id 72mr425717wmh.23.1509823556968;
        Sat, 04 Nov 2017 12:25:56 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.103.131 with SMTP id b125ls775731wmc.12.gmail; Sat, 04 Nov
 2017 12:25:55 -0700 (PDT)
X-Received: by 10.223.148.38 with SMTP id 35mr9624081wrq.49.1509823555602;
        Sat, 04 Nov 2017 12:25:55 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1509823555; cv=none;
        d=google.com; s=arc-20160816;
        b=WAxsu9ZCc/UFiCk1N2zqRSryUkiU3cGcEnklIjFQuRSSn2WOHKDE8cXpwJFcTLie4x
         rgq2tIsC+TC8mJnD/2pd0fCfuuHNwMRPxOTqGQgOrI4iugHDhhwcVAOBovj2SICihUsM
         rw9+1yzfZNr+bERuT5Y9el8zrCPPJ+O77vORSuDkVVzybySJN7dOsqOvrsZBf0rsCA+E
         zyca3JmYl6VHI3nAUAiZAWn24pDjsfDjJGM7vk3g4ha431Tq7aAufs4MxgET9c+/Ywye
         nW+P+aADujpSxggjORuH3SMMVO4eugASGo3800aEyaUxbM4WOoqfQUlWGy+6Fk+GTQWM
         fiUw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:to:from:arc-authentication-results;
        bh=SmGUn25z1NKL6hg3G6VnmFhtLCqf9jUaSMonhc42WrE=;
        b=LyXAj0+DqQfnWGxLs7kurbz9P5vztkQrx3BG+M/j+hAeW0Iet0B/PSJhtQ+YkD/jQH
         UQ9IQjqEtLZJe8yi5HC/CdSsPH2tRGMN4WfiPlSfUJmsiZd8EB4Ixqin7Ml7ulwOl2Hq
         +ODCvIjJoIXjpU0SeYFCMXV6oFJqneMwkV1pN9gf7L/sHgumZRrmCOy5NipsPIw8hCtr
         n3jgOFX3g53kxXbD85WhWMTpk7GEWpl+TmeQgFYIPa2rYExRryp6z6ehEyMuNcuYnmQ8
         VI7pNxs2oVhg10bNDCTsQwA868BK93jJt9GQrSeRAhlSF/fq0QKSlnWFzl/CDO3/h6Jd
         9rPw==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3 as permitted sender) smtp.mailfrom=thiago@macieira.org
Original-Received: from gondolin.macieira.info (gondolin.macieira.info. [2a01:4f8:d13:f81:21c:14ff:fe01:12a3])
        by mx.google.com with ESMTP id o81si8522134wrb.226.2017.11.04.12.25.55
        for <std-proposals@isocpp.org>;
        Sat, 04 Nov 2017 12:25:55 -0700 (PDT)
Received-SPF: pass (google.com: domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3 as permitted sender) client-ip=2a01:4f8:d13:f81:21c:14ff:fe01:12a3;
Original-Received: from tjmaciei-mobl1.localnet (unknown [IPv6:2601:1c0:4501:5f9f:c4cb:f753:d6a5:e233])
	by gondolin.macieira.info (Postfix) with ESMTPSA id 1597C11B6FE
	for <std-proposals@isocpp.org>; Sat,  4 Nov 2017 12:25:55 -0700 (PDT)
In-Reply-To: <5b06f168-cde4-45a9-8614-6025c8b16e85@isocpp.org>
X-Original-Sender: thiago@macieira.org
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3
 as permitted sender) smtp.mailfrom=thiago@macieira.org
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:35269
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/35269>

On s=C3=A1bado, 4 de novembro de 2017 04:07:46 PDT ambrop7@gmail.com wrote:
> > struct A {
> > virtual void virtualFunction() =3D 0;
> >
> >};
> >
> >struct B {
> >
> > struct A1 : A {
> > void virtualFunction() override;
> > } m_a1;
> > struct A2 : A {
> > void virtualFunction() override;
> > } m_a2;
> >
> >};
>=20
> The issue with this approach is that the implementations of
> virtualFunctions() will need to get B* from a pointer to A1*/A2*. That
> cannot be done in general (only when B is a standard-layout class by usin=
g
> offsetof). So to be portable code, A1 and A2 would each need to have a "B
> *parent" member. That adds size overhead and requires boilerplate.

Correct.

And remember that offsetof is restricted for a reason. If you're not allowe=
d=20
to use it, what makes you think the compiler could resolve the pointer from=
 A=20
back to B without storing a pointer somewhere? Since B is not standard layo=
ut,=20
a subclass C of B could change the offsets from m_a1 and m_a2 to the top of=
 B=20
(it doesn't happen with the major ABIs, but it is theoretically possible).

Now, I'll grant you that there are advantages to leaving this to the compil=
er:
 1) if the distance is fixed by ABI, then the adjustment can be in code
 2) even if it isn't, the adjustment may be stored in the vtable itself, as=
=20
    opposed to storing it in each object.

I'm just wondering if this is worth the complexity. I see no other advantag=
e=20
to your feature suggestion, except that of saving sizeof(void*) per object.

--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/1540337.mpxU4uUWLP%40tjmaciei-mobl1.

.
