Topic: Facilitating composition with using declarations


Author: Vincent Reverdy <vince.rev@gmail.com>
Date: Fri, 29 Jan 2016 19:03:45 -0800 (PST)
Raw View
------=_Part_644_1305200454.1454123025048
Content-Type: multipart/alternative;
 boundary="----=_Part_645_1163348406.1454123025049"

------=_Part_645_1163348406.1454123025049
Content-Type: text/plain; charset=UTF-8

Hello.

What I am describing here, is just a rough idea I had for some time, and I
just wanted to have some opinion on it (for now, I don't plan to draft any
proposal about it).
The using declarations are convenient for inheriting constructors and to
introduce a member of a base class into the scope of a derived class.
It would be very convenient to be able to do the same kind of approach for
composition, to avoid writing forwarding functions.

The idea would be the following:

struct my_vector
{
   // Composition
   including my_component = std::vector<int>; // "including" is a
hypothetical new keyword (don't focus on the name, anything could be chosen
instead)
   using my_component::size; // Creates a member function size, that will
call v.size(), with the exact same characteristics
   using my_component::at; // Creates all the at members that will call
v.at(...)
   using my_component::operator[]; // Same thing here, for operator[]

   // Data members
   private:
   my_component v; // Declares v as std::vector<int>
};

It would need a new keyword, that would create a special "alias" for a
particular type.
The class should declare zero or one member with this alias (when zero
member are explicitly declared, one is implicitly generated)
Then, the syntax *using "an_alias"::"a member function"*, generates
forwarding functions at compile time.

I think having something of that kind could be very useful and could
facilitate composition without the need of writing forwarding functions.
What's your point of view on that?

Thank you very much,
Vincent

--

---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.

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

<div dir=3D"ltr">Hello.<br><br>What I am describing here, is just a rough i=
dea I had for some time, and I just wanted to have some opinion on it (for =
now, I don&#39;t plan to draft any proposal about it).<br>The using declara=
tions are convenient for inheriting constructors and to introduce a member =
of a base class into the scope of a derived class.<br>It would be very conv=
enient to be able to do the same kind of approach for composition, to avoid=
 writing forwarding functions.<br><br>The idea would be the following:<br><=
br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250)=
; border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px;=
 word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprett=
yprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> my_vector<br=
></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0<=
/span><span style=3D"color: #800;" class=3D"styled-by-prettify">// Composit=
ion</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0including my_component </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">vector</span><span style=3D"color: #080;" class=3D"styled-by-prettify">&=
lt;int&gt;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #800;" class=3D"styled-by-prettify">// &quot;including=
&quot; is a hypothetical new keyword (don&#39;t focus on the name, anything=
 could be chosen instead)</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">using</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> my_component</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">size</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// Creat=
es a member function size, that will call v.size(), with the exact same cha=
racteristics</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br>=C2=A0 =C2=A0</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">using</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> my_component</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">a=
t</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #800;" class=3D"styled-by-prettify">// Creates all the at membe=
rs that will call v.at(...)</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>=C2=A0 =C2=A0</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">using</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> my_component</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">operator</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">[];</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//=
 Same thing here, for operator[]</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0</span><span style=3D"color: #=
800;" class=3D"styled-by-prettify">// Data members</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">private</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0my_component v</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">// Declares v as std::vector&lt;int&g=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span></div=
></code></div><br>It would need a new keyword, that would create a special =
&quot;alias&quot; for a particular type. <br>The class should declare zero =
or one member with this alias (when zero member are explicitly declared, on=
e is implicitly generated)<br>Then, the syntax <b><span style=3D"font-famil=
y: courier new,monospace;">using &quot;an_alias&quot;::&quot;a member funct=
ion&quot;</span></b>, generates forwarding functions at compile time.<br><b=
r>I think having something of that kind could be very useful and could faci=
litate composition without the need of writing forwarding functions.<br>Wha=
t&#39;s your point of view on that?<br><br>Thank you very much,<br>Vincent<=
br></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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

------=_Part_645_1163348406.1454123025049--
------=_Part_644_1305200454.1454123025048--

.


Author: Tony V E <tvaneerd@gmail.com>
Date: Sat, 30 Jan 2016 12:50:39 -0500
Raw View
<html><head></head><body lang=3D"en-US" style=3D"background-color: rgb(255,=
 255, 255); line-height: initial;">                                        =
                                              <div style=3D"width: 100%; fo=
nt-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif=
; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, =
255, 255);">There have been some discussions here (and maybe a proposal?) o=
n "mix ins". I think this is of the same vein. You might try searching for =
"mix ins" (which is, unfortunately, an ambiguous search string).&nbsp;</div=
><div style=3D"width: 100%; font-size: initial; font-family: Calibri, 'Slat=
e Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-align: initia=
l; background-color: rgb(255, 255, 255);"><br></div>                       =
                                                                           =
                                   <div style=3D"width: 100%; font-size: in=
itial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rg=
b(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);"=
><br style=3D"display:initial"></div>                                      =
                                                                           =
                                                                           =
       <div style=3D"font-size: initial; font-family: Calibri, 'Slate Pro',=
 sans-serif, sans-serif; color: rgb(31, 73, 125); text-align: initial; back=
ground-color: rgb(255, 255, 255);">Sent&nbsp;from&nbsp;my&nbsp;BlackBerry&n=
bsp;portable&nbsp;Babbage&nbsp;Device</div>                                =
                                                                           =
                                                                       <tab=
le width=3D"100%" style=3D"background-color:white;border-spacing:0px;"> <tb=
ody><tr><td colspan=3D"2" style=3D"font-size: initial; text-align: initial;=
 background-color: rgb(255, 255, 255);">                           <div sty=
le=3D"border-style: solid none none; border-top-color: rgb(181, 196, 223); =
border-top-width: 1pt; padding: 3pt 0in 0in; font-family: Tahoma, 'BB Alpha=
 Sans', 'Slate Pro'; font-size: 10pt;">  <div><b>From: </b>Vincent Reverdy<=
/div><div><b>Sent: </b>Friday, January 29, 2016 10:03 PM</div><div><b>To: <=
/b>ISO C++ Standard - Future Proposals</div><div><b>Reply To: </b>std-propo=
sals@isocpp.org</div><div><b>Subject: </b>[std-proposals] Facilitating comp=
osition with using declarations</div></div></td></tr></tbody></table><div s=
tyle=3D"border-style: solid none none; border-top-color: rgb(186, 188, 209)=
; border-top-width: 1pt; font-size: initial; text-align: initial; backgroun=
d-color: rgb(255, 255, 255);"></div><br><div id=3D"_originalContent" style=
=3D""><div dir=3D"ltr">Hello.<br><br>What I am describing here, is just a r=
ough idea I had for some time, and I just wanted to have some opinion on it=
 (for now, I don't plan to draft any proposal about it).<br>The using decla=
rations are convenient for inheriting constructors and to introduce a membe=
r of a base class into the scope of a derived class.<br>It would be very co=
nvenient to be able to do the same kind of approach for composition, to avo=
id writing forwarding functions.<br><br>The idea would be the following:<br=
><br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 25=
0); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1p=
x; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpre=
ttyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">struct<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> my_vector<=
br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp=
;</span><span style=3D"color: #800;" class=3D"styled-by-prettify">// Compos=
ition</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&=
nbsp; &nbsp;including my_component </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">vector</span><span style=3D"color: #080;" class=3D"styled-by-prettify">=
&lt;int&gt;</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #800;" class=3D"styled-by-prettify">// "including" is=
 a hypothetical new keyword (don't focus on the name, anything could be cho=
sen instead)</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br>&nbsp; &nbsp;</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">using</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> my_component</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">s=
ize</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #800;" class=3D"styled-by-prettify">// Creates a member funct=
ion size, that will call v.size(), with the exact same characteristics</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbs=
p;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">using</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> my_component=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">at</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">// Creates all the at members that will call=
 v.at(...)</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>&nbsp; &nbsp;</span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">using</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> my_component</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">::</span><span style=3D"color: #008;" class=3D"styled-by-prettify">ope=
rator</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[];</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #800;" class=3D"styled-by-prettify">// Same thing here, f=
or operator[]</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br><br>&nbsp; &nbsp;</span><span style=3D"color: #800;" class=3D"styled=
-by-prettify">// Data members</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>&nbsp; &nbsp;</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">private</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>&nbsp; &nbsp;my_component v</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">// Declares v as std::vector&lt;int&gt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">};</span></div></code></div><br>It=
 would need a new keyword, that would create a special "alias" for a partic=
ular type. <br>The class should declare zero or one member with this alias =
(when zero member are explicitly declared, one is implicitly generated)<br>=
Then, the syntax <b><span style=3D"font-family: courier new,monospace;">usi=
ng "an_alias"::"a member function"</span></b>, generates forwarding functio=
ns at compile time.<br><br>I think having something of that kind could be v=
ery useful and could facilitate composition without the need of writing for=
warding functions.<br>What's your point of view on that?<br><br>Thank you v=
ery much,<br>Vincent<br></div>

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" 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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br>
<br><!--end of _originalContent --></div></body></html>

<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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

.


Author: Jonathan Coe <jbcoe@me.com>
Date: Sat, 30 Jan 2016 18:01:27 +0000
Raw View
--001a114770acd5880b052a90f0d3
Content-Type: text/plain; charset=UTF-8

On 30 January 2016 at 03:03, Vincent Reverdy <vince.rev@gmail.com> wrote:

> Hello.
>
> What I am describing here, is just a rough idea I had for some time, and I
> just wanted to have some opinion on it (for now, I don't plan to draft any
> proposal about it).
> The using declarations are convenient for inheriting constructors and to
> introduce a member of a base class into the scope of a derived class.
> It would be very convenient to be able to do the same kind of approach for
> composition, to avoid writing forwarding functions.
>
> The idea would be the following:
>
> struct my_vector
> {
>    // Composition
>    including my_component = std::vector<int>; // "including" is a
> hypothetical new keyword (don't focus on the name, anything could be chosen
> instead)
>    using my_component::size; // Creates a member function size, that will
> call v.size(), with the exact same characteristics
>    using my_component::at; // Creates all the at members that will call
> v.at(...)
>    using my_component::operator[]; // Same thing here, for operator[]
>
>    // Data members
>    private:
>    my_component v; // Declares v as std::vector<int>
> };
>
> It would need a new keyword, that would create a special "alias" for a
> particular type.
> The class should declare zero or one member with this alias (when zero
> member are explicitly declared, one is implicitly generated)
> Then, the syntax *using "an_alias"::"a member function"*, generates
> forwarding functions at compile time.
>
> I think having something of that kind could be very useful and could
> facilitate composition without the need of writing forwarding functions.
> What's your point of view on that?
>
>
It's a nice idea. Something very similar can currently be accomplished
using private inheritance:

```
struct my_vector : private std::vector<int>
{
   using std::vector<int>::size;
   using std::vector<int>::at;
   using std::vector<int>::operator[];
};
```

Does your proposed syntax give us any new functionality?

Thank you very much,
> Vincent
>
> --
>
> ---
> 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
> https://groups.google.com/a/isocpp.org/group/std-proposals/.
>

--

---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.

--001a114770acd5880b052a90f0d3
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On 30 January 2016 at 03:03, Vincent Reverdy <span dir=3D"=
ltr">&lt;<a href=3D"mailto:vince.rev@gmail.com" target=3D"_blank">vince.rev=
@gmail.com</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=
=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px =
0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-l=
eft-style:solid;padding-left:1ex"><div dir=3D"ltr">Hello.<br><br>What I am =
describing here, is just a rough idea I had for some time, and I just wante=
d to have some opinion on it (for now, I don&#39;t plan to draft any propos=
al about it).<br>The using declarations are convenient for inheriting const=
ructors and to introduce a member of a base class into the scope of a deriv=
ed class.<br>It would be very convenient to be able to do the same kind of =
approach for composition, to avoid writing forwarding functions.<br><br>The=
 idea would be the following:<br><br><div style=3D"background-color:rgb(250=
,250,250);border:1px solid rgb(187,187,187);word-wrap:break-word"><code><di=
v><span style=3D"color:rgb(0,0,136)">struct</span><span style=3D"color:rgb(=
0,0,0)"> my_vector<br></span><span style=3D"color:rgb(102,102,0)">{</span><=
span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0</span><span style=3D"colo=
r:rgb(136,0,0)">// Composition</span><span style=3D"color:rgb(0,0,0)"><br>=
=C2=A0 =C2=A0including my_component </span><span style=3D"color:rgb(102,102=
,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> std</span><span style=3D"c=
olor:rgb(102,102,0)">::</span><span style=3D"color:rgb(0,0,0)">vector</span=
><span style=3D"color:rgb(0,136,0)">&lt;int&gt;</span><span style=3D"color:=
rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"> </span><span styl=
e=3D"color:rgb(136,0,0)">// &quot;including&quot; is a hypothetical new key=
word (don&#39;t focus on the name, anything could be chosen instead)</span>=
<span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0</span><span style=3D"col=
or:rgb(0,0,136)">using</span><span style=3D"color:rgb(0,0,0)"> my_component=
</span><span style=3D"color:rgb(102,102,0)">::</span><span style=3D"color:r=
gb(0,0,0)">size</span><span style=3D"color:rgb(102,102,0)">;</span><span st=
yle=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0,0)">// Crea=
tes a member function size, that will call v.size(), with the exact same ch=
aracteristics</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0</spa=
n><span style=3D"color:rgb(0,0,136)">using</span><span style=3D"color:rgb(0=
,0,0)"> my_component</span><span style=3D"color:rgb(102,102,0)">::</span><s=
pan style=3D"color:rgb(0,0,0)">at</span><span style=3D"color:rgb(102,102,0)=
">;</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb=
(136,0,0)">// Creates all the at members that will call <a href=3D"http://v=
..at" target=3D"_blank">v.at</a>(...)</span><span style=3D"color:rgb(0,0,0)"=
><br>=C2=A0 =C2=A0</span><span style=3D"color:rgb(0,0,136)">using</span><sp=
an style=3D"color:rgb(0,0,0)"> my_component</span><span style=3D"color:rgb(=
102,102,0)">::</span><span style=3D"color:rgb(0,0,136)">operator</span><spa=
n style=3D"color:rgb(102,102,0)">[];</span><span style=3D"color:rgb(0,0,0)"=
> </span><span style=3D"color:rgb(136,0,0)">// Same thing here, for operato=
r[]</span><span style=3D"color:rgb(0,0,0)"><br><br>=C2=A0 =C2=A0</span><spa=
n style=3D"color:rgb(136,0,0)">// Data members</span><span style=3D"color:r=
gb(0,0,0)"><br>=C2=A0 =C2=A0</span><span style=3D"color:rgb(0,0,136)">priva=
te</span><span style=3D"color:rgb(102,102,0)">:</span><span style=3D"color:=
rgb(0,0,0)"><br>=C2=A0 =C2=A0my_component v</span><span style=3D"color:rgb(=
102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D=
"color:rgb(136,0,0)">// Declares v as std::vector&lt;int&gt;</span><span st=
yle=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(102,102,0)">};=
</span></div></code></div><br>It would need a new keyword, that would creat=
e a special &quot;alias&quot; for a particular type. <br>The class should d=
eclare zero or one member with this alias (when zero member are explicitly =
declared, one is implicitly generated)<br>Then, the syntax <b><span style=
=3D"font-family:&#39;courier new&#39;,monospace">using &quot;an_alias&quot;=
::&quot;a member function&quot;</span></b>, generates forwarding functions =
at compile time.<br><br>I think having something of that kind could be very=
 useful and could facilitate composition without the need of writing forwar=
ding functions.<br>What&#39;s your point of view on that?<br><br></div></bl=
ockquote><div><br></div><div>It&#39;s a nice idea. Something very similar c=
an currently be accomplished using private inheritance:<div><br></div><div>=
```<br>struct my_vector : private=C2=A0std::vector&lt;int&gt;<br>{<br>=C2=
=A0 =C2=A0using=C2=A0std::vector&lt;int&gt;::size;<br>=C2=A0 =C2=A0using=C2=
=A0std::vector&lt;int&gt;::at;=C2=A0<br>=C2=A0 =C2=A0using=C2=A0std::vector=
&lt;int&gt;::operator[];=C2=A0<br>};<br>```</div></div><div>=C2=A0</div><di=
v>Does your proposed syntax give us any new functionality?</div><div><br></=
div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bor=
der-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:sol=
id;padding-left:1ex"><div dir=3D"ltr">Thank you very much,<br>Vincent<span =
class=3D""><font color=3D"#888888"><br></font></span></div><span class=3D""=
><font color=3D"#888888">

<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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"https://groups.google.com/a/isocpp.org/group=
/std-proposals/" target=3D"_blank">https://groups.google.com/a/isocpp.org/g=
roup/std-proposals/</a>.<br>
</font></span></blockquote></div><br></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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

--001a114770acd5880b052a90f0d3--

.


Author: Larry Evans <cppljevans@suddenlink.net>
Date: Sat, 30 Jan 2016 13:14:18 -0600
Raw View
On 01/29/2016 09:03 PM, Vincent Reverdy wrote:
> Hello.
>
> What I am describing here, is just a rough idea I had for some time, and
> I just wanted to have some opinion on it (for now, I don't plan to draft
> any proposal about it).
> The using declarations are convenient for inheriting constructors and to
> introduce a member of a base class into the scope of a derived class.
> It would be very convenient to be able to do the same kind of approach
> for composition, to avoid writing forwarding functions.
>
> The idea would be the following:
>

> struct my_vector
> {
[snip]
>    using my_component::size;
>    using my_component::at;
>    using my_component::operator[];
>
>    // Data members
>    private:
>     my_component v;// Declares v as std::vector<int>
> };
Why not factor out the my_component?:

struct my_vector
{
   // Composition
   including my_component = std::vector<int>;
   using my_component::
     { size
     , at
     , operator[]
     }
     ;
   // Data members
   private:
   my_component v; // Declares v as std::vector<int>
};

--

---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sat, 30 Jan 2016 22:51:57 +0100
Raw View
This is a multi-part message in MIME format.
--------------080300030001060405080604
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 30/01/2016 04:03, Vincent Reverdy a =C3=A9crit :
> Hello.
>
> What I am describing here, is just a rough idea I had for some time,=20
> and I just wanted to have some opinion on it (for now, I don't plan to=20
> draft any proposal about it).
> The using declarations are convenient for inheriting constructors and=20
> to introduce a member of a base class into the scope of a derived class.
> It would be very convenient to be able to do the same kind of approach=20
> for composition, to avoid writing forwarding functions.
>
> The idea would be the following:
>
> |
> structmy_vector
> {
> // Composition
>    including my_component =3Dstd::vector<int>;// "including" is a=20
> hypothetical new keyword (don't focus on the name, anything could be=20
> chosen instead)
> usingmy_component::size;// Creates a member function size, that will=20
> call v.size(), with the exact same characteristics
> usingmy_component::at;// Creates all the at members that will call=20
> v.at(...)
> usingmy_component::operator[];// Same thing here, for operator[]
>
> // Data members
> private:
>    my_component v;// Declares v as std::vector<int>
> };
> |
>
> It would need a new keyword, that would create a special "alias" for a=20
> particular type.
> The class should declare zero or one member with this alias (when zero=20
> member are explicitly declared, one is implicitly generated)
> Then, the syntax *using "an_alias"::"a member function"*, generates=20
> forwarding functions at compile time.
>
> I think having something of that kind could be very useful and could=20
> facilitate composition without the need of writing forwarding functions.
> What's your point of view on that?
>

Hi,

there is a proposal that I like and explains the problem that must be=20
addressed, but I don't what is his state. It is Opaque Typedefs [1]

Vicente

[1] p0109r0. - Function Aliases + Extended Inheritance =3D Opaque Typedefs
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0109r0.pdf

--=20

---=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.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-propos=
als/.

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

<html>
  <head>
    <meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Le 30/01/2016 04:03, Vincent Reverdy a
      =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote
      cite=3D"mid:01b89d1d-2a56-4059-92ca-b088f69372ea@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr">Hello.<br>
        <br>
        What I am describing here, is just a rough idea I had for some
        time, and I just wanted to have some opinion on it (for now, I
        don't plan to draft any proposal about it).<br>
        The using declarations are convenient for inheriting
        constructors and to introduce a member of a base class into the
        scope of a derived class.<br>
        It would be very convenient to be able to do the same kind of
        approach for composition, to avoid writing forwarding functions.<br=
>
        <br>
        The idea would be the following:<br>
        <br>
        <div class=3D"prettyprint" style=3D"background-color: rgb(250, 250,
          250); border-color: rgb(187, 187, 187); border-style: solid;
          border-width: 1px; word-wrap: break-word;"><code
            class=3D"prettyprint">
            <div class=3D"subprettyprint"><span style=3D"color: #008;"
                class=3D"styled-by-prettify">struct</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify">
                my_vector<br>
              </span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">{</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0</span><span style=3D"color: #800;"
                class=3D"styled-by-prettify">// Composition</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0including my_component </span><span style=3D"c=
olor:
                #660;" class=3D"styled-by-prettify">=3D</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> std</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">vector<=
/span><span
                style=3D"color: #080;" class=3D"styled-by-prettify">&lt;int=
&gt;</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #800;" class=3D"styled-by-prettify">//
                "including" is a hypothetical new keyword (don't focus
                on the name, anything could be chosen instead)</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0</span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">using</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify">
                my_component</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">::</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify">size</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #800;" class=3D"styled-by-prettify">//
                Creates a member function size, that will call v.size(),
                with the exact same characteristics</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0</span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">using</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify">
                my_component</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">::</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify">at</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #800;" class=3D"styled-by-prettify">//
                Creates all the at members that will call v.at(...)</span><=
span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0</span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">using</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify">
                my_component</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">::</span><span style=3D"color:
                #008;" class=3D"styled-by-prettify">operator</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">[];</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #800;" class=3D"styled-by-prettify">// Same
                thing here, for operator[]</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
                <br>
                =C2=A0 =C2=A0</span><span style=3D"color: #800;"
                class=3D"styled-by-prettify">// Data members</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0</span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">private</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">:</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                =C2=A0 =C2=A0my_component v</span><span style=3D"color: #66=
0;"
                class=3D"styled-by-prettify">;</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"> </span><span
                style=3D"color: #800;" class=3D"styled-by-prettify">//
                Declares v as std::vector&lt;int&gt;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
              </span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">};</span></div>
          </code></div>
        <br>
        It would need a new keyword, that would create a special "alias"
        for a particular type. <br>
        The class should declare zero or one member with this alias
        (when zero member are explicitly declared, one is implicitly
        generated)<br>
        Then, the syntax <b><span style=3D"font-family: courier
            new,monospace;">using "an_alias"::"a member function"</span></b=
>,
        generates forwarding functions at compile time.<br>
        <br>
        I think having something of that kind could be very useful and
        could facilitate composition without the need of writing
        forwarding functions.<br>
        What's your point of view on that?<br>
        <br>
      </div>
    </blockquote>
    <br>
    Hi,<br>
    <br>
    there is a proposal that I like and explains the problem that must
    be addressed, but I don't what is his state. It is Opaque Typedefs=C2=
=A0
    [1]<br>
    <br>
    Vicente<br>
    <br>
    <meta http-equiv=3D"content-type" content=3D"text/html; charset=3Dutf-8=
">
    [1] p0109r0. - Function Aliases + Extended Inheritance =3D Opaque
    Typedefs <br>
    <meta http-equiv=3D"content-type" content=3D"text/html; charset=3Dutf-8=
">
    <a class=3D"moz-txt-link-freetext" href=3D"http://www.open-std.org/jtc1=
/sc22/wg21/docs/papers/2015/p0109r0.pdf">http://www.open-std.org/jtc1/sc22/=
wg21/docs/papers/2015/p0109r0.pdf</a><br>
  </body>
</html>

<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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

--------------080300030001060405080604--

.


Author: David Krauss <potswa@gmail.com>
Date: Sun, 31 Jan 2016 13:26:41 +0800
Raw View
--Apple-Mail=_06A02708-BA06-4E26-808D-6D3CFE437FAF
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2016=E2=80=9301=E2=80=9331, at 5:51 AM, Vicente J. Botet Escriba <vice=
nte.botet@wanadoo.fr> wrote:
>=20
> there is a proposal that I like and explains the problem that must be add=
ressed, but I don't what is his state. It is Opaque Typedefs  [1]

Opaque typedefs are exclusive of composition. The proposal here does align =
with function aliases, the other side of that proposal. It=E2=80=99s slight=
ly more complicated because a member function alias would be bound to a mem=
ber.

The discussion in Kona was pretty contentious. The discussion was mostly hi=
gh-level and focused on the type system, not function aliases. Perhaps func=
tion aliases for ordinary classes could be a new proposal.


> On 2016=E2=80=9301=E2=80=9330, at 11:03 AM, Vincent Reverdy <vince.rev@gm=
ail.com> wrote:
>=20
>    // Composition
>    including my_component =3D std::vector<int>; // "including" is a hypot=
hetical new keyword (don't focus on the name, anything could be chosen inst=
ead)


What happens if my_component is used to declare several members? Why not fo=
rgo the keyword and allow using at =3D v.at; or using v.at;?

--=20

---=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.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-propos=
als/.

--Apple-Mail=_06A02708-BA06-4E26-808D-6D3CFE437FAF
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2016=E2=80=9301=
=E2=80=9331, at 5:51 AM, Vicente J. Botet Escriba &lt;<a href=3D"mailto:vic=
ente.botet@wanadoo.fr" class=3D"">vicente.botet@wanadoo.fr</a>&gt; wrote:</=
div><br class=3D"Apple-interchange-newline"><div class=3D""><span style=3D"=
font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-al=
ign: start; text-indent: 0px; text-transform: none; white-space: normal; wi=
dows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-c=
olor: rgb(255, 255, 255); float: none; display: inline !important;" class=
=3D"">there is a proposal that I like and explains the problem that must be=
 addressed, but I don't what is his state. It is Opaque Typedefs&nbsp; [1]<=
/span><br style=3D"font-family: Helvetica; font-size: 12px; font-style: nor=
mal; font-variant: normal; font-weight: normal; letter-spacing: normal; orp=
hans: auto; text-align: start; text-indent: 0px; text-transform: none; whit=
e-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width=
: 0px; background-color: rgb(255, 255, 255);" class=3D""></div></blockquote=
></div><br class=3D""><div class=3D"">Opaque typedefs are exclusive of comp=
osition. The proposal here does align with function aliases, the other side=
 of that proposal. It=E2=80=99s slightly more complicated because a member =
function alias would be bound to a member.</div><div class=3D""><br class=
=3D""></div><div class=3D"">The discussion in Kona was pretty contentious. =
The discussion was mostly high-level and focused on the type system, not fu=
nction aliases. Perhaps function aliases for ordinary classes could be a ne=
w proposal.</div><div class=3D""><br class=3D""></div><div class=3D""><br c=
lass=3D""></div><div class=3D""><blockquote type=3D"cite" class=3D""><div c=
lass=3D"">On 2016=E2=80=9301=E2=80=9330, at 11:03 AM, Vincent Reverdy &lt;<=
a href=3D"mailto:vince.rev@gmail.com" class=3D"">vince.rev@gmail.com</a>&gt=
; wrote:</div><br class=3D"Apple-interchange-newline"><div class=3D""><span=
 class=3D"styled-by-prettify" style=3D"font-family: monospace;">&nbsp; &nbs=
p;</span><span class=3D"styled-by-prettify" style=3D"font-family: monospace=
; color: rgb(136, 0, 0);">// Composition</span><span class=3D"styled-by-pre=
ttify" style=3D"font-family: monospace;"><br class=3D"">&nbsp; &nbsp;includ=
ing my_component&nbsp;</span><span class=3D"styled-by-prettify" style=3D"fo=
nt-family: monospace; color: rgb(102, 102, 0);">=3D</span><span class=3D"st=
yled-by-prettify" style=3D"font-family: monospace;">&nbsp;std</span><span c=
lass=3D"styled-by-prettify" style=3D"font-family: monospace; color: rgb(102=
, 102, 0);">::</span><span class=3D"styled-by-prettify" style=3D"font-famil=
y: monospace;">vector</span><span class=3D"styled-by-prettify" style=3D"fon=
t-family: monospace; color: rgb(0, 136, 0);">&lt;int&gt;</span><span class=
=3D"styled-by-prettify" style=3D"font-family: monospace; color: rgb(102, 10=
2, 0);">;</span><span class=3D"styled-by-prettify" style=3D"font-family: mo=
nospace;">&nbsp;</span><span class=3D"styled-by-prettify" style=3D"font-fam=
ily: monospace; color: rgb(136, 0, 0);">// "including" is a hypothetical ne=
w keyword (don't focus on the name, anything could be chosen instead)</span=
><span class=3D"styled-by-prettify" style=3D"font-family: monospace;"><br c=
lass=3D""></span></div></blockquote></div><div class=3D""><div class=3D""><=
span class=3D"styled-by-prettify"><br class=3D""></span></div></div><div cl=
ass=3D"">What happens if <font face=3D"Courier" class=3D"">my_component</fo=
nt> is used to declare several members? Why not forgo the keyword and allow=
&nbsp;<font face=3D"Courier" class=3D"">using at =3D <a href=3D"http://v.at=
" class=3D"">v.at</a>;</font>&nbsp;or&nbsp;<span style=3D"font-family: Cour=
ier;" class=3D"">using </span><span style=3D"font-family: Courier;" class=
=3D""><a href=3D"http://v.at" class=3D"">v.at</a></span><span style=3D"font=
-family: Courier;" class=3D"">;</span>?</div><div class=3D""><br class=3D""=
></div></body></html>

<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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

--Apple-Mail=_06A02708-BA06-4E26-808D-6D3CFE437FAF--

.


Author: Mathias Gaunard <mathias.gaunard@gmail.com>
Date: Sun, 31 Jan 2016 14:28:34 +0000
Raw View
--001a114023b0564b65052aa21551
Content-Type: text/plain; charset=UTF-8

There are proposals to overload operator dot, which allows to do something
somewhat similar.
On 30 Jan 2016 03:03, "Vincent Reverdy" <vince.rev@gmail.com> wrote:

> Hello.
>
> What I am describing here, is just a rough idea I had for some time, and I
> just wanted to have some opinion on it (for now, I don't plan to draft any
> proposal about it).
> The using declarations are convenient for inheriting constructors and to
> introduce a member of a base class into the scope of a derived class.
> It would be very convenient to be able to do the same kind of approach for
> composition, to avoid writing forwarding functions.
>
> The idea would be the following:
>
> struct my_vector
> {
>    // Composition
>    including my_component = std::vector<int>; // "including" is a
> hypothetical new keyword (don't focus on the name, anything could be chosen
> instead)
>    using my_component::size; // Creates a member function size, that will
> call v.size(), with the exact same characteristics
>    using my_component::at; // Creates all the at members that will call
> v.at(...)
>    using my_component::operator[]; // Same thing here, for operator[]
>
>    // Data members
>    private:
>    my_component v; // Declares v as std::vector<int>
> };
>
> It would need a new keyword, that would create a special "alias" for a
> particular type.
> The class should declare zero or one member with this alias (when zero
> member are explicitly declared, one is implicitly generated)
> Then, the syntax *using "an_alias"::"a member function"*, generates
> forwarding functions at compile time.
>
> I think having something of that kind could be very useful and could
> facilitate composition without the need of writing forwarding functions.
> What's your point of view on that?
>
> Thank you very much,
> Vincent
>
> --
>
> ---
> 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
> https://groups.google.com/a/isocpp.org/group/std-proposals/.
>

--

---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.

--001a114023b0564b65052aa21551
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<p dir=3D"ltr">There are proposals to overload operator dot, which allows t=
o do something somewhat similar.</p>
<div class=3D"gmail_quote">On 30 Jan 2016 03:03, &quot;Vincent Reverdy&quot=
; &lt;<a href=3D"mailto:vince.rev@gmail.com">vince.rev@gmail.com</a>&gt; wr=
ote:<br type=3D"attribution"><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr=
">Hello.<br><br>What I am describing here, is just a rough idea I had for s=
ome time, and I just wanted to have some opinion on it (for now, I don&#39;=
t plan to draft any proposal about it).<br>The using declarations are conve=
nient for inheriting constructors and to introduce a member of a base class=
 into the scope of a derived class.<br>It would be very convenient to be ab=
le to do the same kind of approach for composition, to avoid writing forwar=
ding functions.<br><br>The idea would be the following:<br><br><div style=
=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-=
style:solid;border-width:1px;word-wrap:break-word"><code><div><span style=
=3D"color:#008">struct</span><span style=3D"color:#000"> my_vector<br></spa=
n><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =
=C2=A0</span><span style=3D"color:#800">// Composition</span><span style=3D=
"color:#000"><br>=C2=A0 =C2=A0including my_component </span><span style=3D"=
color:#660">=3D</span><span style=3D"color:#000"> std</span><span style=3D"=
color:#660">::</span><span style=3D"color:#000">vector</span><span style=3D=
"color:#080">&lt;int&gt;</span><span style=3D"color:#660">;</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#800">// &quot;including&quo=
t; is a hypothetical new keyword (don&#39;t focus on the name, anything cou=
ld be chosen instead)</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0</s=
pan><span style=3D"color:#008">using</span><span style=3D"color:#000"> my_c=
omponent</span><span style=3D"color:#660">::</span><span style=3D"color:#00=
0">size</span><span style=3D"color:#660">;</span><span style=3D"color:#000"=
> </span><span style=3D"color:#800">// Creates a member function size, that=
 will call v.size(), with the exact same characteristics</span><span style=
=3D"color:#000"><br>=C2=A0 =C2=A0</span><span style=3D"color:#008">using</s=
pan><span style=3D"color:#000"> my_component</span><span style=3D"color:#66=
0">::</span><span style=3D"color:#000">at</span><span style=3D"color:#660">=
;</span><span style=3D"color:#000"> </span><span style=3D"color:#800">// Cr=
eates all the at members that will call <a href=3D"http://v.at" target=3D"_=
blank">v.at</a>(...)</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0</sp=
an><span style=3D"color:#008">using</span><span style=3D"color:#000"> my_co=
mponent</span><span style=3D"color:#660">::</span><span style=3D"color:#008=
">operator</span><span style=3D"color:#660">[];</span><span style=3D"color:=
#000"> </span><span style=3D"color:#800">// Same thing here, for operator[]=
</span><span style=3D"color:#000"><br><br>=C2=A0 =C2=A0</span><span style=
=3D"color:#800">// Data members</span><span style=3D"color:#000"><br>=C2=A0=
 =C2=A0</span><span style=3D"color:#008">private</span><span style=3D"color=
:#660">:</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0my_component v</=
span><span style=3D"color:#660">;</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#800">// Declares v as std::vector&lt;int&gt;</span><s=
pan style=3D"color:#000"><br></span><span style=3D"color:#660">};</span></d=
iv></code></div><br>It would need a new keyword, that would create a specia=
l &quot;alias&quot; for a particular type. <br>The class should declare zer=
o or one member with this alias (when zero member are explicitly declared, =
one is implicitly generated)<br>Then, the syntax <b><span style=3D"font-fam=
ily:courier new,monospace">using &quot;an_alias&quot;::&quot;a member funct=
ion&quot;</span></b>, generates forwarding functions at compile time.<br><b=
r>I think having something of that kind could be very useful and could faci=
litate composition without the need of writing forwarding functions.<br>Wha=
t&#39;s your point of view on that?<br><br>Thank you very much,<br>Vincent<=
br></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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"https://groups.google.com/a/isocpp.org/group=
/std-proposals/" target=3D"_blank">https://groups.google.com/a/isocpp.org/g=
roup/std-proposals/</a>.<br>
</blockquote></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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

--001a114023b0564b65052aa21551--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sun, 31 Jan 2016 09:01:27 -0800 (PST)
Raw View
------=_Part_3465_1092221746.1454259687958
Content-Type: multipart/alternative;
 boundary="----=_Part_3466_712797116.1454259687959"

------=_Part_3466_712797116.1454259687959
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Saturday, January 30, 2016 at 4:52:03 PM UTC-5, Vicente J. Botet Escriba=
=20
wrote:
>
> Le 30/01/2016 04:03, Vincent Reverdy a =C3=A9crit :
>
> Hi,
>
> there is a proposal that I like and explains the problem that must be=20
> addressed, but I don't what is his state. It is Opaque Typedefs  [1]
>

According to this trip report=20
<https://botondballo.wordpress.com/2015/11/09/trip-report-c-standards-meeti=
ng-in-kona-october-2015/>,=20
it was sent back for improvements. The committee apparently liked the=20
"function alias" part a lot.

--=20

---=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.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-propos=
als/.

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

<div dir=3D"ltr"><br><br>On Saturday, January 30, 2016 at 4:52:03 PM UTC-5,=
 Vicente J. Botet Escriba wrote:<blockquote class=3D"gmail_quote" style=3D"=
margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;=
">
 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div>Le 30/01/2016 04:03, Vincent Reverdy a
      =C3=A9crit=C2=A0:<br>
    </div>
    <br>
    Hi,<br>
    <br>
    there is a proposal that I like and explains the problem that must
    be addressed, but I don&#39;t what is his state. It is Opaque Typedefs=
=C2=A0
    [1]<br></div></blockquote><div><br>According to <a href=3D"https://boto=
ndballo.wordpress.com/2015/11/09/trip-report-c-standards-meeting-in-kona-oc=
tober-2015/">this trip report</a>, it was sent back for improvements. The c=
ommittee apparently liked the &quot;function alias&quot; part a lot.</div><=
br></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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

------=_Part_3466_712797116.1454259687959--
------=_Part_3465_1092221746.1454259687958--

.


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sun, 31 Jan 2016 18:56:46 +0100
Raw View
This is a multi-part message in MIME format.
--------------030300010207020308050805
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 31/01/2016 06:26, David Krauss a =C3=A9crit :
>
>> On 2016=E2=80=9301=E2=80=9331, at 5:51 AM, Vicente J. Botet Escriba=20
>> <vicente.botet@wanadoo.fr <mailto:vicente.botet@wanadoo.fr>> wrote:
>>
>> there is a proposal that I like and explains the problem that must be=20
>> addressed, but I don't what is his state. It is Opaque Typedefs  [1]
>
> Opaque typedefs are exclusive of composition. The proposal here does=20
> align with function aliases, the other side of that proposal. It=E2=80=99=
s=20
> slightly more complicated because a member function alias would be=20
> bound to a member.
>
> The discussion in Kona was pretty contentious. The discussion was=20
> mostly high-level and focused on the type system, not function=20
> aliases. Perhaps function aliases for ordinary classes could be a new=20
> proposal.
Sure. However function alias alone will not help when the new function=20
has the wrapping type several times.

E.g. how could we define the following operator+

class energy {
     double value;
public:
     explicit energy(double);
     //energy operator+ (energy , energy)
     using operator+() =3D ...

I believe that we will need some kind of high-order function composition.

The advantage of Opaque Typedef proposal was that it was up to the=20
compiler to do all this unwrapping, apply the operation and possibly=20
wrapping again when needed

energy operator+ (energy , energy) =3D default;

If extended inheritance is not a good idea, maybe we could extend the=20
default

energy operator+ (energy , energy) =3D default value;
>
>
>> On 2016=E2=80=9301=E2=80=9330, at 11:03 AM, Vincent Reverdy <vince.rev@g=
mail.com=20
>> <mailto:vince.rev@gmail.com>> wrote:
>>
>> // Composition
>>    including my_component =3D std::vector<int>;// "including" is a=20
>> hypothetical new keyword (don't focus on the name, anything could be=20
>> chosen instead)
>
> What happens if my_component is used to declare several members? Why=20
> not forgo the keyword and allow using at =3D v.at <http://v.at>; or=20
> using v.at <http://v.at>;?
>
>
Yes, v.at is in someway the composition of the member v access and the=20
application to the vector<int>::at member function.

Wondering how function aliases are related to point-free style.

Vicente

--=20

---=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.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-propos=
als/.

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

<html>
  <head>
    <meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Le 31/01/2016 06:26, David Krauss a
      =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote
      cite=3D"mid:87E6DA5F-F519-42B9-9F9E-73ADABE0EE42@gmail.com"
      type=3D"cite">
      <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf=
-8">
      <br class=3D"">
      <div>
        <blockquote type=3D"cite" class=3D"">
          <div class=3D"">On 2016=E2=80=9301=E2=80=9331, at 5:51 AM, Vicent=
e J. Botet
            Escriba &lt;<a moz-do-not-send=3D"true"
              href=3D"mailto:vicente.botet@wanadoo.fr" class=3D"">vicente.b=
otet@wanadoo.fr</a>&gt;
            wrote:</div>
          <br class=3D"Apple-interchange-newline">
          <div class=3D""><span style=3D"font-family: Helvetica; font-size:
              12px; font-style: normal; font-variant: normal;
              font-weight: normal; letter-spacing: normal; orphans:
              auto; text-align: start; text-indent: 0px; text-transform:
              none; white-space: normal; widows: auto; word-spacing:
              0px; -webkit-text-stroke-width: 0px; background-color:
              rgb(255, 255, 255); float: none; display: inline
              !important;" class=3D"">there is a proposal that I like and
              explains the problem that must be addressed, but I don't
              what is his state. It is Opaque Typedefs=C2=A0 [1]</span><br
              style=3D"font-family: Helvetica; font-size: 12px;
              font-style: normal; font-variant: normal; font-weight:
              normal; letter-spacing: normal; orphans: auto; text-align:
              start; text-indent: 0px; text-transform: none;
              white-space: normal; widows: auto; word-spacing: 0px;
              -webkit-text-stroke-width: 0px; background-color: rgb(255,
              255, 255);" class=3D"">
          </div>
        </blockquote>
      </div>
      <br class=3D"">
      <div class=3D"">Opaque typedefs are exclusive of composition. The
        proposal here does align with function aliases, the other side
        of that proposal. It=E2=80=99s slightly more complicated because a
        member function alias would be bound to a member.</div>
      <div class=3D""><br class=3D"">
      </div>
      <div class=3D"">The discussion in Kona was pretty contentious. The
        discussion was mostly high-level and focused on the type system,
        not function aliases. Perhaps function aliases for ordinary
        classes could be a new proposal.</div>
    </blockquote>
    Sure. However function alias alone will not help when the new
    function has the wrapping type several times.<br>
    <br>
    E.g. how could we define the following operator+<br>
    <br>
    class energy {<br>
    =C2=A0=C2=A0=C2=A0 double value;<br>
    public:<br>
    =C2=A0=C2=A0=C2=A0 explicit energy(double);<br>
    =C2=A0=C2=A0=C2=A0 //energy operator+ (energy , energy)<br>
    =C2=A0=C2=A0=C2=A0 using operator+() =3D ...<br>
    <br>
    I believe that we will need some kind of high-order function
    composition.<br>
    <br>
    The advantage of Opaque Typedef proposal was that it was up to the
    compiler to do all this unwrapping, apply the operation and possibly
    wrapping again when needed<br>
    <br>
    energy operator+ (energy , energy) =3D default;<br>
    <br>
    If extended inheritance is not a good idea, maybe we could extend
    the default<br>
    <br>
    energy operator+ (energy , energy) =3D default value;<br>
    <blockquote
      cite=3D"mid:87E6DA5F-F519-42B9-9F9E-73ADABE0EE42@gmail.com"
      type=3D"cite">
      <div class=3D""><br class=3D"">
      </div>
      <div class=3D""><br class=3D"">
      </div>
      <div class=3D"">
        <blockquote type=3D"cite" class=3D"">
          <div class=3D"">On 2016=E2=80=9301=E2=80=9330, at 11:03 AM, Vince=
nt Reverdy &lt;<a
              moz-do-not-send=3D"true" href=3D"mailto:vince.rev@gmail.com"
              class=3D""><a class=3D"moz-txt-link-abbreviated" href=3D"mail=
to:vince.rev@gmail.com">vince.rev@gmail.com</a></a>&gt; wrote:</div>
          <br class=3D"Apple-interchange-newline">
          <div class=3D""><span class=3D"styled-by-prettify"
              style=3D"font-family: monospace;">=C2=A0 =C2=A0</span><span
              class=3D"styled-by-prettify" style=3D"font-family: monospace;
              color: rgb(136, 0, 0);">// Composition</span><span
              class=3D"styled-by-prettify" style=3D"font-family: monospace;=
"><br
                class=3D"">
              =C2=A0 =C2=A0including my_component=C2=A0</span><span
              class=3D"styled-by-prettify" style=3D"font-family: monospace;
              color: rgb(102, 102, 0);">=3D</span><span
              class=3D"styled-by-prettify" style=3D"font-family: monospace;=
">=C2=A0std</span><span
              class=3D"styled-by-prettify" style=3D"font-family: monospace;
              color: rgb(102, 102, 0);">::</span><span
              class=3D"styled-by-prettify" style=3D"font-family: monospace;=
">vector</span><span
              class=3D"styled-by-prettify" style=3D"font-family: monospace;
              color: rgb(0, 136, 0);">&lt;int&gt;</span><span
              class=3D"styled-by-prettify" style=3D"font-family: monospace;
              color: rgb(102, 102, 0);">;</span><span
              class=3D"styled-by-prettify" style=3D"font-family: monospace;=
">=C2=A0</span><span
              class=3D"styled-by-prettify" style=3D"font-family: monospace;
              color: rgb(136, 0, 0);">// "including" is a hypothetical
              new keyword (don't focus on the name, anything could be
              chosen instead)</span><span class=3D"styled-by-prettify"
              style=3D"font-family: monospace;"><br class=3D"">
            </span></div>
        </blockquote>
      </div>
      <div class=3D"">
        <div class=3D""><span class=3D"styled-by-prettify"><br class=3D"">
          </span></div>
      </div>
      <div class=3D"">What happens if <font class=3D"" face=3D"Courier">my_=
component</font>
        is used to declare several members? Why not forgo the keyword
        and allow=C2=A0<font class=3D"" face=3D"Courier">using at =3D <a
            moz-do-not-send=3D"true" href=3D"http://v.at" class=3D"">v.at</=
a>;</font>=C2=A0or=C2=A0<span
          style=3D"font-family: Courier;" class=3D"">using </span><span
          style=3D"font-family: Courier;" class=3D""><a
            moz-do-not-send=3D"true" href=3D"http://v.at" class=3D"">v.at</=
a></span><span
          style=3D"font-family: Courier;" class=3D"">;</span>?</div>
      <div class=3D""><br class=3D"">
      </div>
      <br>
    </blockquote>
    Yes, v.at is in someway the composition of the member v access and
    the application to the vector&lt;int&gt;::at member function.<br>
    <br>
    Wondering how function aliases are related to point-free style.<br>
    <br>
    Vicente<br>
  </body>
</html>

<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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

--------------030300010207020308050805--

.


Author: David Krauss <potswa@gmail.com>
Date: Tue, 2 Feb 2016 13:55:58 +0800
Raw View
--Apple-Mail=_D164290F-E29E-4341-B1D9-D10E80353A9E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2016=E2=80=9302=E2=80=9301, at 1:56 AM, Vicente J. Botet Escriba <vice=
nte.botet@wanadoo.fr> wrote:
>=20
> Sure. However function alias alone will not help when the new function ha=
s the wrapping type several times.
>=20
> E.g. how could we define the following operator+
>=20
> class energy {
>     double value;
> public:
>     explicit energy(double);
>     //energy operator+ (energy , energy)
>     using operator+() =3D =E2=80=A6

This is a different problem.

1. It doesn=E2=80=99t, and shouldn=E2=80=99t, involve overloading. Such a u=
sing declaration shouldn=E2=80=99t import both the unary and binary forms.

2. Should the implicitly-declared function pass by value or by reference? T=
he language can=E2=80=99t do better than a heuristic, and the only simple a=
nd robust heuristic wouldn=E2=80=99t match your example expectation. Passin=
g by value would be a bad idea in the presence of other members.

P0109R0 works because it doesn=E2=80=99t worry about other members. Its fun=
ction alias example wouldn=E2=80=99t have unary/binary ambiguity with opera=
tor+ because the alias is to a function object.

> I believe that we will need some kind of high-order function composition.
>=20
> The advantage of Opaque Typedef proposal was that it was up to the compil=
er to do all this unwrapping, apply the operation and possibly wrapping aga=
in when needed
>=20
> energy operator+ (energy , energy) =3D default;
>=20
> If extended inheritance is not a good idea, maybe we could extend the def=
ault
>=20
> energy operator+ (energy , energy) =3D default value;

I think the language would be too clever to synthesize a function just like=
 that.

It would be nice to import generic free functions, such as already exist in=
 std::rel_ops. A template could easily handle delegation to a member as lon=
g as the member is named value, and can even do a bit better given a pointe=
r-to-member template parameter. The effect of importing would be like frien=
dship, so perhaps it should be spelled friend instead of using.

namespace value_operators {
    template< typename t >
    t operator + ( t const & lhs, t const & res )
        { return t( lhs.value + rhs.value ); }

    template< typename t >
    t operator - ( t const & lhs, t const & res )
        { return t( lhs.value - rhs.value ); }

    template< typename t >
    bool operator < ( t const & lhs, t const & res )
        { return lhs.value < rhs.value; }
}

class energy {
    double value;
public:
    explicit energy(double);
    friend value_operators;
    friend std::rel_ops;
};

One problem with this is the eagerness of ADL. You don=E2=80=99t want rel_o=
ps to handle every foo_template<energy>. But since this is uncharted territ=
ory, that might be a solvable problem.

> Yes, v.at is in someway the composition of the member v access and the ap=
plication to the vector<int>::at member function.
>=20
> Wondering how function aliases are related to point-free style.

Had to look that up=E2=80=A6 point-free style describes the terseness of e.=
g. Forth and lambda calculus/combinatory logic. C++ overload sets are simil=
ar, but different: we wait until all the arguments are visible, then decide=
 which function to use. I think that=E2=80=99s as far as the relationship g=
oes. Yes, it=E2=80=99s useful in this design space to defer overload resolu=
tion by treating overloaded names as entities. But it might be a bad idea t=
o ask C++ programmers to think in terms of functional composition.

--=20

---=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.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-propos=
als/.

--Apple-Mail=_D164290F-E29E-4341-B1D9-D10E80353A9E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2016=E2=80=9302=
=E2=80=9301, at 1:56 AM, Vicente J. Botet Escriba &lt;<a href=3D"mailto:vic=
ente.botet@wanadoo.fr" class=3D"">vicente.botet@wanadoo.fr</a>&gt; wrote:</=
div><br class=3D"Apple-interchange-newline"><div class=3D"">
 =20
    <meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
" class=3D"">
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000" class=3D"">
    <div class=3D"moz-cite-prefix">Sure. However function alias alone will =
not help when the new
    function has the wrapping type several times.</div>
    <br class=3D"">
    E.g. how could we define the following operator+<br class=3D"">
    <br class=3D"">
    class energy {<br class=3D"">
    &nbsp;&nbsp;&nbsp; double value;<br class=3D"">
    public:<br class=3D"">
    &nbsp;&nbsp;&nbsp; explicit energy(double);<br class=3D"">
    &nbsp;&nbsp;&nbsp; //energy operator+ (energy , energy)<br class=3D"">
    &nbsp;&nbsp;&nbsp; using operator+() =3D =E2=80=A6</div></div></blockqu=
ote><div><br class=3D""></div><div>This is a different problem.</div><div><=
br class=3D""></div><div>1. It doesn=E2=80=99t, and shouldn=E2=80=99t, invo=
lve overloading. Such a using declaration shouldn=E2=80=99t import both the=
 unary and binary forms.</div><div><br class=3D""></div><div>2. Should the =
implicitly-declared function pass by value or by reference? The language ca=
n=E2=80=99t do better than a heuristic, and the only simple and robust heur=
istic wouldn=E2=80=99t match your example expectation. Passing by value wou=
ld be a bad idea in the presence of other members.</div><div><br class=3D""=
></div><div>P0109R0 works because it doesn=E2=80=99t worry about other memb=
ers. Its function alias example wouldn=E2=80=99t have unary/binary ambiguit=
y with <font face=3D"Courier" class=3D"">operator+</font> because the alias=
 is to a function object.</div><div><br class=3D""></div><blockquote type=
=3D"cite" class=3D""><div class=3D""><div bgcolor=3D"#FFFFFF" text=3D"#0000=
00" class=3D"">I believe that we will need some kind of high-order function
    composition.<br class=3D"">
    <br class=3D"">
    The advantage of Opaque Typedef proposal was that it was up to the
    compiler to do all this unwrapping, apply the operation and possibly
    wrapping again when needed<br class=3D"">
    <br class=3D"">
    energy operator+ (energy , energy) =3D default;<br class=3D"">
    <br class=3D"">
    If extended inheritance is not a good idea, maybe we could extend
    the default<br class=3D"">
    <br class=3D"">
    energy operator+ (energy , energy) =3D default value;<br class=3D""></d=
iv></div></blockquote><div><br class=3D""></div><div>I think the language w=
ould be too clever to synthesize a function just like that.</div><div><br c=
lass=3D""></div><div>It would be nice to import generic free functions, suc=
h as already exist in <font face=3D"Courier" class=3D"">std::rel_ops</font>=
.. A template could easily handle delegation to a member as long as the memb=
er is named <font face=3D"Courier" class=3D"">value</font>, and can even do=
 a bit better given a pointer-to-member template parameter. The effect of i=
mporting would be like friendship, so perhaps it should be spelled <font fa=
ce=3D"Courier" class=3D"">friend</font> instead of <font face=3D"Courier" c=
lass=3D"">using</font>.</div><div><br class=3D""></div><div><font face=3D"C=
ourier" class=3D"">namespace value_operators {</font></div><div><font face=
=3D"Courier" class=3D"">&nbsp; &nbsp; template&lt; typename t &gt;</font></=
div><div><font face=3D"Courier" class=3D"">&nbsp; &nbsp; t operator + ( t c=
onst &amp; lhs, t const &amp;&nbsp;res&nbsp;)</font></div><div><font face=
=3D"Courier" class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; { return t( lhs.value +=
 rhs.value ); }</font></div><div><font face=3D"Courier" class=3D""><br clas=
s=3D""></font></div><div><font face=3D"Courier" class=3D"">&nbsp; &nbsp; te=
mplate&lt; typename t &gt;</font></div><div><font face=3D"Courier" class=3D=
"">&nbsp; &nbsp; t operator - ( t const &amp; lhs, t const &amp;&nbsp;res&n=
bsp;)</font></div><div><font face=3D"Courier" class=3D"">&nbsp; &nbsp; &nbs=
p; &nbsp; { return t( lhs.value - rhs.value ); }</font></div><div><span sty=
le=3D"font-family: Courier;" class=3D""><br class=3D""></span></div><div><f=
ont face=3D"Courier" class=3D"">&nbsp; &nbsp; template&lt; typename t &gt;<=
/font></div><div><font face=3D"Courier" class=3D"">&nbsp; &nbsp; bool opera=
tor &lt; ( t const &amp; lhs, t const &amp;&nbsp;res&nbsp;)</font></div><di=
v><font face=3D"Courier" class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; { return lh=
s.value &lt; rhs.value; }</font></div><div><span style=3D"font-family: Cour=
ier;" class=3D"">}</span></div><div><font face=3D"Courier" class=3D""><br c=
lass=3D""></font></div><div><font face=3D"Courier" class=3D"">class energy =
{<br class=3D""></font></div><div><font face=3D"Courier" class=3D"">&nbsp; =
&nbsp; double value;<br class=3D"">public:<br class=3D"">&nbsp; &nbsp; expl=
icit energy(double);<br class=3D""></font></div><div><font face=3D"Courier"=
 class=3D"">&nbsp; &nbsp; friend&nbsp;</font><span style=3D"font-family: Co=
urier;" class=3D"">value_operators</span><font face=3D"Courier" class=3D"">=
;</font></div><font face=3D"Courier" class=3D""></font><div><font face=3D"C=
ourier" class=3D"">&nbsp; &nbsp; friend std::rel_ops;</font></div><div><spa=
n style=3D"font-family: Courier;" class=3D"">};</span></div></div><div><br =
class=3D""></div><div>One problem with this is the eagerness of ADL. You do=
n=E2=80=99t want <font face=3D"Courier" class=3D"">rel_ops</font> to handle=
 every&nbsp;<font face=3D"Courier" class=3D"">foo_template&lt;energy&gt;</f=
ont>. But since this is uncharted territory, that might be a solvable probl=
em.</div><div><br class=3D""><blockquote type=3D"cite" class=3D""><div clas=
s=3D""><div bgcolor=3D"#FFFFFF" text=3D"#000000" class=3D"">
    Yes, <a href=3D"http://v.at" class=3D"">v.at</a> is in someway the comp=
osition of the member v access and
    the application to the vector&lt;int&gt;::at member function.<br class=
=3D"">
    <br class=3D"">
    Wondering how function aliases are related to point-free style.<br clas=
s=3D""></div></div></blockquote><div><br class=3D""></div><div>Had to look =
that up=E2=80=A6 <i class=3D"">point-free style</i> describes the terseness=
 of e.g. Forth and lambda calculus/combinatory logic. C++ overload sets are=
 similar, but different: we wait until all the arguments are visible, then =
decide which function to use. I think that=E2=80=99s as far as the relation=
ship goes. Yes, it=E2=80=99s useful in this design space to defer overload =
resolution by treating overloaded names as entities. But it might be a bad =
idea to ask C++ programmers to think in terms of functional composition.</d=
iv><div><br class=3D""></div></div></body></html>

<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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

--Apple-Mail=_D164290F-E29E-4341-B1D9-D10E80353A9E--

.