220 24927 <7db63114-8e12-4d38-94e4-39f0061362de@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: "'Walt Karas' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: "Components" template with implicitly defined
 partial specializations for all classes
Date: Fri, 4 Mar 2016 11:48:07 -0800 (PST)
Lines: 157
Approved: news@gmane.org
Message-ID: <7db63114-8e12-4d38-94e4-39f0061362de@isocpp.org>
References: <fd64d8c9-703d-45d8-a9b2-4b8a222c02f0@isocpp.org>
 <92a6bfcf-0100-40b2-8946-a9c634783ec9@isocpp.org>
 <3c8bb230-c83b-4c18-95b6-1cc32caae76d@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1228_1211116281.1457120887341"
X-Trace: ger.gmane.org 1457120899 30749 80.91.229.3 (4 Mar 2016 19:48:19 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 4 Mar 2016 19:48:19 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDFLZXWOVYIBB6GM463AKGQEOJGHLYA@isocpp.org Fri Mar 04 20:48:11 2016
Return-path: <std-proposals+bncBDFLZXWOVYIBB6GM463AKGQEOJGHLYA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yk0-f198.google.com ([209.85.160.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDFLZXWOVYIBB6GM463AKGQEOJGHLYA@isocpp.org>)
	id 1abvhq-0001Nx-LN
	for gclcip-std-proposals@m.gmane.org; Fri, 04 Mar 2016 20:48:10 +0100
Original-Received: by mail-yk0-f198.google.com with SMTP id m4sf69358649yke.2
        for <gclcip-std-proposals@m.gmane.org>; Fri, 04 Mar 2016 11:48:10 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :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=MEX0rSUeG4PimnSdqV6OENhHC7yROUMXD7mht/YmHwk=;
        b=Mg4uqt/Ocu8FnfDEqs/0Yr3V/X9NuP0fDBFg2oYm5amom2yoC0Ogcl2S3zkNK9ZBU+
         G3datlFTIM3t8WTrQdPqa1EydFQdO5NH3DyLv9xcBdydN0woDzGPn6RmBvcP/n100NXH
         +ZY0/MMpXb0ipYu6woF4LU6UBgrUwPvjff3uodHUQKA5gfCJBiAdSWuUg1Pk5fFSODpY
         jBcqkcJDN5tivof1M7ILplCD60+ds4ldFYm0S65DtyQZpJVaw9l0C+ZjJ52duSVUzfgE
         zZN3hQAVW74WTKR17njY4yoSM2uHiUUNFyGlxXAlVCL4yQ/H/221Q8HzAo2cUZrBTfJq
         6iOQ==
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: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=MEX0rSUeG4PimnSdqV6OENhHC7yROUMXD7mht/YmHwk=;
        b=HgLHF5eXcvs2M/FYnFJ0gXcr5YZKrd9rYptNQPFwv75xdWBfJCi/rV3wE0798srVis
         OyOlTsBXDMtSpJOUwXXW6r5Jn+EN2ZQi0j3/7kHCdampaorD8xuntl2vUuZ/HaNGADRw
         L9aYU++OukeDe1OxHOXps0abIKyRmsxySKiz1YGe3kbdZ3K9T7tLmZLNRpkRwxNLfP7o
         gvOKBj1z11bKhWb7e1SIQkNDhtMs/gXFDCYJLXeVF+7OLmijmIG1qfSQYDGAjhaCxteV
         a5f+OQM1BV53mLLHvQhvHaTPiKqbaiC3PlhUAUSdBi4QIExu+cm6h+f40D7Jydeb+yI4
         HjpQ==
X-Gm-Message-State: AD7BkJIQVWS09GYPZiGQ9nanepWI+6FAKJr8ua9SGWlpSfOYadv4eN/rwLd3Xydt+k00dA==
X-Received: by 10.140.28.71 with SMTP id 65mr7186602qgy.1.1457120889665;
        Fri, 04 Mar 2016 11:48:09 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.14.138 with SMTP id 132ls297840ioo.27.gmail; Fri, 04 Mar
 2016 11:48:08 -0800 (PST)
X-Received: by 10.50.109.230 with SMTP id hv6mr24458igb.2.1457120888279;
        Fri, 04 Mar 2016 11:48:08 -0800 (PST)
In-Reply-To: <3c8bb230-c83b-4c18-95b6-1cc32caae76d@isocpp.org>
X-Original-Sender: wkaras@yahoo.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: <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>
X-Original-From: Walt Karas <wkaras@yahoo.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:24927
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/24927>

------=_Part_1228_1211116281.1457120887341
Content-Type: multipart/alternative; 
	boundary="----=_Part_1229_67359125.1457120887341"

------=_Part_1229_67359125.1457120887341
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

I'm a complete beginner with variadic templates.  I think the equivalent=20
with your proposal is maybe:

template <class Target_, typename Member_type_, Member_type_ Target_::*=20
mptr_>
struct A_component
  {
    Target_ Target;
    Member_type_ Member_type;
    static const Target::Member_type *mptr =3D mptr_
  };

#define COMPONENTS(C) A_component<C, typename<C, is_member_object_pointer=
=20
|| is_parent>, typedef<C, is_member_object_pointer || is_parent> >...

But still there is the issue of needing member pointers to parent/base=20
classes.

On Friday, March 4, 2016 at 1:02:44 PM UTC-5, Cleiton Santoia wrote:
>
>
>    Reflection ? p0255r0=20
> <http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0255r0.pdf>
>
> X<typedef<A>...> solves your case....
>
>
>
>
> Em sexta-feira, 4 de mar=C3=A7o de 2016 02:01:15 UTC-3, Walt Karas escrev=
eu:
>>
>> Another possible approach generic mapping of operations to components=20
>> would be to accept the idiom ++C , C a class name, as a template=20
>> parameter.  The compiler would implicitly expand ++C to multiple=20
>> parameters, namely C itself, followed by a pair of parameters for each=
=20
>> component of C.  Each pair would consist of  the type T of the component=
,=20
>> followed by the member pointer of type T C::* to the component.  (The=20
>> reason for using ++ is to suggest iteration of over the components.)  Fo=
r=20
>> example, for this class:
>>
>> struct A { int i, j; double x; };
>>
>> the template instantiation:
>>
>> X<++A>
>>
>> would be equivalent to:
>>
>> X<A, int, &C::i, int, &C::j, double, &C::x>
>>
>> This hopefully would allow variadic templates to create reasonable=20
>> default comparison, input and display, persistence, endiance swap, hashi=
ng,=20
>> etc. operations for many classes.  A difficult issue would be wether the=
=20
>> context where X<++A> is instantiated would be required to have access to=
=20
>> all the implicitly reverenced component types and components themselves.
>>
>> Perhaps the compiler could also except the idiomatic template parameter=
=20
>> --C, which would lay out the components in reverse order (of destruction=
)=20
>> rather than forward order (of construction).
>>
>

--=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/7db63114-8e12-4d38-94e4-39f0061362de%40isocpp.or=
g.

------=_Part_1229_67359125.1457120887341
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I&#39;m a complete beginner with variadic templates.=C2=A0=
 I think the equivalent with your proposal is maybe:<br><br>template &lt;cl=
ass Target_, typename Member_type_, Member_type_ Target_::* mptr_&gt;<br>st=
ruct A_component<br>=C2=A0 {<br>=C2=A0=C2=A0=C2=A0 Target_ Target;<br>=C2=
=A0=C2=A0=C2=A0 Member_type_ Member_type;<br>=C2=A0=C2=A0=C2=A0 static cons=
t Target::Member_type *mptr =3D mptr_<br>=C2=A0 };<br><br>#define COMPONENT=
S(C) A_component&lt;C, typename&lt;C, is_member_object_pointer || is_parent=
&gt;, typedef&lt;C, is_member_object_pointer || is_parent&gt; &gt;...<br><b=
r>But still there is the issue of needing member pointers to parent/base cl=
asses.<br><br>On Friday, March 4, 2016 at 1:02:44 PM UTC-5, Cleiton Santoia=
 wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.=
8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><=
br></div>=C2=A0 =C2=A0Reflection ?=C2=A0<a href=3D"http://open-std.org/JTC1=
/SC22/WG21/docs/papers/2016/p0255r0.pdf" target=3D"_blank" rel=3D"nofollow"=
 onmousedown=3D"this.href=3D&#39;http://www.google.com/url?q\75http%3A%2F%2=
Fopen-std.org%2FJTC1%2FSC22%2FWG21%2Fdocs%2Fpapers%2F2016%2Fp0255r0.pdf\46s=
a\75D\46sntz\0751\46usg\75AFQjCNFkSi3VdFDFaygG2yLv-eC_hWmqFg&#39;;return tr=
ue;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\75http%3A%2F%2=
Fopen-std.org%2FJTC1%2FSC22%2FWG21%2Fdocs%2Fpapers%2F2016%2Fp0255r0.pdf\46s=
a\75D\46sntz\0751\46usg\75AFQjCNFkSi3VdFDFaygG2yLv-eC_hWmqFg&#39;;return tr=
ue;">p0255r0</a><div><br></div><div>X&lt;typedef&lt;A&gt;...&gt; solves you=
r case....</div><div><br></div><div><br></div><div><br><br>Em sexta-feira, =
4 de mar=C3=A7o de 2016 02:01:15 UTC-3, Walt Karas  escreveu:<blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #cc=
c solid;padding-left:1ex"><div dir=3D"ltr">Another possible approach generi=
c mapping of operations to components would be to accept the idiom ++C , C =
a class name, as a template parameter.=C2=A0 The compiler would implicitly =
expand ++C to multiple parameters, namely C itself, followed by a pair of p=
arameters for each component of C.=C2=A0 Each pair would consist of=C2=A0 t=
he type T of the component, followed by the member pointer of type T C::* t=
o the component.=C2=A0 (The reason for using ++ is to suggest iteration of =
over the components.)=C2=A0 For example, for this class:<br><br>struct A { =
int i, j; double x; };<br><br>the template instantiation:<br><br>X&lt;++A&g=
t;<br><br>would be equivalent to:<br><br>X&lt;A, int, &amp;C::i, int, &amp;=
C::j, double, &amp;C::x&gt;<br><br>This hopefully would allow variadic temp=
lates to create reasonable default comparison, input and display, persisten=
ce, endiance swap, hashing, etc. operations for many classes.=C2=A0 A diffi=
cult issue would be wether the context where X&lt;++A&gt; is instantiated w=
ould be required to have access to all the implicitly reverenced component =
types and components themselves.<br><br>Perhaps the compiler could also exc=
ept the idiomatic template parameter --C, which would lay out the component=
s in reverse order (of destruction) rather than forward order (of construct=
ion).<br></div></blockquote></div></div></blockquote></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/7db63114-8e12-4d38-94e4-39f0061362de%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/7db63114-8e12-4d38-94e4-39f0061362de=
%40isocpp.org</a>.<br />

------=_Part_1229_67359125.1457120887341--
------=_Part_1228_1211116281.1457120887341--

.
