Topic: pointer to member of class C of type
Author: Richard Smith <richard@metafoo.co.uk>
Date: Thu, 13 Mar 2014 14:39:15 -0700
Raw View
--047d7b3a946aee372f04f483c853
Content-Type: text/plain; charset=ISO-8859-1
On Thu, Mar 13, 2014 at 2:17 PM, Cleiton Santoia
<cleitonsantoia@gmail.com>wrote:
> We got the same problem on N3951 as Tiago Macieira pointed and remains the
> doubt why "int& X::*" not allowed ? I think i should have a const
> somewhere, since you cannot reassign the refererence. But other than that
> references are pointer in disguise.
>
No, they aren't (no matter how any particular implementation chooses to
represent them). A reference isn't required to occupy storage or have an
address (see 8.3.2/4). For instance, given:
int n;
struct X {
X() {}
int &r = n;
};
.... an implementation could choose to not allocate any storage for the 'r'
member in X, and instead rewrite all uses of it to directly reference ::n.
That said, as far as I'm aware no implementation does anything remotely
like this for class members of reference type, and in practice this
extension seems feasible (even though it weakens the conceptual model for
references).
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--047d7b3a946aee372f04f483c853
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
hu, Mar 13, 2014 at 2:17 PM, Cleiton Santoia <span dir=3D"ltr"><<a href=
=3D"mailto:cleitonsantoia@gmail.com" target=3D"_blank">cleitonsantoia@gmail=
..com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>We got the same proble=
m on N3951 as Tiago Macieira pointed and remains the doubt why "int&am=
p; X::*" not allowed ? I think i should have a const somewhere, since =
you cannot reassign the refererence. But other than that references are poi=
nter in disguise.</div>
</div></blockquote><div><br></div><div>No, they aren't (no matter how a=
ny particular implementation chooses to represent them). A reference isn=
9;t required to occupy storage or have an address (see 8.3.2/4). For instan=
ce, given:</div>
<div><br></div><div>=A0 int n;</div><div>=A0 struct X {</div><div>=A0 =A0 X=
() {}</div><div>=A0 =A0 int &r =3D n;</div><div>=A0 };</div><div><br></=
div><div>... an implementation could choose to not allocate any storage for=
the 'r' member in X, and instead rewrite all uses of it to directl=
y reference ::n.</div>
<div><br></div><div>That said, as far as I'm aware no implementation do=
es anything remotely like this for class members of reference type, and in =
practice this extension seems feasible (even though it weakens the conceptu=
al model for references).</div>
</div></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--047d7b3a946aee372f04f483c853--
.
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Fri, 14 Mar 2014 17:31:46 +0100
Raw View
--f46d043c07e01fd71d04f4939ba7
Content-Type: text/plain; charset=ISO-8859-1
On Fri, Mar 14, 2014 at 5:04 PM, Matthew Woehlke <
mw_triad@users.sourceforge.net> wrote:
> (It occurred to me that what I "really" want is e.g. 'public: using m_v =
> const m_mv'...)
>
What you really want is:
class Data
{
public:
const T value;
protected:
T value;
};
:)
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--f46d043c07e01fd71d04f4939ba7
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On F=
ri, Mar 14, 2014 at 5:04 PM, Matthew Woehlke <span dir=3D"ltr"><<a href=
=3D"mailto:mw_triad@users.sourceforge.net" target=3D"_blank">mw_triad@users=
..sourceforge.net</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div class=3D"">(It occurred to me that what=
I "really" want is e.g. 'public: using m_v =3D const m_mv=
9;...)<br>
</div></blockquote><div>=A0</div></div>What you really want is:</div><div c=
lass=3D"gmail_extra"><br></div><div class=3D"gmail_extra">=A0 =A0 class Dat=
a</div><div class=3D"gmail_extra">=A0 =A0 {</div><div class=3D"gmail_extra"=
>=A0 =A0 public:</div>
<div class=3D"gmail_extra">=A0 =A0 =A0 =A0 const T value;</div><div class=
=3D"gmail_extra"><br></div><div class=3D"gmail_extra">=A0 =A0 protected:</d=
iv><div class=3D"gmail_extra">=A0 =A0 =A0 =A0 T value;</div><div class=3D"g=
mail_extra">=A0 =A0 };</div><div class=3D"gmail_extra">
<br></div><div class=3D"gmail_extra">:)</div><div class=3D"gmail_extra"><br=
></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--f46d043c07e01fd71d04f4939ba7--
.
Author: Cleiton Santoia <cleitonsantoia@gmail.com>
Date: Fri, 14 Mar 2014 11:11:43 -0700 (PDT)
Raw View
------=_Part_566_11852602.1394820703951
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Em quinta-feira, 13 de mar=C3=A7o de 2014 18h39min15s UTC-3, Richard Smith=
=20
escreveu:
>
> No, they aren't (no matter how any particular implementation chooses to=
=20
> represent them). A reference isn't required to occupy storage or have an=
=20
> address (see 8.3.2/4). For instance, given:
>
> int n;
> struct X {
> X() {}
> int &r =3D n;
> };
>
> ... an implementation could choose to not allocate any storage for the 'r=
'=20
> member in X, and instead rewrite all uses of it to directly reference ::n=
..
>
I think that in one particular point of view yes, the are ! When you use=20
X::r in your program, somehow the reference will be resolved, if compiler=
=20
decides that X::r in this case is static, therefore does not need instance=
=20
space, so the reflection mechanism could reflect it as non-member-pointer=
=20
'int*', and if compiler decides that each instance must have their own=20
pointer (at some offset from the start of object structure), so the=20
reflection can extract them as int member pointers 'int* X::*'. Even if you=
=20
cannot get it as member-reference-type you could, at least, use it as=20
pointer.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_566_11852602.1394820703951
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>Em quinta-feira, 13 de mar=C3=A7o de 2014 18h39min=
15s UTC-3, Richard Smith escreveu:<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"><div class=3D"gmail_quote"><div>No, they aren't (no =
matter how any particular implementation chooses to represent them). A refe=
rence isn't required to occupy storage or have an address (see 8.3.2/4). Fo=
r instance, given:<br></div>
<div><br></div><div> int n;</div><div> struct X {</div><div>&nb=
sp; X() {}</div><div> int &r =3D n;</div><div> =
; };</div><div><br></div><div>... an implementation could choose to not all=
ocate any storage for the 'r' member in X, and instead rewrite all uses of =
it to directly reference ::n.</div></div></div></blockquote><div><br></div>=
<div>I think that in one particular point of view yes, the are ! When =
you use X::r in your program, somehow the reference will be resolved,&=
nbsp;if compiler decides that X::r in this case is static, therefore does n=
ot need instance space, so the reflection mechanism could reflect it as non=
-member-pointer 'int*', and if compiler decides that each instance must hav=
e their own pointer (at some offset from the start of object structure), so=
the reflection can extract them as int member pointers 'int* X::*'. Even i=
f you cannot get it as member-reference-type you could, at least, use it as=
pointer.</div><div><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_566_11852602.1394820703951--
.