Topic: Do we need a "foreach class component


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Mon, 2 May 2016 20:12:39 -0700 (PDT)
Raw View
------=_Part_2240_1175758374.1462245159330
Content-Type: multipart/alternative;
 boundary="----=_Part_2241_1266966086.1462245159330"

------=_Part_2241_1266966086.1462245159330
Content-Type: text/plain; charset=UTF-8



On Monday, May 2, 2016 at 7:50:32 PM UTC-4, Walt Karas wrote:
>
> I've been playing with some code to "tease out" the underlying "foreach
> class component" behavior in the default assignment operator, and use it to
> create a "default" equality operator:
>
> https://github.com/wkaras/C-plus-plus-library-default-operators
>
> Obviously, this code is too intrusive and ugly to be a real solution.  But
> I think it does show that, if we can expose the iteration over components
> already present in the default operators (in cleaner way), that allows for
> making useful stuff in library land, including comparison operators.
>
> Has there been any discussion of how to get comparison operators from the
> reflection proposals, rather than making them primitives?
>

That would require:

1: Reflection to be finished first. It's not even a TS yet. Whereas the
default comparison proposal has a decent chance of making C++17.

2: To reflect over private members as well as public. And reflection may
not allow that unless the reflecting function is a friend of the type.
Whereas the default comparison operators are always friends.

3: People to explicitly write said code for their types. Half the point of
default comparison operators is that they exist *by default*. Even if you
have helper functions that will implement the iteration/comparison, you
still have to manually write an implementation of each operator that calls
them.

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a4fb1e04-135c-44b8-a94c-5ae4ceb35d75%40isocpp.org.

------=_Part_2241_1266966086.1462245159330
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Monday, May 2, 2016 at 7:50:32 PM UTC-4, Walt K=
aras 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">I&=
#39;ve been playing with some code to &quot;tease out&quot; the underlying =
&quot;foreach class component&quot; behavior in the default assignment oper=
ator, and use it to create a &quot;default&quot; equality operator:<br><br>=
<a href=3D"https://github.com/wkaras/C-plus-plus-library-default-operators"=
 target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https:/=
/www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fwkaras%2FC-plus-plus-li=
brary-default-operators\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHNNwkUj7ioJ=
8DVekLu_9Xq51r3EA&#39;;return true;" onclick=3D"this.href=3D&#39;https://ww=
w.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fwkaras%2FC-plus-plus-libra=
ry-default-operators\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHNNwkUj7ioJ8DV=
ekLu_9Xq51r3EA&#39;;return true;">https://github.com/wkaras/C-<wbr>plus-plu=
s-library-default-<wbr>operators</a><br><br>Obviously, this code is too int=
rusive and ugly to be a real solution.=C2=A0 But I think it does show that,=
 if we can expose the iteration over components already present in the defa=
ult operators (in cleaner way), that allows for making useful stuff in libr=
ary land, including comparison operators.<br><br>Has there been any discuss=
ion of how to get comparison operators from the reflection proposals, rathe=
r than making them primitives?<br></div></blockquote><div><br>That would re=
quire:<br></div><div><br>1: Reflection to be finished first. It&#39;s not e=
ven a TS yet. Whereas the default comparison proposal has a decent chance o=
f making C++17.<br><br>2: To reflect over private members as well as public=
.. And reflection may not allow that unless the reflecting function is a fri=
end of the type. Whereas the default comparison operators are always friend=
s.<br><br>3: People to explicitly write said code for their types. Half the=
 point of default comparison operators is that they exist=C2=A0<i>by defaul=
t</i>. Even if you have helper functions that will implement the iteration/=
comparison, you still have to manually write an implementation of each oper=
ator that calls them.<br></div></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/a4fb1e04-135c-44b8-a94c-5ae4ceb35d75%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a4fb1e04-135c-44b8-a94c-5ae4ceb35d75=
%40isocpp.org</a>.<br />

------=_Part_2241_1266966086.1462245159330--
------=_Part_2240_1175758374.1462245159330--

.