Topic: Structurally Bound Aliases


Author: Derek Ross <antiquarktv@gmail.com>
Date: Sun, 4 Dec 2016 11:24:46 -0800 (PST)
Raw View
------=_Part_524_1993308492.1480879486955
Content-Type: multipart/alternative;
 boundary="----=_Part_525_346849692.1480879486955"

------=_Part_525_346849692.1480879486955
Content-Type: text/plain; charset=UTF-8

This idea is motivated by the problem of utilizing existing types, but with
a desire to change the names of the members.

For example, say you want to use pair<int,int> as a coordinate type:


 using coord_t = pair<int,int>;


This is useful because you get a bunch of stuff already implemented by the
pair. However you're stuck with the 'first' and 'second' member naming.  It
would be nice if we could rename 'first' to 'x' and 'second' to 'y' to make
them more self-descriptive.

Maybe the structured binding syntax can be hijacked for this purpose.

I propose the following syntax:


 using coord_t auto [x, y] = pair<int,int> ;


So this means that a type alias named coord_t is created, and it has two
members which are aliased to pair::first and pair::second.

This could also be used with tuples, like:


 using student_t auto [firstname, lastname, age] = tuple<string, string, int
>;


That's all... thanks!
Derek

--
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/9ebd97ee-5a14-426a-b5f6-8815961f8b7c%40isocpp.org.

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

<div dir=3D"ltr">This idea is motivated by the problem of utilizing existin=
g types, but with a desire to change the names of the members. <br><br>For =
example, say you want to use pair&lt;int,int&gt; as a coordinate type:<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: #000;" class=3D"styled-by-prettify"><br>=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"> coord_t </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> pair</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">int</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&gt;;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br><br></span></div></code></div>=C2=A0<br>This is useful =
because you get a bunch of stuff already implemented by the pair. However y=
ou&#39;re stuck with the &#39;first&#39; and &#39;second&#39; member naming=
..=C2=A0 It would be nice if we could rename &#39;first&#39; to &#39;x&#39; =
and &#39;second&#39; to &#39;y&#39; to make them more self-descriptive.<br>=
<br>Maybe the structured binding syntax can be hijacked for this purpose. <=
br><br>I propose the following syntax:<br><br><div class=3D"prettyprint" st=
yle=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 18=
7); border-style: solid; border-width: 1px; word-wrap: break-word;"><code c=
lass=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">=C2=A0<br>=C2=A0</span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">using</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> coord_t </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">x</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> y</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> pair</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">int</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">,</span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">int</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0<br><br></span><=
/div></code></div><br>So this means that a type alias named coord_t is crea=
ted, and it has two members which are aliased to pair::first and pair::seco=
nd.<br><br>This could also be used with tuples, like: <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: brea=
k-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0<br>=C2=A0</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">using</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> student_t </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">firstname</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> lastname</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> age</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">]</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> tuple</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">string</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">string</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">i=
nt</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></spa=
n></div></code></div><br>That&#39;s all... thanks!<br>Derek<br></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/9ebd97ee-5a14-426a-b5f6-8815961f8b7c%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/9ebd97ee-5a14-426a-b5f6-8815961f8b7c=
%40isocpp.org</a>.<br />

------=_Part_525_346849692.1480879486955--

------=_Part_524_1993308492.1480879486955--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sun, 4 Dec 2016 11:47:10 -0800 (PST)
Raw View
------=_Part_1177_2035929616.1480880830516
Content-Type: multipart/alternative;
 boundary="----=_Part_1178_1504878946.1480880830516"

------=_Part_1178_1504878946.1480880830516
Content-Type: text/plain; charset=UTF-8



On Sunday, December 4, 2016 at 2:24:47 PM UTC-5, Derek Ross wrote:
>
> This idea is motivated by the problem of utilizing existing types, but
> with a desire to change the names of the members.
>
> For example, say you want to use pair<int,int> as a coordinate type:
>
>
>  using coord_t = pair<int,int>;
>
>
> This is useful because you get a bunch of stuff already implemented by the
> pair.
>

Um, what "stuff" are we talking about? Let's go over the features of `pair`:

* Piecewise construction from a pair of `tuple`s.
* Comparison forwarded to members.
* `get/tuple_element/tuple_size` overloads.
* `swap`.
* `make_pair`

With the exception of the first, there are C++ features that cover these,
or proposals in various stages of review that provide these to user-defined
types. Comparison operator generation is still on the table for C++20.
There have been discussions about automatically generating `get/etc`
overloads for publicly accessible "product types". `std::swap` is perfectly
capable of handling swap behavior. And `make_pair` is essentially obsolete
now that we have template constructor deduction.

So what exactly is it that you *need* from `pair<int, int>` that you
couldn't get from a user-defined struct?

Let's not encourage people to use tuples as a cheap way to make
user-defined types. Let's instead make normal user-defined types more
feature-rich.

--
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/5012391a-c91e-4dd6-9120-3bcf9abfc3d2%40isocpp.org.

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

<div dir=3D"ltr"><br><br>On Sunday, December 4, 2016 at 2:24:47 PM UTC-5, D=
erek Ross 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"lt=
r">This idea is motivated by the problem of utilizing existing types, but w=
ith a desire to change the names of the members. <br><br>For example, say y=
ou want to use pair&lt;int,int&gt; as a coordinate type:<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:#000"><br>=C2=A0</span><span style=3D"color:#008">using</span><sp=
an style=3D"color:#000"> coord_t </span><span style=3D"color:#660">=3D</spa=
n><span style=3D"color:#000"> pair</span><span style=3D"color:#660">&lt;</s=
pan><span style=3D"color:#008">int</span><span style=3D"color:#660">,</span=
><span style=3D"color:#008">int</span><span style=3D"color:#660">&gt;;</spa=
n><span style=3D"color:#000"><br><br></span></div></code></div>=C2=A0<br>Th=
is is useful because you get a bunch of stuff already implemented by the pa=
ir.</div></blockquote><div><br>Um, what &quot;stuff&quot; are we talking ab=
out? Let&#39;s go over the features of `pair`:<br><br>* Piecewise construct=
ion from a pair of `tuple`s.<br>* Comparison forwarded to members.<br>* `ge=
t/tuple_element/tuple_size` overloads.<br>* `swap`.<br>* `make_pair`<br><br=
>With the exception of the first, there are C++ features that cover these, =
or proposals in various stages of review that provide these to user-defined=
 types. Comparison operator generation is still on the table for C++20. The=
re have been discussions about automatically generating `get/etc` overloads=
 for publicly accessible &quot;product types&quot;. `std::swap` is perfectl=
y capable of handling swap behavior. And `make_pair` is essentially obsolet=
e now that we have template constructor deduction.<br><br>So what exactly i=
s it that you <i>need</i> from `pair&lt;int, int&gt;` that you couldn&#39;t=
 get from a user-defined struct?<br><br>Let&#39;s not encourage people to u=
se tuples as a cheap way to make user-defined types. Let&#39;s instead make=
 normal user-defined types more feature-rich.<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/5012391a-c91e-4dd6-9120-3bcf9abfc3d2%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/5012391a-c91e-4dd6-9120-3bcf9abfc3d2=
%40isocpp.org</a>.<br />

------=_Part_1178_1504878946.1480880830516--

------=_Part_1177_2035929616.1480880830516--

.


Author: Derek Ross <antiquarktv@gmail.com>
Date: Sun, 4 Dec 2016 14:40:58 -0800 (PST)
Raw View
------=_Part_3406_197320466.1480891258137
Content-Type: multipart/alternative;
 boundary="----=_Part_3407_2131958867.1480891258137"

------=_Part_3407_2131958867.1480891258137
Content-Type: text/plain; charset=UTF-8



On Sunday, December 4, 2016 at 1:47:10 PM UTC-6, Nicol Bolas wrote:
>
>
> So what exactly is it that you *need* from `pair<int, int>` that you
> couldn't get from a user-defined struct?
>

I may need any or all of it!  It's an "epic win" in a productivity sense if
I can use a std::pair without reinventing a bunch of wheels that pair
already implements. If I have to write functions and operators for my
struct (again and again), there will be some bugs in there, which I can
avoid by using std::pair.


>
> Let's not encourage people to use tuples as a cheap way to make
> user-defined types. Let's instead make normal user-defined types more
> feature-rich.
>

I consulted my copy of TC++PL, and Bjarne thinks it's OK to use std::pair
as a struct replacement. So if he's not concerned with cheap types, then
probably, people shouldn't worry too much about it.


--
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/fb84a940-fc6e-40c7-9d18-9f7d4a5c6d57%40isocpp.org.

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

<div dir=3D"ltr"><br><br>On Sunday, December 4, 2016 at 1:47:10 PM UTC-6, N=
icol Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr"><br><div>So what exactly is it that you <i>need</i> from `pair&lt;int, =
int&gt;` that you couldn&#39;t get from a user-defined struct?<br></div></d=
iv></blockquote><div><br>I may need any or all of it!=C2=A0 It&#39;s an &qu=
ot;epic win&quot; in a productivity sense if I can use a std::pair without =
reinventing a bunch of wheels that pair already implements. If I have to wr=
ite functions and operators for my struct (again and again), there will be =
some bugs in there, which I can avoid by using std::pair. <br>=C2=A0</div><=
blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bord=
er-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><br>Let&#=
39;s not encourage people to use tuples as a cheap way to make user-defined=
 types. Let&#39;s instead make normal user-defined types more feature-rich.=
<br></div></div></blockquote><div><br>I consulted my copy of TC++PL, and Bj=
arne thinks it&#39;s OK to use std::pair as a struct replacement. So if he&=
#39;s not concerned with cheap types, then probably, people shouldn&#39;t w=
orry too much about it. <br><br><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/fb84a940-fc6e-40c7-9d18-9f7d4a5c6d57%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/fb84a940-fc6e-40c7-9d18-9f7d4a5c6d57=
%40isocpp.org</a>.<br />

------=_Part_3407_2131958867.1480891258137--

------=_Part_3406_197320466.1480891258137--

.


Author: Larry Evans <cppljevans@suddenlink.net>
Date: Sun, 4 Dec 2016 17:48:16 -0600
Raw View
On 12/04/2016 01:24 PM, Derek Ross wrote:
> This idea is motivated by the problem of utilizing existing types, but
> with a desire to change the names of the members.
>
> For example, say you want to use pair<int,int> as a coordinate type:
>
> |
>
>  usingcoord_t =pair<int,int>;
>
> |
>
> This is useful because you get a bunch of stuff already implemented by
> the pair. However you're stuck with the 'first' and 'second' member
> naming.  It would be nice if we could rename 'first' to 'x' and 'second'
> to 'y' to make them more self-descriptive.
>
> Maybe the structured binding syntax can be hijacked for this purpose.
>
> I propose the following syntax:
>
> |
>
>  usingcoord_t auto[x,y]=pair<int,int>;
>
> |
>
> So this means that a type alias named coord_t is created, and it has two
> members which are aliased to pair::first and pair::second.
>
> This could also be used with tuples, like:
>
> |
>
>  usingstudent_t auto[firstname,lastname,age]=tuple<string,string,int>;
>
> |
>
> That's all... thanks!
> Derek
A related discussion about "tagged_tuple" occurred here:

https://groups.google.com/a/isocpp.org/forum/#!msg/std-proposals/pk4s49YJpUg/CgprxLydEgAJ






--
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/o226er%24dvv%241%40blaine.gmane.org.

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sun, 4 Dec 2016 16:55:25 -0800 (PST)
Raw View
------=_Part_3623_2044218306.1480899325267
Content-Type: multipart/alternative;
 boundary="----=_Part_3624_334506465.1480899325268"

------=_Part_3624_334506465.1480899325268
Content-Type: text/plain; charset=UTF-8

On Sunday, December 4, 2016 at 5:40:58 PM UTC-5, Derek Ross wrote:
>
> On Sunday, December 4, 2016 at 1:47:10 PM UTC-6, Nicol Bolas wrote:
>>
>>
>> So what exactly is it that you *need* from `pair<int, int>` that you
>> couldn't get from a user-defined struct?
>>
>
> I may need any or all of it!  It's an "epic win" in a productivity sense
> if I can use a std::pair without reinventing a bunch of wheels that pair
> already implements. If I have to write functions and operators for my
> struct (again and again), there will be some bugs in there, which I can
> avoid by using std::pair.
>

OK, let's look at your example:

using coord_t = pair<int,int>;

You have a type which is a coordinate. If you were writing this type from
scratch, there are many things from `pair` you wouldn't add. Not because
they're time consuming, but because they're not appropriate for `coord_t`.

For example, what good is the piecewise constructor for `pair` in this
case? Do you honestly expect users to pass two tuples when creating a
`coord_t`? No; it's a pointless interface. It adds nothing useful to the
type.

But there are worse issues in this regard. Take the less/greater comparison
operators. It makes absolutely no sense to even *ask* the question of
whether one `coord_t` is less than another. Yet your `pair`-based object
provides exactly that. This is not just confusing to the user; it is
actively dangerous. It gives the impression that it is reasonable to order
`coord_t` objects, when it probably isn't. And even if it is, do you really
want them ordered this way? Or do you want to order them in some other way?

So at best, what you've done is made a type that has a poor interface, one
with more functions than is actually needed. At worse, you've made a type
that has a *misleading* interface.

Whereas given the various proposals for automatic "product type" and
equality operator generation, you would get a far better object with a
better interface, just by doing this:

struct coord_t {int x; int y;};

Let's not encourage people to use tuples as a cheap way to make
>> user-defined types. Let's instead make normal user-defined types more
>> feature-rich.
>>
>
> I consulted my copy of TC++PL, and Bjarne thinks it's OK to use std::pair
> as a struct replacement. So if he's not concerned with cheap types, then
> probably, people shouldn't worry too much about it.
>

Bjarne also thinks that the template induction syntax in Concepts TS is a
good thing too. Bjarne has good ideas, but that doesn't mean his word
should be considered definitive.

--
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/e3a25cae-7046-4a20-b8ce-1e25bb99764d%40isocpp.org.

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

<div dir=3D"ltr">On Sunday, December 4, 2016 at 5:40:58 PM UTC-5, Derek Ros=
s 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">On Su=
nday, December 4, 2016 at 1:47:10 PM UTC-6, Nicol Bolas wrote:<blockquote c=
lass=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #c=
cc solid;padding-left:1ex"><div dir=3D"ltr"><br><div>So what exactly is it =
that you <i>need</i> from `pair&lt;int, int&gt;` that you couldn&#39;t get =
from a user-defined struct?<br></div></div></blockquote><div><br>I may need=
 any or all of it!=C2=A0 It&#39;s an &quot;epic win&quot; in a productivity=
 sense if I can use a std::pair without reinventing a bunch of wheels that =
pair already implements. If I have to write functions and operators for my =
struct (again and again), there will be some bugs in there, which I can avo=
id by using std::pair.<br></div></div></blockquote><div><br>OK, let&#39;s l=
ook at your example:<br><br><div style=3D"background-color: rgb(250, 250, 2=
50); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1=
px; overflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"pretty=
print"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"=
styled-by-prettify">using</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> coord_t </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> pair</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&gt;;</span></div></code></=
div><br>You have a type which is a coordinate. If you were writing this typ=
e from scratch, there are many things from `pair` you wouldn&#39;t add. Not=
 because they&#39;re time consuming, but because they&#39;re not appropriat=
e for `coord_t`.<br><br>For example, what good is the piecewise constructor=
 for `pair` in this case? Do you honestly expect users to pass two tuples w=
hen creating a `coord_t`? No; it&#39;s a pointless interface. It adds nothi=
ng useful to the type.<br><br>But there are worse issues in this regard. Ta=
ke the less/greater comparison operators. It makes absolutely no sense to e=
ven <i>ask</i> the question of whether one `coord_t` is less than another. =
Yet your `pair`-based object provides exactly that. This is not just confus=
ing to the user; it is actively dangerous. It gives the impression that it =
is reasonable to order `coord_t` objects, when it probably isn&#39;t. And e=
ven if it is, do you really want them ordered this way? Or do you want to o=
rder them in some other way?<br><br>So at best, what you&#39;ve done is mad=
e a type that has a poor interface, one with more functions than is actuall=
y needed. At worse, you&#39;ve made a type that has a <i>misleading</i> int=
erface.<br><br>Whereas given the various proposals for automatic &quot;prod=
uct type&quot; and equality operator generation, you would get a far better=
 object with a better interface, just by doing this:<br><br><div style=3D"b=
ackground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); bord=
er-style: solid; border-width: 1px; overflow-wrap: break-word;" class=3D"pr=
ettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span =
style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> coord_t </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> x</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
y</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;};</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div=
></code></div><br></div><blockquote class=3D"gmail_quote" style=3D"margin: =
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div d=
ir=3D"ltr"><div></div><blockquote class=3D"gmail_quote" style=3D"margin:0;m=
argin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"l=
tr"><div>Let&#39;s not encourage people to use tuples as a cheap way to mak=
e user-defined types. Let&#39;s instead make normal user-defined types more=
 feature-rich.<br></div></div></blockquote><div><br>I consulted my copy of =
TC++PL, and Bjarne thinks it&#39;s OK to use std::pair as a struct replacem=
ent. So if he&#39;s not concerned with cheap types, then probably, people s=
houldn&#39;t worry too much about it. </div></div></blockquote><div><br>Bja=
rne also thinks that the template induction syntax in Concepts TS is a good=
 thing too. Bjarne has good ideas, but that doesn&#39;t mean his word shoul=
d be considered definitive.<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/e3a25cae-7046-4a20-b8ce-1e25bb99764d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/e3a25cae-7046-4a20-b8ce-1e25bb99764d=
%40isocpp.org</a>.<br />

------=_Part_3624_334506465.1480899325268--

------=_Part_3623_2044218306.1480899325267--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Mon, 05 Dec 2016 13:19:12 -0800
Raw View
Em domingo, 4 de dezembro de 2016, =C3=A0s 11:24:46 PST, Derek Ross escreve=
u:
> This idea is motivated by the problem of utilizing existing types, but wi=
th
> a desire to change the names of the members.
>=20
> For example, say you want to use pair<int,int> as a coordinate type:
>=20
>=20
>  using coord_t =3D pair<int,int>;

Can you give an example that doesn't use pair or tuple?

--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center

--=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/5092075.oYp9xNUEDx%40tjmaciei-mobl1.

.


Author: Derek Ross <antiquarktv@gmail.com>
Date: Mon, 5 Dec 2016 14:24:33 -0800 (PST)
Raw View
------=_Part_4471_44136385.1480976673098
Content-Type: multipart/alternative;
 boundary="----=_Part_4472_193905109.1480976673098"

------=_Part_4472_193905109.1480976673098
Content-Type: text/plain; charset=UTF-8


>
>
> Can you give an example that doesn't use pair or tuple?
>

You might want to convert the elements of an array into named fields, like:

   char rawbuffer[4] = {41,42,43,44};
   auto [ stx, type, data, etx ] = rawbuffer;

--
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/d1e6595a-db05-4fcb-b7ea-c2d273b9bbd9%40isocpp.org.

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

<div dir=3D"ltr"><div><blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">=C2=A0<b=
r>Can you give an example that doesn&#39;t use pair or tuple?
<br>
</blockquote><div><br></div><div>You might want to convert the elements of =
an array into named fields, like:=C2=A0</div><div><br></div><div class=3D"p=
rettyprint" 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 style=3D"color: #000;" class=3D"styled-b=
y-prettify">=C2=A0 =C2=A0</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">char</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> rawbuffer</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">=
4</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: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">{</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">41</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">,</span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">42</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,=
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">43</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #066;" class=3D"styled-by-prettify">44</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0<br>=C2=A0 =C2=A0</span><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> stx</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> type</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> data</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> etx </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> rawbuffer</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">;</span></div></code></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/d1e6595a-db05-4fcb-b7ea-c2d273b9bbd9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d1e6595a-db05-4fcb-b7ea-c2d273b9bbd9=
%40isocpp.org</a>.<br />

------=_Part_4472_193905109.1480976673098--

------=_Part_4471_44136385.1480976673098--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Mon, 05 Dec 2016 15:52:28 -0800
Raw View
Em segunda-feira, 5 de dezembro de 2016, =C3=A0s 14:24:33 PST, Derek Ross e=
screveu:
> > Can you give an example that doesn't use pair or tuple?
>=20
> You might want to convert the elements of an array into named fields, lik=
e:
>=20
>    char rawbuffer[4] =3D {41,42,43,44};
>    auto [ stx, type, data, etx ] =3D rawbuffer;

This should work with structured bindings, provided there's a get<N> for=20
char[].

But this example didn't use your "using" proposal.

Let me be more specific: do you see this used with anything besides pair,=
=20
tuple, and trivial types?

--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center

--=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/1842551.1pn9GujV1S%40tjmaciei-mobl1.

.


Author: Derek Ross <antiquarktv@gmail.com>
Date: Mon, 5 Dec 2016 17:04:36 -0800 (PST)
Raw View
------=_Part_138_98114534.1480986276674
Content-Type: multipart/alternative;
 boundary="----=_Part_139_431791461.1480986276674"

------=_Part_139_431791461.1480986276674
Content-Type: text/plain; charset=UTF-8



> Let me be more specific: do you see this used with anything besides pair,
> tuple, and trivial types?
>

My personal motivation is to provide a way of "renaming" the elements of
pairs and tuples, so it's easy to create structs that have the various
features of pair/tuple. But it could be used anywhere where structured
bindings are.




--
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/f22f36d3-6e6a-4f5d-96d2-fa530bc0b4dd%40isocpp.org.

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

<div dir=3D"ltr"><br><blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Let me be=
 more specific: do you see this used with anything besides pair,=20
<br>tuple, and trivial types?
<br></blockquote><div><br>My personal motivation is to provide a way of &qu=
ot;renaming&quot; the elements of pairs and tuples, so it&#39;s easy to cre=
ate structs that have the various features of pair/tuple. But it could be u=
sed anywhere where structured bindings are. <br><br><br>=C2=A0<br></div></d=
iv>

<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/f22f36d3-6e6a-4f5d-96d2-fa530bc0b4dd%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/f22f36d3-6e6a-4f5d-96d2-fa530bc0b4dd=
%40isocpp.org</a>.<br />

------=_Part_139_431791461.1480986276674--

------=_Part_138_98114534.1480986276674--

.


Author: Daniel Boles <db0451@gmail.com>
Date: Tue, 06 Dec 2016 01:16:37 +0000
Raw View
I feel like this is really circular:
 * Person doesn't want to continually write structs with the same =C2=A0
   methods
 * Person users an extremely generic type
 * Person is annoyed at how generic the type is
 * Person tries to add scaffolding to make the type look like a struct
 * Person says that structs could learn from the generic type

At a certain point, we just need to calm down, and use a struct.

--=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/1480986997.2164.2.camel%40gmail.com.

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Tue, 6 Dec 2016 13:33:11 -0800 (PST)
Raw View
------=_Part_2545_812018104.1481059991779
Content-Type: multipart/alternative;
 boundary="----=_Part_2546_86194271.1481059991779"

------=_Part_2546_86194271.1481059991779
Content-Type: text/plain; charset=UTF-8

On Monday, December 5, 2016 at 8:16:41 PM UTC-5, D. B. wrote:
>
> I feel like this is really circular:
>  * Person doesn't want to continually write structs with the same
>    methods
>  * Person users an extremely generic type
>  * Person is annoyed at how generic the type is
>  * Person tries to add scaffolding to make the type look like a struct
>  * Person says that structs could learn from the generic type
>
> At a certain point, we just need to calm down, and use a struct.
>

Not only that, there is every chance that we'll be able to give a type most
of the features of `pair` and `tuple` with minimal or zero effort. So as
C++ becomes a better language, there will be less need for such a feature.

--
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/aaa3aa98-b7ff-4b81-a91b-860da6d0f01b%40isocpp.org.

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

<div dir=3D"ltr">On Monday, December 5, 2016 at 8:16:41 PM UTC-5, D. B. wro=
te:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;=
border-left: 1px #ccc solid;padding-left: 1ex;">I feel like this is really =
circular:
<br>=C2=A0* Person doesn&#39;t want to continually write structs with the s=
ame =C2=A0
<br>=C2=A0 =C2=A0methods
<br>=C2=A0* Person users an extremely generic type
<br>=C2=A0* Person is annoyed at how generic the type is
<br>=C2=A0* Person tries to add scaffolding to make the type look like a st=
ruct
<br>=C2=A0* Person says that structs could learn from the generic type
<br>
<br>At a certain point, we just need to calm down, and use a struct.
<br></blockquote><div><br>Not only that, there is every chance that we&#39;=
ll be able to give a type most of the features of `pair` and `tuple` with m=
inimal or zero effort. So as C++ becomes a better language, there will be l=
ess need for such a feature.<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/aaa3aa98-b7ff-4b81-a91b-860da6d0f01b%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/aaa3aa98-b7ff-4b81-a91b-860da6d0f01b=
%40isocpp.org</a>.<br />

------=_Part_2546_86194271.1481059991779--

------=_Part_2545_812018104.1481059991779--

.