220 20661 <2574e6bc-2891-4e3b-a862-d0e0210d839f@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Matthew Fioravante <fmatthew5876@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Bodies for inherited constructors
Date: Tue, 22 Sep 2015 15:32:01 -0700 (PDT)
Lines: 160
Approved: news@gmane.org
Message-ID: <2574e6bc-2891-4e3b-a862-d0e0210d839f@isocpp.org>
References: <89428051-95c4-486d-9e4f-1947a6cbd305@isocpp.org>
 <14aa5a21-b816-40f1-b6ed-b3cb0f62003d@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2954_444324962.1442961121828"
X-Trace: ger.gmane.org 1442961125 25467 80.91.229.3 (22 Sep 2015 22:32:05 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 22 Sep 2015 22:32:05 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDELF54RTIGRBYVNQ6YAKGQEXJ4CTWA@isocpp.org Wed Sep 23 00:32:05 2015
Return-path: <std-proposals+bncBDELF54RTIGRBYVNQ6YAKGQEXJ4CTWA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ob0-f198.google.com ([209.85.214.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDELF54RTIGRBYVNQ6YAKGQEXJ4CTWA@isocpp.org>)
	id 1ZeW6W-0001qe-ER
	for gclcip-std-proposals@m.gmane.org; Wed, 23 Sep 2015 00:32:04 +0200
Original-Received: by obbiz7 with SMTP id iz7sf32847392obb.2
        for <gclcip-std-proposals@m.gmane.org>; Tue, 22 Sep 2015 15:32:03 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :content-type:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=4vf8zDQBlewr7bOhhNU6VwwUIiBTHPwA3aVZ2wzhHhg=;
        b=rKOMPK9HI8jT/U5vqLr6Qt+d8wRkxUN7LnrCZJ4fdWAB0Ei3CdEckMw7O2ka5jXOxf
         5cfqI+OatDxXwMQXiU+mytTNh7DYfZxC5kYwOux2j+AyKVhkI0k0ihx6pPThSsMbh5rC
         Y3wiom59Fhp31zgzrPMPCszi7WYTkBLw778+pwq8G+ndd0xhro2DbLGToVtiSCErSZlu
         d1bW0LW0ITC9q5JNQrQosOWkNJ8PeOzf3J7rPpzB74XdY1RlHP1VTqe2gu2h23yhwiXz
         nPATXPrhRLpSSJQnvj/R96cA3lWqcoAJPW+2YDerFRvt3SRtg22Ymnt48RSO0uvyV9jl
         pguw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:content-type:x-original-sender:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=4vf8zDQBlewr7bOhhNU6VwwUIiBTHPwA3aVZ2wzhHhg=;
        b=mKyXZ2nXJunGMmR0od7ZE30+dUO1ZxHdUpSBsQaceO3bz5lK8JjtUvWJj8VkEZdCOj
         qd7SrDrtWg5lYN2lcFp4SxZi2wnHRNJW9S2lO4gfuqgSrXfa0ObBmhVNXzmOpg596x0C
         IzGnghNUJjoUDEiADvK6Y2D95W184rET5rnkAmRtDHMfJMQuwWjX3F7VfSr2+I+sfQCL
         eMCDxiLMK3OjGe1NjOIRM+5r+gvfMFSe4y+1Nv3d2AvKPD77CIWdPfwhDZ/AMljJvgoc
         MWUD350KanQsQWbnmhfBVkzxUPYvM8bbyvunF8JZXPRL7vyY1Qb0LN60GfOeO+1yhj4Z
         M9Eg==
X-Gm-Message-State: ALoCoQnHq5CVwziNUhCpSySs/0L7v70ejR1tTrjBbYZvCbhUyNnJ24/O3Q+VU7FSSrBaXntTMwY5
X-Received: by 10.182.60.167 with SMTP id i7mr22821431obr.1.1442961123261;
        Tue, 22 Sep 2015 15:32:03 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.10.16 with SMTP id u16ls271641ioi.56.gmail; Tue, 22 Sep
 2015 15:32:02 -0700 (PDT)
X-Received: by 10.50.112.133 with SMTP id iq5mr232761igb.17.1442961122590;
        Tue, 22 Sep 2015 15:32:02 -0700 (PDT)
In-Reply-To: <14aa5a21-b816-40f1-b6ed-b3cb0f62003d@isocpp.org>
X-Original-Sender: fmatthew5876@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://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>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:20661
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/20661>

------=_Part_2954_444324962.1442961121828
Content-Type: multipart/alternative; 
	boundary="----=_Part_2955_1475970551.1442961121828"

------=_Part_2955_1475970551.1442961121828
Content-Type: text/plain; charset=UTF-8


On Tuesday, September 22, 2015 at 6:12:06 PM UTC-4, Giovanni Piero Deretta 
wrote:
>
>
> Two solutions:
>
> use a separate base:
>
> struct A { .... };
> struct B_members { int x; B_base() : x(0) {} };
>
> struct B : A, B_members {
> using A::A;
> };
>
 
Clever, but if you need to mutate a member of A:: in the addon B::B logic 
(which my use case does) then this approach does not work since B_members 
won't have access to A.
 
Essentially, I want to do this:
struct A {
 //constructors
 Obj& obj();
};

struct B : A {
 B(/*Args*/) : A(/*forward args*/) { A::obj().do_something(); }
};

 

>
> NSMI:
>
> struct B : A {
>     using A::A;
>     int x = 0;
>
> };
>
 
If all you need to do is initialize a data member this is the obvious 
solution. If you need to do something else in the constructor, this won't 
work. Doing your logic in a lambda meant to initialize a data member would 
work but it requires that B has at least 1 data member and its horribly 
ugly.
 
Having an NSMI syntax for base classes could be another solution and make 
your B_members proposal solve my problem.
 

-- 

--- 
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 email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_2955_1475970551.1442961121828
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br>On Tuesday, September 22, 2015 at 6:12:06 PM UTC-4, Gi=
ovanni Piero Deretta wrote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; =
padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width=
: 1px; border-left-style: solid;" class=3D"gmail_quote"><div><br>Two soluti=
ons:<br><br>use a separate base:<br><br>struct A { .... };<br>struct B_memb=
ers { int x; B_base() : x(0) {} };<br><br>struct B : A, B_members {<br>usin=
g A::A;<br>};</div></blockquote><div>=C2=A0</div><div>Clever, but if you ne=
ed=C2=A0to mutate=C2=A0a member of=C2=A0A:: in the addon=C2=A0B::B logic (w=
hich my use case does) then this approach=C2=A0does not work since B_member=
s won&#39;t have access to A.</div><div>=C2=A0</div><div>Essentially, I wan=
t to do this:</div><div><div style=3D"border: 1px solid rgb(187, 187, 187);=
 word-wrap: break-word; background-color: rgb(250, 250, 250);" class=3D"pre=
ttyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span s=
tyle=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">struct</span><=
span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> A </span>=
<span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">{</sp=
an><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br>=
=C2=A0</span><span style=3D"color: rgb(136, 0, 0);" class=3D"styled-by-pret=
tify">//constructors</span><span style=3D"color: rgb(0, 0, 0);" class=3D"st=
yled-by-prettify"><br>=C2=A0</span><span style=3D"color: rgb(102, 0, 102);"=
 class=3D"styled-by-prettify">Obj</span><span style=3D"color: rgb(102, 102,=
 0);" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: rgb(0,=
 0, 0);" class=3D"styled-by-prettify"> obj</span><span style=3D"color: rgb(=
102, 102, 0);" class=3D"styled-by-prettify">();</span><span style=3D"color:=
 rgb(0, 0, 0);" class=3D"styled-by-prettify"><br></span><span style=3D"colo=
r: rgb(102, 102, 0);" class=3D"styled-by-prettify">};</span><span style=3D"=
color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br><br></span><span sty=
le=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">struct</span><sp=
an style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> B </span><s=
pan style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">:</span=
><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> A </spa=
n><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">{</=
span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br>=
=C2=A0B</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: rgb(136, 0, 0);" class=3D"styled-by-=
prettify">/*Args*/</span><span style=3D"color: rgb(102, 102, 0);" class=3D"=
styled-by-prettify">)</span><span style=3D"color: rgb(0, 0, 0);" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: rgb(102, 102, 0);" class=
=3D"styled-by-prettify">:</span><span style=3D"color: rgb(0, 0, 0);" class=
=3D"styled-by-prettify"> A</span><span style=3D"color: rgb(102, 102, 0);" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: rgb(136, 0, 0);" =
class=3D"styled-by-prettify">/*forward args*/</span><span style=3D"color: r=
gb(102, 102, 0);" class=3D"styled-by-prettify">)</span><span style=3D"color=
: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </span><span style=3D"color:=
 rgb(102, 102, 0);" class=3D"styled-by-prettify">{</span><span style=3D"col=
or: rgb(0, 0, 0);" class=3D"styled-by-prettify"> A</span><span style=3D"col=
or: rgb(102, 102, 0);" class=3D"styled-by-prettify">::</span><span style=3D=
"color: rgb(0, 0, 0);" class=3D"styled-by-prettify">obj</span><span style=
=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">().</span><span =
style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify">do_something</s=
pan><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">(=
);</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify">=
 </span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettif=
y">}</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify=
"><br></span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-pr=
ettify">};</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-pr=
ettify"><br></span></div></code></div><br></div><div>=C2=A0</div><blockquot=
e style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color:=
 rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;" cla=
ss=3D"gmail_quote"><div><br>NSMI:<br><br>struct B : A {<br>=C2=A0=C2=A0=C2=
=A0 using A::A;<br>=C2=A0=C2=A0=C2=A0 int x =3D 0;<br><br>};</div></blockqu=
ote><div>=C2=A0</div><div>If all you need to do is initialize a data member=
 this is the obvious solution. If you need to do something else in the cons=
tructor, this won&#39;t work. Doing your logic in a lambda meant to initial=
ize a data member would work but it requires that B has at least 1 data mem=
ber and its horribly ugly.</div><div>=C2=A0</div><div>Having an NSMI syntax=
=C2=A0for base classes could be another solution and make your B_members pr=
oposal solve my problem.</div><div>=C2=A0</div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_2955_1475970551.1442961121828--
------=_Part_2954_444324962.1442961121828--

.
