Topic: Allow to access member typedefs of a type


Author: "'Matt Calabrese' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Thu, 20 Apr 2017 13:44:21 -0400
Raw View
--94eb2c18cda4efdb23054d9cb05a
Content-Type: text/plain; charset=UTF-8

On Thu, Apr 20, 2017 at 3:57 AM, Jakob Riedle <jakob.riedle@gmail.com>
wrote:

> I don't know whether it is a good idea to consider *reference to class *a *class
> type.*
>

That's not what is being argued for and is not necessary to accomplish the
OP's goal. We would not need to do anything so drastic to simply allow ::
to work that way with reference types.

--
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/CANh8DEnr0KEH0_yuu6gSJzq4U49nd%3DPVb6sYHQAMTxgLb-UvJA%40mail.gmail.com.

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

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
hu, Apr 20, 2017 at 3:57 AM, Jakob Riedle <span dir=3D"ltr">&lt;<a href=3D"=
mailto:jakob.riedle@gmail.com" target=3D"_blank">jakob.riedle@gmail.com</a>=
&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0=
 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>=
I don&#39;t know whether it is a good idea to consider <i>reference to clas=
s </i>a <i>class type.</i></div></div></blockquote><div><br></div><div>That=
&#39;s not what is being argued for and is not necessary to accomplish the =
OP&#39;s goal. We would not need to do anything so drastic to simply allow =
:: to work that way with reference types.</div></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/CANh8DEnr0KEH0_yuu6gSJzq4U49nd%3DPVb6=
sYHQAMTxgLb-UvJA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANh8DEnr0KEH0_=
yuu6gSJzq4U49nd%3DPVb6sYHQAMTxgLb-UvJA%40mail.gmail.com</a>.<br />

--94eb2c18cda4efdb23054d9cb05a--

.


Author: Jakob Riedle <jakob.riedle@gmail.com>
Date: Thu, 20 Apr 2017 14:04:42 -0700 (PDT)
Raw View
------=_Part_3614_1689940736.1492722283044
Content-Type: multipart/alternative;
 boundary="----=_Part_3615_633958372.1492722283044"

------=_Part_3615_633958372.1492722283044
Content-Type: text/plain; charset=UTF-8


>
> We would not need to do anything so drastic to simply allow :: to work
> that way with reference types.
>

I know, what you mean and you're right I guess.
For me personally, I had the following situation:
I wrote a template that does some stuff, not overly straightforward, it
just does what I designed it for.
Within that template, some member is referenced from one of the supplied
template parameters.

When I worked on a different part of my program and expected the former
template to work on references as well.
Since GCC gave me an error telling me that I had not thought of this case,
I realized, that I did not think about a bunch of other cases as well (e.g.
with volatile, const, *, && and so on).

My personal problem is a little bit (that's just my opinion, not that I'm
completely against it)
that removing this source of information about potentially unconsidered
cases in favor of a little less typing might not always be desirable.

What I do have to admit is, that your proposal reduces typing at spots,
where it is harmless to do so in maybe 70% of all the cases.
*Note:* One (potential) agrument infor your proposal is, that
const-qualified types *are *class types (resp. union- or struct-).


Hope this makes my position a little clearer
Jakob


PS: Why did nobody else answer in this discussion thread yet? Is this
question not important to many people or what?


--
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/a89a619e-84d6-43da-983e-61e8a4158f87%40isocpp.org.

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

<div dir=3D"ltr"><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"><div class=3D"gmail_quote">We would not need to do anything so drastic =
to simply allow :: to work that way with reference types.<br></div></div></=
blockquote><div><br></div><div>I know, what you mean and you&#39;re right I=
 guess.</div><div>For me personally, I had the following situation:</div><d=
iv>I wrote a template that does some stuff, not overly straightforward, it =
just does what I designed it for.</div><div>Within that template, some memb=
er is referenced from one of the supplied template parameters.</div><div><b=
r></div><div>When I worked on a different part of my program and expected t=
he former template to work on references as well.</div><div>Since GCC gave =
me an error telling me that I had not thought of this case,</div><div>I rea=
lized, that I did not think about a bunch of other cases as well (e.g. with=
 volatile, const, *, &amp;&amp; and so on).</div><div><br></div><div>My per=
sonal problem is a little bit (that&#39;s just my opinion, not that I&#39;m=
 completely against it)</div><div>that removing this source of information =
about potentially unconsidered cases in favor of a little less typing might=
 not always be desirable.</div><div><br></div><div>What I do have to admit =
is, that your proposal reduces typing at spots, where it is harmless to do =
so in maybe 70% of all the cases.</div><div><i>Note:</i> One (potential) ag=
rument infor your proposal is, that const-qualified types <b>are </b>class =
types (resp. union- or struct-).</div><div><br></div><div><br></div><div>Ho=
pe this makes my position a little clearer</div><div>Jakob</div><div><br></=
div><div><br></div><div>PS: Why did nobody else answer in this discussion t=
hread yet? Is this question not important to many people or what?</div><div=
>=C2=A0</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/a89a619e-84d6-43da-983e-61e8a4158f87%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a89a619e-84d6-43da-983e-61e8a4158f87=
%40isocpp.org</a>.<br />

------=_Part_3615_633958372.1492722283044--

------=_Part_3614_1689940736.1492722283044--

.


Author: Richard Smith <richard@metafoo.co.uk>
Date: Thu, 20 Apr 2017 15:09:06 -0700
Raw View
--001a1143d6b2f1b12e054da064a5
Content-Type: text/plain; charset=UTF-8

On 20 April 2017 at 00:57, Jakob Riedle <jakob.riedle@gmail.com> wrote:

> I quite like this idea and I had this problem myself. The reason why
> compilers reject this code is because
> 'T is not a class, struct, or union type'. I don't know whether it is a
> good idea to consider *reference to class *a *class type.*
> It would be very misleading to do this if we allow references to class
> types to be usable as if they were the referenced class:
> struct A{};
> struct B : A& {};
>

We already allow this kind of thing for cv-qualifiers:

struct A { typedef int T; };
typedef const A CA;
CA::T n; // ok!
struct B : CA {}; // ok!!

.... but only through typedefs to cv-qualified class names. This is
ill-formed:

struct C : const A {}; // nope

.... so it would not be unprecedented to allow similar things for
typedef-names denoting reference-to-class types.


> *References to objects* can be and are treated exactly like the
> referenced object itself.
> Note that this only concerns the *run-time*.
> On the other hand a *reference type* is not a class, it is ... a
> reference.
>
> IMHO it is very consequent, that e.g. T::r is not resolvable for T being
> a reference type,
> because its not a class, struct or union type.
>
> Cheers
> Jakob
>
> --
> 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/23d75c32-3724-49fa-
> 961a-cb4a2c7259b7%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/23d75c32-3724-49fa-961a-cb4a2c7259b7%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

--
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/CAOfiQqk-D0oHf4wp%3D2yB9cOEWv2-t45TBHS8Rf6TP%3D%2Be4D%3DRcg%40mail.gmail.com.

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

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 2=
0 April 2017 at 00:57, Jakob Riedle <span dir=3D"ltr">&lt;<a href=3D"mailto=
:jakob.riedle@gmail.com" target=3D"_blank">jakob.riedle@gmail.com</a>&gt;</=
span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8e=
x;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">I quite lik=
e this idea and I had this problem myself. The reason why compilers reject =
this code is because<div>&#39;<span style=3D"background-color:rgb(245,245,2=
45);color:rgb(51,51,51);font-family:Menlo,Monaco,Consolas,&quot;Courier New=
&quot;,monospace;font-size:13.3333px;white-space:pre-wrap">T is not a class=
, struct, or union type&#39;</span>. I don&#39;t know whether it is a good =
idea to consider <i>reference to class </i>a <i>class type.</i></div><div>I=
t would be very misleading to do this if we allow references to class types=
 to be usable as if they were the referenced class:</div><div class=3D"m_79=
18931451975576033prettyprint" style=3D"background-color:rgb(250,250,250);bo=
rder-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:b=
reak-word"><code class=3D"m_7918931451975576033prettyprint"><div class=3D"m=
_7918931451975576033subprettyprint"><span style=3D"color:#008" class=3D"m_7=
918931451975576033styled-by-prettify">struct</span><span style=3D"color:#00=
0" class=3D"m_7918931451975576033styled-by-prettify"> A</span><span style=
=3D"color:#660" class=3D"m_7918931451975576033styled-by-prettify">{};</span=
><span style=3D"color:#000" class=3D"m_7918931451975576033styled-by-prettif=
y"><br></span><span style=3D"color:#008" class=3D"m_7918931451975576033styl=
ed-by-prettify">struct</span><span style=3D"color:#000" class=3D"m_79189314=
51975576033styled-by-prettify"> B </span><span style=3D"color:#660" class=
=3D"m_7918931451975576033styled-by-prettify">:</span><span style=3D"color:#=
000" class=3D"m_7918931451975576033styled-by-prettify"> A</span><span style=
=3D"color:#660" class=3D"m_7918931451975576033styled-by-prettify">&amp;</sp=
an><span style=3D"color:#000" class=3D"m_7918931451975576033styled-by-prett=
ify"> </span><span style=3D"color:#660" class=3D"m_7918931451975576033style=
d-by-prettify">{};</span></div></code></div></div></blockquote><div><br></d=
iv><div>We already allow this kind of thing for cv-qualifiers:<br></div><di=
v><br></div><div>struct A { typedef int T; };</div><div>typedef const A CA;=
</div><div>CA::T n; // ok!</div><div>struct B : CA {}; // ok!!</div><div><b=
r></div><div>... but only through typedefs to cv-qualified class names. Thi=
s is ill-formed:</div><div><br></div><div>struct C : const A {}; // nope</d=
iv><div><br></div><div>... so it would not be unprecedented to allow simila=
r things for typedef-names denoting reference-to-class types.</div><div>=C2=
=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;borde=
r-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><b>References=
 to objects</b> can be and are treated exactly like the referenced object i=
tself.</div><div>Note that this only concerns the <b>run-time</b>.</div><di=
v>On the other hand a <i>reference type</i> is not a class, it is ... a ref=
erence.</div><div><br></div><div>IMHO it is very consequent, that e.g. <spa=
n style=3D"background-color:rgb(245,245,245);color:rgb(51,51,51);font-famil=
y:Menlo,Monaco,Consolas,&quot;Courier New&quot;,monospace;font-size:13.3333=
px;white-space:pre-wrap">T::r</span>=C2=A0is not resolvable for=C2=A0<span =
style=3D"background-color:rgb(245,245,245);color:rgb(51,51,51);font-family:=
Menlo,Monaco,Consolas,&quot;Courier New&quot;,monospace;font-size:13.3333px=
;white-space:pre-wrap">T</span>=C2=A0being a reference type,</div><div>beca=
use its not a class, struct or union type.</div><div><br></div><div>Cheers<=
/div><div>Jakob</div></div><span class=3D"">

<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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/23d75c32-3724-49fa-961a-cb4a2c7259b7%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/23d7=
5c32-3724-49fa-<wbr>961a-cb4a2c7259b7%40isocpp.org</a><wbr>.<br>
</blockquote></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/CAOfiQqk-D0oHf4wp%3D2yB9cOEWv2-t45TBH=
S8Rf6TP%3D%2Be4D%3DRcg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoo=
ter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOfiQqk-=
D0oHf4wp%3D2yB9cOEWv2-t45TBHS8Rf6TP%3D%2Be4D%3DRcg%40mail.gmail.com</a>.<br=
 />

--001a1143d6b2f1b12e054da064a5--

.