Topic: Sugar fix: static subscript operators


Author: mihailnajdenov@gmail.com
Date: Thu, 20 Oct 2016 08:37:04 -0700 (PDT)
Raw View
------=_Part_231_658922557.1476977824742
Content-Type: multipart/alternative;
 boundary="----=_Part_232_645035625.1476977824743"

------=_Part_232_645035625.1476977824743
Content-Type: text/plain; charset=UTF-8

Right now to access the new types like tuple and variant, types without
named fields, we use the rather awkward std::get<> syntax.

To the user perspective, this is nothing more then an index into the type,
made in compile time.

In the light of the new structured bindings and the syntax sure there, can
we improve this access as well?

Wouldn't it be nice instead of

std::tuple<int, string> tup;

std::get<0>(tup) = 12;
std::get<string>(tup) = "hello";

To say

tup.[0] = 12;
tup.[string] = 12;

The idea being, a dot, as we would do with struct, but because of lack of
name, we use a subscript operator syntax instead, thus becoming "static
subscript operator".

I don't know if this is possible, just pointing it out as the "most
logical" and "simplest" extension.
I also know, square braces have been overused lately...


This should work with pointers as well, though a bit more cumbersome.

(&tup)->[int] = 12;

The idea is to also be able to implement *std::get_if* with something in
the lines of

std::variant<int, string> var;

if(auto v = (&var)->?[int]) //< same as std::get_if<int>(&var);
  std::cout << "we have int: " << *v << '\n';


Anyways.
Just few ideas.

I wonder if there is any work in that direction?
I know there is work on getting variant with fields as native type.
But adding this will be beneficial nevertheless, I think.

--
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/181c78bc-ed2d-4645-8d8c-9d88b89058cd%40isocpp.org.

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

<div dir=3D"ltr"><div>Right now to access the new types like tuple and vari=
ant, types without named fields, we use the rather awkward std::get&lt;&gt;=
 syntax.</div><div><br></div><div>To the user perspective, this is nothing =
more then an index into the type, made in compile time. </div><div><br></di=
v><div>In the light of the new structured bindings and the syntax sure ther=
e, can we improve this access as well?</div><div><br></div><div>Wouldn&#39;=
t it=C2=A0be nice instead of</div><div><br></div><div class=3D"prettyprint"=
 style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; back=
ground-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><span class=3D"styled-by-prettify" style=3D"color: #000=
;">std</span><span class=3D"styled-by-prettify" style=3D"color: #660;">::</=
span><span class=3D"styled-by-prettify" style=3D"color: #000;">tuple</span>=
<span class=3D"styled-by-prettify" style=3D"color: #660;">&lt;</span><span =
class=3D"styled-by-prettify" style=3D"color: #008;">int</span><span class=
=3D"styled-by-prettify" style=3D"color: #660;">,</span><span class=3D"style=
d-by-prettify" style=3D"color: #000;"> </span><span class=3D"styled-by-pret=
tify" style=3D"color: #008;">string</span><span class=3D"styled-by-prettify=
" style=3D"color: #660;">&gt;</span><span class=3D"styled-by-prettify" styl=
e=3D"color: #000;"> tup</span><span class=3D"styled-by-prettify" style=3D"c=
olor: #660;">;</span><span class=3D"styled-by-prettify" style=3D"color: #00=
0;"><br><br>std</span><span class=3D"styled-by-prettify" style=3D"color: #6=
60;">::</span><span class=3D"styled-by-prettify" style=3D"color: #008;">get=
</span><span class=3D"styled-by-prettify" style=3D"color: #660;">&lt;</span=
><span class=3D"styled-by-prettify" style=3D"color: #066;">0</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: #660;">&gt;(</span><span class=
=3D"styled-by-prettify" style=3D"color: #000;">tup</span><span class=3D"sty=
led-by-prettify" style=3D"color: #660;">)</span><span class=3D"styled-by-pr=
ettify" style=3D"color: #000;"> </span><span class=3D"styled-by-prettify" s=
tyle=3D"color: #660;">=3D</span><span class=3D"styled-by-prettify" style=3D=
"color: #000;"> </span><span class=3D"styled-by-prettify" style=3D"color: #=
066;">12</span><span class=3D"styled-by-prettify" style=3D"color: #660;">;<=
/span><span class=3D"styled-by-prettify" style=3D"color: #000;"><br>std</sp=
an><span class=3D"styled-by-prettify" style=3D"color: #660;">::</span><span=
 class=3D"styled-by-prettify" style=3D"color: #008;">get</span><span class=
=3D"styled-by-prettify" style=3D"color: #080;">&lt;string&gt;</span><span c=
lass=3D"styled-by-prettify" style=3D"color: #660;">(</span><span class=3D"s=
tyled-by-prettify" style=3D"color: #000;">tup</span><span class=3D"styled-b=
y-prettify" style=3D"color: #660;">)</span><span class=3D"styled-by-prettif=
y" style=3D"color: #000;"> </span><span class=3D"styled-by-prettify" style=
=3D"color: #660;">=3D</span><span class=3D"styled-by-prettify" style=3D"col=
or: #000;"> </span><span class=3D"styled-by-prettify" style=3D"color: #080;=
">&quot;hello&quot;</span><span class=3D"styled-by-prettify" style=3D"color=
: #660;">;</span><b></b><i></i><u></u><sub></sub><sup></sup><strike></strik=
e><span class=3D"styled-by-prettify" style=3D"color: #000;"><br></span></di=
v></code></div><div><br></div><div>To say</div><div><br></div><div class=3D=
"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: bre=
ak-word; background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"=
><div class=3D"subprettyprint"><span class=3D"styled-by-prettify" style=3D"=
color: #000;">tup</span><span class=3D"styled-by-prettify" style=3D"color: =
#660;">.[</span><span class=3D"styled-by-prettify" style=3D"color: #066;">0=
</span><span class=3D"styled-by-prettify" style=3D"color: #660;">]</span><s=
pan class=3D"styled-by-prettify" style=3D"color: #000;"> </span><span class=
=3D"styled-by-prettify" style=3D"color: #660;">=3D</span><span class=3D"sty=
led-by-prettify" style=3D"color: #000;"> </span><span class=3D"styled-by-pr=
ettify" style=3D"color: #066;">12</span><span class=3D"styled-by-prettify" =
style=3D"color: #660;">;</span><span class=3D"styled-by-prettify" style=3D"=
color: #000;"><br>tup</span><span class=3D"styled-by-prettify" style=3D"col=
or: #660;">.[</span><span class=3D"styled-by-prettify" style=3D"color: #008=
;">string</span><span class=3D"styled-by-prettify" style=3D"color: #660;">]=
</span><span class=3D"styled-by-prettify" style=3D"color: #000;"> </span><s=
pan class=3D"styled-by-prettify" style=3D"color: #660;">=3D</span><span cla=
ss=3D"styled-by-prettify" style=3D"color: #000;"> </span><span class=3D"sty=
led-by-prettify" style=3D"color: #066;">12</span><span class=3D"styled-by-p=
rettify" style=3D"color: #660;">;</span><b></b><i></i><u></u><sub></sub><su=
p></sup><strike></strike><span class=3D"styled-by-prettify" style=3D"color:=
 #000;"><br></span></div></code></div><b></b><div><br>The idea being, a dot=
, as we would do with struct, but because of lack of name, we use a subscri=
pt operator syntax instead, thus becoming &quot;static subscript operator&q=
uot;.</div><div><br></div><div>I don&#39;t know if this is possible, just p=
ointing it out as the &quot;most logical&quot; and &quot;simplest&quot; ext=
ension. </div><div>I also know, square braces have been overused lately... =
</div><div><br></div><div><br></div><div>This should work with pointers as =
well, though a bit more cumbersome. </div><div><br></div><div class=3D"pret=
typrint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-wo=
rd; background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div=
 class=3D"subprettyprint"><span class=3D"styled-by-prettify" style=3D"color=
: #660;">(&amp;</span><span class=3D"styled-by-prettify" style=3D"color: #0=
00;">tup</span><span class=3D"styled-by-prettify" style=3D"color: #660;">)-=
&gt;[</span><span class=3D"styled-by-prettify" style=3D"color: #008;">int</=
span><span class=3D"styled-by-prettify" style=3D"color: #660;">]</span><spa=
n class=3D"styled-by-prettify" style=3D"color: #000;"> </span><span class=
=3D"styled-by-prettify" style=3D"color: #660;">=3D</span><span class=3D"sty=
led-by-prettify" style=3D"color: #000;"> </span><span class=3D"styled-by-pr=
ettify" style=3D"color: #066;">12</span><span class=3D"styled-by-prettify" =
style=3D"color: #660;">;</span></div></code></div><div><br></div><div>The i=
dea=C2=A0is to also=C2=A0be able to implement <b>std::get_if</b> with somet=
hing in the lines of</div><div><br></div><div><div class=3D"prettyprint" st=
yle=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; backgro=
und-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"s=
ubprettyprint"><font color=3D"rgb(0,0,0)"><span class=3D"styled-by-prettify=
" style=3D"color: #000;">std</span><span class=3D"styled-by-prettify" style=
=3D"color: #660;">::</span><span class=3D"styled-by-prettify" style=3D"colo=
r: #000;">variant</span><span class=3D"styled-by-prettify" style=3D"color: =
#660;">&lt;</span><span class=3D"styled-by-prettify" style=3D"color: #008;"=
>int</span><span class=3D"styled-by-prettify" style=3D"color: #660;">,</spa=
n><span class=3D"styled-by-prettify" style=3D"color: #000;"> </span><span c=
lass=3D"styled-by-prettify" style=3D"color: #008;">string</span><span class=
=3D"styled-by-prettify" style=3D"color: #660;">&gt;</span><span class=3D"st=
yled-by-prettify" style=3D"color: #000;"> </span><span class=3D"styled-by-p=
rettify" style=3D"color: #008;">var</span><span class=3D"styled-by-prettify=
" style=3D"color: #660;">;</span><span class=3D"styled-by-prettify" style=
=3D"color: #000;"><br><br></span><span class=3D"styled-by-prettify" style=
=3D"color: #008;">if</span><span class=3D"styled-by-prettify" style=3D"colo=
r: #660;">(</span><span class=3D"styled-by-prettify" style=3D"color: #008;"=
>auto</span><span class=3D"styled-by-prettify" style=3D"color: #000;"> v </=
span><span class=3D"styled-by-prettify" style=3D"color: #660;">=3D</span><s=
pan class=3D"styled-by-prettify" style=3D"color: #000;"> </span><span class=
=3D"styled-by-prettify" style=3D"color: #660;">(&amp;</span><span class=3D"=
styled-by-prettify" style=3D"color: #008;">var</span><span class=3D"styled-=
by-prettify" style=3D"color: #660;">)-&gt;?[</span><span class=3D"styled-by=
-prettify" style=3D"color: #008;">int</span><span class=3D"styled-by-pretti=
fy" style=3D"color: #660;">])</span><span class=3D"styled-by-prettify" styl=
e=3D"color: #000;"> </span><span class=3D"styled-by-prettify" style=3D"colo=
r: #800;">//&lt; same as</span><font color=3D"#222222"><b><span class=3D"st=
yled-by-prettify" style=3D"color: #800;"> </span></b><span class=3D"styled-=
by-prettify" style=3D"color: #800;">std::get_if&lt;int&gt;(&amp;var);</span=
></font><font color=3D"#222222"></font><span class=3D"styled-by-prettify" s=
tyle=3D"color: #000;"><br>=C2=A0 std</span><span class=3D"styled-by-prettif=
y" style=3D"color: #660;">::</span><span class=3D"styled-by-prettify" style=
=3D"color: #000;">cout </span><span class=3D"styled-by-prettify" style=3D"c=
olor: #660;">&lt;&lt;</span><span class=3D"styled-by-prettify" style=3D"col=
or: #000;"> </span><span class=3D"styled-by-prettify" style=3D"color: #080;=
">&quot;we have int: &quot;</span><span class=3D"styled-by-prettify" style=
=3D"color: #000;"> </span><span class=3D"styled-by-prettify" style=3D"color=
: #660;">&lt;&lt;</span><span class=3D"styled-by-prettify" style=3D"color: =
#000;"> </span><span class=3D"styled-by-prettify" style=3D"color: #660;">*<=
/span><span class=3D"styled-by-prettify" style=3D"color: #000;">v </span><s=
pan class=3D"styled-by-prettify" style=3D"color: #660;">&lt;&lt;</span><spa=
n class=3D"styled-by-prettify" style=3D"color: #000;"> </span><span class=
=3D"styled-by-prettify" style=3D"color: #080;">&#39;\n&#39;</span><span cla=
ss=3D"styled-by-prettify" style=3D"color: #660;">;</span><span class=3D"sty=
led-by-prettify" style=3D"color: #000;"><br><br></span></font></div></code>=
</div><b></b><br></div><div>Anyways.</div><div>Just few ideas.</div><div><b=
r></div><div>I wonder if there is any work in that direction?</div><div>I k=
now there is work on getting variant with fields as native type. </div><div=
>But adding this will be beneficial nevertheless, I think.</div><div><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/181c78bc-ed2d-4645-8d8c-9d88b89058cd%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/181c78bc-ed2d-4645-8d8c-9d88b89058cd=
%40isocpp.org</a>.<br />

------=_Part_232_645035625.1476977824743--

------=_Part_231_658922557.1476977824742--

.


Author: Jens Maurer <Jens.Maurer@gmx.net>
Date: Thu, 20 Oct 2016 23:38:25 +0200
Raw View
On 10/20/2016 05:37 PM, mihailnajdenov@gmail.com wrote:
> Wouldn't it be nice instead of
>
> ||
> std::tuple<int,string>tup;
>
> std::get<0>(tup)=12;
> std::get<string>(tup)="hello";**//___^
>
> To say
>
> ||
> tup.[0]=12;
> tup.[string]=12;**//___^
> **

> I wonder if there is any work in that direction?

Not that I'm aware of.

If you want to have this happen, the first step is to write
a paper showing the necessary grammar changes and the
"translation" into std::get<> (or whatever) that you want
to see.  This at least ensures it gets attention in the C++
committee's Evolution Working Group.  I can't say whether
people will like it enough to buy into the grammar change.

If you need help obtaining a paper number and submitting it
for a committee mailing, send me e-mail.

Jens

--
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/58093951.5070808%40gmx.net.

.


Author: Bengt Gustafsson <bengt.gustafsson@beamways.com>
Date: Thu, 20 Oct 2016 15:23:32 -0700 (PDT)
Raw View
------=_Part_19_461926828.1477002212643
Content-Type: multipart/alternative;
 boundary="----=_Part_20_1340156240.1477002212643"

------=_Part_20_1340156240.1477002212643
Content-Type: text/plain; charset=UTF-8

I think this would be best solved by a more or less regular operator[] but
with a constexpr parameter:

In tuple's class head:

   auto& operator[](constexpr size_t ix) { return std::get<ix>(*this); }

You get the drift. The idea of allowing a constexpr function parameter
which is defined to be the equivalent of a template with a non-type
template parameter was posted here a while ago. So the above would be
equivalent of:

   template<size_t ix> auto& operator[]() { return std::get<ix>(*this); }

with two exceptions: 1: You can't make an operator[] without parameter, 2:
you would not have to type the template keyword when calling the operator
(or else the idea is moot).

With this you would obviously not have to add the dot before the [ as it is
just a regular operator[] syntaxwise.





Den torsdag 20 oktober 2016 kl. 23:38:31 UTC+2 skrev Jens Maurer:
>
> On 10/20/2016 05:37 PM, mihailn...@gmail.com <javascript:> wrote:
> > Wouldn't it be nice instead of
> >
> > ||
> > std::tuple<int,string>tup;
> >
> > std::get<0>(tup)=12;
> > std::get<string>(tup)="hello";**//___^
> >
> > To say
> >
> > ||
> > tup.[0]=12;
> > tup.[string]=12;**//___^
> > **
>
> > I wonder if there is any work in that direction?
>
> Not that I'm aware of.
>
> If you want to have this happen, the first step is to write
> a paper showing the necessary grammar changes and the
> "translation" into std::get<> (or whatever) that you want
> to see.  This at least ensures it gets attention in the C++
> committee's Evolution Working Group.  I can't say whether
> people will like it enough to buy into the grammar change.
>
> If you need help obtaining a paper number and submitting it
> for a committee mailing, send me e-mail.
>
> Jens
>

--
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/47e80ee1-7d26-44e2-a181-5d4fc6220cb8%40isocpp.org.

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

<div dir=3D"ltr">I think this would be best solved by a more or less regula=
r operator[] but with a constexpr parameter:<div><br></div><div>In tuple&#3=
9;s class head:</div><div><br></div><div>=C2=A0 =C2=A0auto&amp; operator[](=
constexpr size_t ix) { return std::get&lt;ix&gt;(*this); }</div><div><br></=
div><div>You get the drift. The idea of allowing a constexpr function param=
eter which is defined to be the equivalent of a template with a non-type te=
mplate parameter was posted here a while ago. So the above would be equival=
ent of:</div><div><br></div><div>=C2=A0 =C2=A0template&lt;size_t ix&gt; aut=
o&amp; operator[]() { return std::get&lt;ix&gt;(*this); }</div><div><br></d=
iv><div>with two exceptions: 1: You can&#39;t make an operator[] without pa=
rameter, 2: you would not have to type the template keyword when calling th=
e operator (or else the idea is moot).</div><div><br></div><div>With this y=
ou would obviously not have to add the dot before the [ as it is just a reg=
ular operator[] syntaxwise.</div><div><br></div><div><br></div><div><br></d=
iv><div>=C2=A0<br><br>Den torsdag 20 oktober 2016 kl. 23:38:31 UTC+2 skrev =
Jens Maurer:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 10/20/2016 05:3=
7 PM, <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"fk=
ZMM7BHBwAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&#3=
9;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;"=
>mihailn...@gmail.com</a> wrote:
<br>&gt; Wouldn&#39;t it be nice instead of
<br>&gt;=20
<br>&gt; ||
<br>&gt; std::tuple&lt;int,string&gt;tup;
<br>&gt;=20
<br>&gt; std::get&lt;0&gt;(tup)=3D12;
<br>&gt; std::get&lt;string&gt;(tup)=3D&quot;hello&quot;;<wbr>**//___^
<br>&gt;=20
<br>&gt; To say
<br>&gt;=20
<br>&gt; ||
<br>&gt; tup.[0]=3D12;
<br>&gt; tup.[string]=3D12;**//___^
<br>&gt; **
<br>
<br>&gt; I wonder if there is any work in that direction?
<br>
<br>Not that I&#39;m aware of.
<br>
<br>If you want to have this happen, the first step is to write
<br>a paper showing the necessary grammar changes and the
<br>&quot;translation&quot; into std::get&lt;&gt; (or whatever) that you wa=
nt
<br>to see. =C2=A0This at least ensures it gets attention in the C++
<br>committee&#39;s Evolution Working Group. =C2=A0I can&#39;t say whether
<br>people will like it enough to buy into the grammar change.
<br>
<br>If you need help obtaining a paper number and submitting it
<br>for a committee mailing, send me e-mail.
<br>
<br>Jens
<br></blockquote></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/47e80ee1-7d26-44e2-a181-5d4fc6220cb8%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/47e80ee1-7d26-44e2-a181-5d4fc6220cb8=
%40isocpp.org</a>.<br />

------=_Part_20_1340156240.1477002212643--

------=_Part_19_461926828.1477002212643--

.


Author: mihailnajdenov@gmail.com
Date: Thu, 20 Oct 2016 23:39:06 -0700 (PDT)
Raw View
------=_Part_549_1684053809.1477031946362
Content-Type: multipart/alternative;
 boundary="----=_Part_550_160795367.1477031946362"

------=_Part_550_160795367.1477031946362
Content-Type: text/plain; charset=UTF-8



On Friday, October 21, 2016 at 1:23:33 AM UTC+3, Bengt Gustafsson wrote:
>
> I think this would be best solved by a more or less regular operator[] but
> with a constexpr parameter:
>
> ...
>

I am not sure if this wouldn't add parsing ambiguity at some places. Also,
this makes tuple and variant look like an array in code, this might or
might not be a problem.

Lastly, the operator should be free standing, much like get, so it can
specialized, potentially even for regular struct, creating universal
syntax.
This way a tuple can be "upgraded" to a struct and all instances will still
work. On need-to bases one ca start using the field name for clarity.
This is also one bonuses to have a dot before the bracket - it makes it
more easily searchable - ".[" is a unique construct.

I don't have strong opinion on any of these, because, this is just an idea.

--
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/2e45f71f-38e1-4d2d-9e09-59d2e6e813f4%40isocpp.org.

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

<div dir=3D"ltr"><br><br>On Friday, October 21, 2016 at 1:23:33 AM UTC+3, B=
engt Gustafsson 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 think this would be best solved by a more or less regular operat=
or[] but with a constexpr parameter:<div><br></div><div>...<br></div></div>=
</blockquote><div>=C2=A0</div><div>I am not sure if this wouldn&#39;t add p=
arsing ambiguity at some places. Also, this makes tuple and variant look li=
ke an array in code, this might or might not be a problem.</div><div><br></=
div><div>Lastly, the operator should be free standing, much like get, so it=
 can specialized, potentially even for regular struct, creating universal s=
yntax. </div><div>This way a tuple can be &quot;upgraded&quot; to a struct =
and all instances will still work. On need-to bases one ca start using the =
field name for clarity.</div><div>This is also one bonuses to have a dot be=
fore the bracket - it makes it more easily searchable - &quot;.[&quot; is a=
 unique construct. </div><div><br></div><div>I don&#39;t have strong opinio=
n on any of these, because, this is just an idea.</div><div><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/2e45f71f-38e1-4d2d-9e09-59d2e6e813f4%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/2e45f71f-38e1-4d2d-9e09-59d2e6e813f4=
%40isocpp.org</a>.<br />

------=_Part_550_160795367.1477031946362--

------=_Part_549_1684053809.1477031946362--

.


Author: mihailnajdenov@gmail.com
Date: Sat, 22 Oct 2016 06:34:40 -0700 (PDT)
Raw View
------=_Part_816_672989481.1477143280889
Content-Type: multipart/alternative;
 boundary="----=_Part_817_803877690.1477143280889"

------=_Part_817_803877690.1477143280889
Content-Type: text/plain; charset=UTF-8



On Friday, October 21, 2016 at 9:39:06 AM UTC+3, mihailn...@gmail.com wrote:
>
> ...
>
I am not sure if this wouldn't add parsing ambiguity at some places. Also,
> this makes tuple and variant look like an array in code, this might or
> might not be a problem.
>
> Lastly, the operator should be free standing, much like get, so it can
> specialized, potentially even for regular struct, creating universal
> syntax.
> This way a tuple can be "upgraded" to a struct and all instances will
> still work. On need-to bases one ca start using the field name for clarity.
> This is also one bonuses to have a dot before the bracket - it makes it
> more easily searchable - ".[" is a unique construct.
>
> ...
>

Actually, having the dot is important so there can be an orthogonal arrow
version for pointers.
Also, any future "operator dot" overloading should work (I guess).
However, an "operator dot" overloading will probably create problems,
because there are no names to pick the correct overload.
Am not sure about the alternative "op dot" proposals though.

--
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/0b97da09-4f36-4200-acb1-089cd5f04a3e%40isocpp.org.

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

<div dir=3D"ltr"><br><br>On Friday, October 21, 2016 at 9:39:06 AM UTC+3, m=
ihailn...@gmail.com 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">...=C2=A0</div></blockquote><blockquote class=3D"gmail_quote" =
style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-l=
eft: 1ex;"><div dir=3D"ltr">I am not sure if this wouldn&#39;t add parsing =
ambiguity at some places. Also, this makes tuple and variant look like an a=
rray in code, this might or might not be a problem.<div><br></div><div>Last=
ly, the operator should be free standing, much like get, so it can speciali=
zed, potentially even for regular struct, creating universal syntax. </div>=
<div>This way a tuple can be &quot;upgraded&quot; to a struct and all insta=
nces will still work. On need-to bases one ca start using the field name fo=
r clarity.</div><div>This is also one bonuses to have a dot before the brac=
ket - it makes it more easily searchable - &quot;.[&quot; is a unique const=
ruct. </div><div><br></div><div>...<br></div></div></blockquote><div><br></=
div><div>Actually, having the dot is important so there can be an orthogona=
l arrow version for pointers.</div><div>Also, any future &quot;operator dot=
&quot; overloading should work (I guess).=C2=A0</div><div>However, an=C2=A0=
&quot;operator dot&quot; overloading will probably create problems, because=
 there are no names to pick the correct overload.</div><div>Am not sure abo=
ut the alternative &quot;op dot&quot; proposals though.</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/0b97da09-4f36-4200-acb1-089cd5f04a3e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0b97da09-4f36-4200-acb1-089cd5f04a3e=
%40isocpp.org</a>.<br />

------=_Part_817_803877690.1477143280889--

------=_Part_816_672989481.1477143280889--

.


Author: mihailnajdenov@gmail.com
Date: Sun, 23 Oct 2016 04:59:47 -0700 (PDT)
Raw View
------=_Part_1010_1831933148.1477223987388
Content-Type: multipart/alternative;
 boundary="----=_Part_1011_1191739149.1477223987389"

------=_Part_1011_1191739149.1477223987389
Content-Type: text/plain; charset=UTF-8

Just one motivating example

    struct Struct
    {
      string s = "hi";
      bool b {};
      std::pair<Union, Union> pr;

      Struct() { pr.first.s = "lol"; pr.second.i = 1; }
    } stct;

    std::tuple<string, bool, tuple<variant<int, string>, variant<int,
string>>> tup = { "hi", {}, { "lol", 1} };


    auto lol1 = stct.pr.first.s; //< natural access order, digging deeper
into the struct

    auto lol2 = get<string>(get<0>(get<2>(tup))); //< reversed access,
also, welcome to hell

    auto lol3 = tup.[2].[0].[string]; //< natural access order again


Granted, a universal call syntax would render this example much less
attractive.



--
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/10ad925b-8172-4e16-a647-46997f3369a0%40isocpp.org.

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

<div dir=3D"ltr"><div>Just one motivating example</div><div><br></div><div>=
<div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); w=
ord-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=3D=
"prettyprint"><div class=3D"subprettyprint"><span class=3D"styled-by-pretti=
fy" style=3D"color: #606;"><font color=3D"rgb(34,34,34)" face=3D"Arial" sty=
le=3D"background-color: transparent;">=C2=A0=C2=A0=C2=A0 struct Struct<br>=
=C2=A0=C2=A0=C2=A0 {<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 string s =3D &quot;h=
i&quot;;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bool b {};=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 std::pair&lt;Union=
, Union&gt; pr;</font></span></div><div><br></div><div class=3D"subprettypr=
int"><span class=3D"styled-by-prettify" style=3D"color: #606;"><font color=
=3D"rgb(34,34,34)" face=3D"Arial" style=3D"background-color: transparent;">=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Struct() { pr.first.s =3D &quot;lol&quot;; p=
r.second.i =3D 1; }<br>=C2=A0=C2=A0=C2=A0 } stct;<br>=C2=A0=C2=A0=C2=A0=C2=
=A0<br>=C2=A0=C2=A0=C2=A0 std::tuple&lt;string, bool, tuple&lt;variant&lt;i=
nt, string&gt;, variant&lt;int, string&gt;&gt;&gt; tup =3D { &quot;hi&quot;=
, {}, { &quot;lol&quot;, 1} };<br>=C2=A0=C2=A0=C2=A0=C2=A0<br><br>=C2=A0=C2=
=A0=C2=A0 auto lol1 =3D stct.pr.first.s; //&lt; natural access order, diggi=
ng deeper into the struct<br>=C2=A0=C2=A0=C2=A0=C2=A0<br>=C2=A0=C2=A0=C2=A0=
 auto lol2 =3D get&lt;string&gt;(get&lt;0&gt;(get&lt;2&gt;(tup))); //&lt; r=
eversed access, also, welcome to=C2=A0hell<br>=C2=A0=C2=A0=C2=A0=C2=A0<br>=
=C2=A0=C2=A0=C2=A0 auto lol3 =3D tup.[2].[0].[string]; //&lt; natural acces=
s order again<br>=C2=A0=C2=A0=C2=A0 </font></span><span class=3D"styled-by-=
prettify" style=3D"color: #660;"></span></div></code></div><br></div><div>G=
ranted, a universal call syntax would render this example much less attract=
ive. </div><code class=3D"prettyprint"><div><br></div><div class=3D"subpret=
typrint"><br></div></code><div><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/10ad925b-8172-4e16-a647-46997f3369a0%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/10ad925b-8172-4e16-a647-46997f3369a0=
%40isocpp.org</a>.<br />

------=_Part_1011_1191739149.1477223987389--

------=_Part_1010_1831933148.1477223987388--

.


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sun, 23 Oct 2016 19:31:54 +0200
Raw View
This is a multi-part message in MIME format.
--------------2149EAB6108D9316C68D43AA
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 23/10/2016 =C3=A0 13:59, mihailnajdenov@gmail.com a =C3=A9crit :
> Just one motivating example
>
> |
>     struct Struct
>     {
>       string s =3D "hi";
>       bool b {};
>       std::pair<Union, Union> pr;
>
>       Struct() { pr.first.s =3D "lol"; pr.second.i =3D 1; }
>     } stct;
>
>     std::tuple<string, bool, tuple<variant<int, string>, variant<int,=20
> string>>> tup =3D { "hi", {}, { "lol", 1} };
>
>
>     auto lol1 =3D stct.pr.first.s; //< natural access order, digging=20
> deeper into the struct
>
>     auto lol2 =3D get<string>(get<0>(get<2>(tup))); //< reversed access,=
=20
> also, welcome to hell
>
>     auto lol3 =3D tup.[2].[0].[string]; //< natural access order again
> |
>
I don't think we need to access this kind of structs by index and type=20
in generic code. IN generic code I wouln't mind to reverse the order if=20
needed. Do you have an example?
> Granted, a universal call syntax would render this example much less=20
> attractive.
> |
>
>
> |
|
Could you elaborate? get<I>(t) was chosen because t.get<I>() doesn't=20
works always, we need template.

struct P {
     std::pair<int, int> data;
     template <size_t I>
     int& get() { return std::get<I>(data); }
};

template <class T>
auto f(T & v) {
     //v.get<0>(); // COMPILE FAILS
     v.template get<0>();
}

http://melpon.org/wandbox/permlink/QLslsrDEHgV2zdlX

You can already have a product type |||chain |adaptor

||||    as_pt(lot2)(nth<2>|||, nth<|3>, type<string>)
||||
It is not so friendly but it should works.

||
http://melpon.org/wandbox/permlink/Oda6XwY2lIHD2XMU

Vicente
|
P.S. Note that I'm not against having a way to index product types, but=20
it is not so simple to find the appropriated syntax without breaking=20
changes and without ambiguity.

|
|What about


|||    auto lol3 =3D tup: 2: ||||0: ||string;

or
|||
||||||auto lol3 =3D tup: <2,||||0,||string>;
|||

':' after a product type will accept an index or a type or a sequence of=20
index or types

I don't know if this could be a breaking change or needs too much look=20
ahead.

||||
|

--=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/93b9f921-c417-aa64-8a02-6341054c6067%40wanadoo.f=
r.

--------------2149EAB6108D9316C68D43AA
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 23/10/2016 =C3=A0 13:59,
      <a class=3D"moz-txt-link-abbreviated" href=3D"mailto:mihailnajdenov@g=
mail.com">mihailnajdenov@gmail.com</a> a =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote
      cite=3D"mid:10ad925b-8172-4e16-a647-46997f3369a0@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr">
        <div>Just one motivating example</div>
        <div><br>
        </div>
        <div>
          <div class=3D"prettyprint" style=3D"border: 1px solid rgb(187,
            187, 187); word-wrap: break-word; background-color: rgb(250,
            250, 250);"><code class=3D"prettyprint">
              <div class=3D"subprettyprint"><span
                  class=3D"styled-by-prettify" style=3D"color: #606;"><font
                    style=3D"background-color: transparent;" face=3D"Arial"
                    color=3D"rgb(34,34,34)">=C2=A0=C2=A0=C2=A0 struct Struc=
t<br>
                    =C2=A0=C2=A0=C2=A0 {<br>
                    =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 string s =3D "hi";<br>
                    =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bool b {};=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <br>
                    =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 std::pair&lt;Union, Unio=
n&gt; pr;</font></span></div>
              <div><br>
              </div>
              <div class=3D"subprettyprint"><span
                  class=3D"styled-by-prettify" style=3D"color: #606;"><font
                    style=3D"background-color: transparent;" face=3D"Arial"
                    color=3D"rgb(34,34,34)">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =
Struct() { pr.first.s =3D
                    "lol"; pr.second.i =3D 1; }<br>
                    =C2=A0=C2=A0=C2=A0 } stct;<br>
                    =C2=A0=C2=A0=C2=A0=C2=A0<br>
                    =C2=A0=C2=A0=C2=A0 std::tuple&lt;string, bool,
                    tuple&lt;variant&lt;int, string&gt;, variant&lt;int,
                    string&gt;&gt;&gt; tup =3D { "hi", {}, { "lol", 1} };<b=
r>
                    =C2=A0=C2=A0=C2=A0=C2=A0<br>
                    <br>
                    =C2=A0=C2=A0=C2=A0 auto lol1 =3D stct.pr.first.s; //&lt=
; natural
                    access order, digging deeper into the struct<br>
                    =C2=A0=C2=A0=C2=A0=C2=A0<br>
                    =C2=A0=C2=A0=C2=A0 auto lol2 =3D
                    get&lt;string&gt;(get&lt;0&gt;(get&lt;2&gt;(tup)));
                    //&lt; reversed access, also, welcome to=C2=A0hell<br>
                    =C2=A0=C2=A0=C2=A0=C2=A0<br>
                    =C2=A0=C2=A0=C2=A0 auto lol3 =3D tup.[2].[0].[string]; =
//&lt; natural
                    access order again<br>
                    =C2=A0=C2=A0=C2=A0 </font></span><span class=3D"styled-=
by-prettify"
                  style=3D"color: #660;"></span></div>
            </code></div>
          <br>
        </div>
      </div>
    </blockquote>
    I don't think we need to access this kind of structs by index and
    type in generic code. IN generic code I wouln't mind to reverse the
    order if needed. Do you have an example?<br>
    <blockquote
      cite=3D"mid:10ad925b-8172-4e16-a647-46997f3369a0@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr">
        <div>Granted, a universal call syntax would render this example
          much less attractive. </div>
        <code class=3D"prettyprint">
          <div><br>
          </div>
          <div class=3D"subprettyprint"><br>
          </div>
        </code></div>
    </blockquote>
    <code class=3D"prettyprint"><br>
      Could you elaborate? get&lt;I&gt;(t) was chosen because
      t.get&lt;I&gt;() doesn't works always, we need template.<br>
      <br>
      struct P {<br>
      =C2=A0=C2=A0=C2=A0 std::pair&lt;int, int&gt; data;<br>
      =C2=A0=C2=A0=C2=A0 template &lt;size_t I&gt;<br>
      =C2=A0=C2=A0=C2=A0 int&amp; get() { return std::get&lt;I&gt;(data); }=
<br>
      };<br>
      <br>
      template &lt;class T&gt;<br>
      auto f(T &amp; v) {<br>
      =C2=A0=C2=A0=C2=A0 //v.get&lt;0&gt;(); // COMPILE FAILS<br>
      =C2=A0=C2=A0=C2=A0 v.template get&lt;0&gt;();<br>
      }<br>
      <br>
      <a class=3D"moz-txt-link-freetext" href=3D"http://melpon.org/wandbox/=
permlink/QLslsrDEHgV2zdlX">http://melpon.org/wandbox/permlink/QLslsrDEHgV2z=
dlX</a><br>
      <br>
      You can already have a product type </code><code
      class=3D"prettyprint"><code class=3D"prettyprint">chain </code>adapto=
r
      <br>
      <br>
    </code><code class=3D"prettyprint"><code class=3D"prettyprint"><code
          class=3D"prettyprint">=C2=A0=C2=A0=C2=A0 as_pt(lot2)(nth&lt;2&gt;=
</code><code
          class=3D"prettyprint"><code class=3D"prettyprint">, nth&lt;</code=
>3&gt;,
          type&lt;string&gt;)<br>
        </code></code></code><code class=3D"prettyprint"><br>
      It is not so friendly but it should works.<br>
      <br>
    </code><code class=3D"prettyprint"><br>
      <a class=3D"moz-txt-link-freetext" href=3D"http://melpon.org/wandbox/=
permlink/Oda6XwY2lIHD2XMU">http://melpon.org/wandbox/permlink/Oda6XwY2lIHD2=
XMU</a> <br>
      <br>
      Vicente<br>
    </code><br>
    P.S. Note that I'm not against having a way to index product types,
    but it is not so simple to find the appropriated syntax without
    breaking changes and without ambiguity.<br>
    <br>
    <code class=3D"prettyprint"><span class=3D"styled-by-prettify"
        style=3D"color: #606;"><font style=3D"background-color:
          transparent;" face=3D"Arial" color=3D"rgb(34,34,34)"><br>
        </font></span></code>What about <br>
    <br>
    <br>
    <code class=3D"prettyprint"><span class=3D"styled-by-prettify"
        style=3D"color: #606;"><font style=3D"background-color:
          transparent;" face=3D"Arial" color=3D"rgb(34,34,34)"><code
            class=3D"prettyprint"><span class=3D"styled-by-prettify"
              style=3D"color: #606;"><font style=3D"background-color:
                transparent;" face=3D"Arial" color=3D"rgb(34,34,34)"><font
                  color=3D"rgb(34,34,34)"><font color=3D"rgb(34,34,34)"><fo=
nt
                      color=3D"rgb(34,34,34)"><code class=3D"prettyprint"><=
span
                          class=3D"styled-by-prettify" style=3D"color:
                          #606;"><font style=3D"background-color:
                            transparent;" face=3D"Arial"
                            color=3D"rgb(34,34,34)">=C2=A0=C2=A0=C2=A0 auto=
 lol3 =3D tup<font
                              color=3D"rgb(34,34,34)"> <font
                                color=3D"rgb(34,34,34)">:</font> </font>2<f=
ont
                              color=3D"rgb(34,34,34)"> <font
                                color=3D"rgb(34,34,34)">:</font> </font></f=
ont></span></code><code
                        class=3D"prettyprint"><span
                          class=3D"styled-by-prettify" style=3D"color:
                          #606;"><font style=3D"background-color:
                            transparent;" face=3D"Arial"
                            color=3D"rgb(34,34,34)"><font
                              color=3D"rgb(34,34,34)"><code
                                class=3D"prettyprint"><span
                                  class=3D"styled-by-prettify"
                                  style=3D"color: #606;"></span></code></fo=
nt>0<font
                              color=3D"rgb(34,34,34)"> <font
                                color=3D"rgb(34,34,34)">:</font> </font></f=
ont></span></code><code
                        class=3D"prettyprint"><span
                          class=3D"styled-by-prettify" style=3D"color:
                          #606;"><font style=3D"background-color:
                            transparent;" face=3D"Arial"
                            color=3D"rgb(34,34,34)">string; <br>
                            <br>
                            <font color=3D"rgb(34,34,34)">or<br>
                            </font></font></span></code></font></font></fon=
t></font></span></code></font></span></code><br>
    <code class=3D"prettyprint"><span class=3D"styled-by-prettify"
        style=3D"color: #606;"><font style=3D"background-color:
          transparent;" face=3D"Arial" color=3D"rgb(34,34,34)"><code
            class=3D"prettyprint"><span class=3D"styled-by-prettify"
              style=3D"color: #606;"><font style=3D"background-color:
                transparent;" face=3D"Arial" color=3D"rgb(34,34,34)"><font
                  color=3D"rgb(34,34,34)"><font color=3D"rgb(34,34,34)"><fo=
nt
                      color=3D"rgb(34,34,34)"><code class=3D"prettyprint"><=
span
                          class=3D"styled-by-prettify" style=3D"color:
                          #606;"><font style=3D"background-color:
                            transparent;" face=3D"Arial"
                            color=3D"rgb(34,34,34)"><font
                              color=3D"rgb(34,34,34)"><code
                                class=3D"prettyprint"><span
                                  class=3D"styled-by-prettify"
                                  style=3D"color: #606;"><font
                                    style=3D"background-color:
                                    transparent;" face=3D"Arial"
                                    color=3D"rgb(34,34,34)"><code
                                      class=3D"prettyprint"><span
                                        class=3D"styled-by-prettify"
                                        style=3D"color: #606;"><font
                                          style=3D"background-color:
                                          transparent;" face=3D"Arial"
                                          color=3D"rgb(34,34,34)"><font
                                            color=3D"rgb(34,34,34)"><font
                                              color=3D"rgb(34,34,34)"><font
                                                color=3D"rgb(34,34,34)"><co=
de
                                                  class=3D"prettyprint"><sp=
an
class=3D"styled-by-prettify" style=3D"color: #606;"><font
                                                      style=3D"background-c=
olor:
                                                      transparent;"
                                                      face=3D"Arial"
                                                      color=3D"rgb(34,34,34=
)">=C2=A0=C2=A0=C2=A0
                                                      auto lol3 =3D tup<fon=
t
color=3D"rgb(34,34,34)"> <font color=3D"rgb(34,34,34)">:</font> &lt;</font>=
2<font
color=3D"rgb(34,34,34)">,</font></font></span></code><code
                                                  class=3D"prettyprint"><sp=
an
class=3D"styled-by-prettify" style=3D"color: #606;"><font
                                                      style=3D"background-c=
olor:
                                                      transparent;"
                                                      face=3D"Arial"
                                                      color=3D"rgb(34,34,34=
)"><font
color=3D"rgb(34,34,34)"><code class=3D"prettyprint"><span
                                                          class=3D"styled-b=
y-prettify"
                                                          style=3D"color:
                                                          #606;"></span></c=
ode></font>0<font
color=3D"rgb(34,34,34)">,</font></font></span></code><code
                                                  class=3D"prettyprint"><sp=
an
class=3D"styled-by-prettify" style=3D"color: #606;"><font
                                                      style=3D"background-c=
olor:
                                                      transparent;"
                                                      face=3D"Arial"
                                                      color=3D"rgb(34,34,34=
)">string&gt;;
                                                      <br>
                                                    </font></span></code></=
font></font></font></font></span></code></font></span></code></font><br>
                            <br>
                            <font color=3D"rgb(34,34,34)">':' after a
                              product type will accept an index or a </font=
>type
                            or a <font color=3D"rgb(34,34,34)">sequence</fo=
nt>
                            of index <font color=3D"rgb(34,34,34)">or
                              types<br>
                              <br>
                              <font color=3D"rgb(34,34,34)">I don't <font
                                  color=3D"rgb(34,34,34)">know if this
                                  could be a breaking change or needs
                                  too much look ahead</font></font>.<br>
                            </font><br>
                          </font></span></code></font></font></font></font>=
</span></code></font></span></code><code
      class=3D"prettyprint"><span class=3D"styled-by-prettify" style=3D"col=
or:
        #606;"><font style=3D"background-color: transparent;" face=3D"Arial=
"
          color=3D"rgb(34,34,34)"><br>
        </font></span></code><br>
  </body>
</html>

<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/93b9f921-c417-aa64-8a02-6341054c6067%=
40wanadoo.fr?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/93b9f921-c417-aa64-8a02-6341054c6067=
%40wanadoo.fr</a>.<br />

--------------2149EAB6108D9316C68D43AA--

.


Author: mihailnajdenov@gmail.com
Date: Sun, 23 Oct 2016 12:05:48 -0700 (PDT)
Raw View
------=_Part_472_1782563246.1477249548668
Content-Type: multipart/alternative;
 boundary="----=_Part_473_1169858624.1477249548669"

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



On Sunday, October 23, 2016 at 8:32:00 PM UTC+3, Vicente J. Botet Escriba=
=20
wrote:
>
> Le 23/10/2016 =C3=A0 13:59, mihailn...@gmail.com <javascript:> a =C3=A9cr=
it :
>
> ...
>
> I don't think we need to access this kind of structs by index and type in=
=20
> generic code. IN generic code I wouln't mind to reverse the order if=20
> needed. Do you have an example?
>
> Granted, a universal call syntax would render this example much less=20
> attractive.=20
>
>
> Could you elaborate? get<I>(t) was chosen because t.get<I>() doesn't work=
s=20
> always, we need template.
>       ...
>
>
Yeah, in generic code, the standard, non-universal syntax, will be used.=20
The point was for regular, simple uses (and users...).

As for, do we need access of structs by index - this will allow code=20
written against a tuple to accept a struct also.
An algorithm can be written against a generic "type with this number=20
of fields of this and this type" without care what the containing type is.
There is already such symmetry b/w pair, tuple and array and I think it is=
=20
a good thing.

The idea is, this access to be for types (not only pt-s) what iterators are=
=20
to containers - the real type of the container does not matter for the=20
access.=20

Having said that, to have this as default for every possible type is=20
probably not a good idea, still, easy adaptors should be possible.=20


In any case. This is not the core of the proposal !


The core is - to have native access for tuples and, for the time being,=20
until a build-in type, for variant as well.=20

The reason is, tuple access will not change - be it build-in or library, it=
=20
will always be access pretty much the same way - either by integer or type=
=20
index.=20
Considering it is a core "vocabulary" type now, the awkward way it is=20
access is quite glaring. Especially for a new comer.=20

After all, the tuple is not just for template metaprogrammers - it is as=20
basic a s struct, arguably even more basic!=20
Considering tuple is here to stay, its access should be promoted to a=20
language feature, so new comers can get a feel for it more easily.=20
(Again, no matter the impl. of tuple, the access will be the same)

That is the reason for the proposed syntax as well - the mix of two basic=
=20
expressions which are learned in the first week (probably).

Dot means - dig into a struct to get a contained object
A number surrounded with square brackets means "index", note, not just in=
=20
C/C++ but in other, non-programming places like Wikipedia page references=
=20
and others.=20

Combined, dot and number-in-beckets, just mean dig into "a struct" and pick=
=20
at this index.=20
(The user should not think much about templates at this point - even if=20
told what template is, he will be told in the context of tuple<int, string>=
=20
or vector<int>,=20
not in the context of passing is as an argument to a function, which is=20
weird even in normal, day to day c++!)

Lastly, in the context of the fancy structured bindings, the lack of a=20
native way to pick just one element is simply sad. =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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/7e4f3974-a085-4639-bad9-a639c85a0fe3%40isocpp.or=
g.

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

<div dir=3D"ltr"><br><br>On Sunday, October 23, 2016 at 8:32:00 PM UTC+3, V=
icente J. Botet Escriba wrote:<blockquote class=3D"gmail_quote" style=3D"ma=
rgin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
 =20
   =20
 =20
  <div text=3D"#000000" bgcolor=3D"#FFFFFF">
    <div>Le 23/10/2016 =C3=A0 13:59,
      <a onmousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" onc=
lick=3D"this.href=3D&#39;javascript:&#39;;return true;" href=3D"javascript:=
" target=3D"_blank" rel=3D"nofollow" gdf-obfuscated-mailto=3D"qjxDWUmWAAAJ"=
>mihailn...@gmail.com</a> a =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote type=3D"cite">
      <div dir=3D"ltr">
        <div>...<br></div>
       =20
      </div>
    </blockquote>
    I don&#39;t think we need to access this kind of structs by index and
    type in generic code. IN generic code I wouln&#39;t mind to reverse the
    order if needed. Do you have an example?<br>
    <blockquote type=3D"cite">
      <div dir=3D"ltr">
        <div>Granted, a universal call syntax would render this example
          much less attractive. </div><code><div><br>
          </div>
</code><div><code><br>
      Could you elaborate? get&lt;I&gt;(t) was chosen because
      t.get&lt;I&gt;() doesn&#39;t works always, we need template.<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ...</code></div></div></blockquote></div></b=
lockquote><div><br></div><div><div>Yeah, in generic code, the standard,=C2=
=A0non-universal syntax, will be used. The point was for regular, simple=C2=
=A0uses (and users...).</div><div><br></div><div>As for, do we need access =
of structs by index - this will allow code written against a tuple to accep=
t a struct also.</div><div>An algorithm can be written against a generic &q=
uot;type with this number of=C2=A0fields of this and this type&quot; withou=
t care what the containing type is.</div><div>There is already such symmetr=
y b/w pair, tuple and array and I think it is a good thing.</div><div><br><=
/div><div>The idea is, this access to be for types (not only pt-s) what ite=
rators are to containers - the real type of the container=C2=A0does not mat=
ter for the access. </div><div><br></div><div>Having said that, to have thi=
s as default for every possible type is probably not a good idea, still, ea=
sy adaptors should be possible. </div><div><br></div><div><br></div><div>In=
 any case. This is not the core of the proposal !</div><div><br></div><div>=
<br></div><div>The core is - to have native access for tuples and, for the =
time being, until a build-in type, for variant as well. </div><div><br></di=
v><div>The reason is, tuple access will not change - be it build-in or libr=
ary,=C2=A0it will always be access pretty much the same way - either by int=
eger or type index. </div><div>Considering it is a core &quot;vocabulary&qu=
ot;=C2=A0type now, the awkward way it is access is quite glaring. Especiall=
y for a new comer. </div><div><br></div><div>After all, the tuple is not ju=
st for template metaprogrammers - it is as basic a s struct, arguably even =
more basic! </div><div>Considering tuple is here to stay, its access should=
 be promoted to a language feature, so new comers can get a feel for it mor=
e easily. </div><div>(Again, no matter the impl. of tuple, the access will =
be the same)</div><div><br></div><div>That is the reason=C2=A0for the propo=
sed syntax as well - the mix of two basic expressions which are learned in =
the first week (probably).</div><div><br></div><div>Dot means - dig into a =
struct to get a contained object</div><div>A number surrounded with square =
brackets means &quot;index&quot;, note, not just=C2=A0in C/C++ but in other=
, non-programming=C2=A0places like Wikipedia page=C2=A0references and other=
s. </div><div><br></div><div>Combined, dot and=C2=A0number-in-beckets,=C2=
=A0just mean dig into &quot;a struct&quot; and pick at this index. </div><d=
iv>(The user should not think much about templates at this point - even if =
told what template is, he will be told in the context of tuple&lt;int, stri=
ng&gt; or vector&lt;int&gt;, </div><div>not in the context of passing is as=
=C2=A0an argument to a function, which is weird even in normal, day to day =
c++!)</div><div><br></div><div>Lastly, in the context of the fancy structur=
ed bindings, the lack of a native=C2=A0way to pick just one element is simp=
ly sad. =C2=A0</div><div><br></div><div><br></div></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/7e4f3974-a085-4639-bad9-a639c85a0fe3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/7e4f3974-a085-4639-bad9-a639c85a0fe3=
%40isocpp.org</a>.<br />

------=_Part_473_1169858624.1477249548669--

------=_Part_472_1782563246.1477249548668--

.