Topic: pointer that propagates it's modifiers to the value


Author: Alexey Mamontov <caracrist@gmail.com>
Date: Mon, 22 Aug 2016 10:54:37 -0700 (PDT)
Raw View
------=_Part_13_1398974973.1471888477900
Content-Type: multipart/alternative;
 boundary="----=_Part_14_1925794906.1471888477900"

------=_Part_14_1925794906.1471888477900
Content-Type: text/plain; charset=UTF-8

The idea is simple. I need to have some member by pointer (using the
abstract base class, for example), but I want it to behave absolutely the
same as member by value - it must inherit the constantness of this.

Lets call it member_ptr<T> and see what I mean:

T * member_ptr<T>::operator->();
const T * member_ptr<T>::operator->() const;

T & member_ptr<T>::operator*();
const T & member_ptr<T>::operator*() const;

struct B
{
 void f() = 0;
 void f() const = 0;
};
struct S
{
 member_ptr<B> m;
};

S s;
s.m->f(); // void f() is called
const S cs;
cs.m->f(); // void f() const is called

All other modifiers (volatile, rvalue) must be forwarded as well...

--
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/28cf9d88-64c9-47c4-83f9-46843d869150%40isocpp.org.

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

<div dir=3D"ltr"><div>The idea is simple.=C2=A0I need to have some member b=
y pointer (using the abstract base class, for example), but I want it to be=
have absolutely the same as member by value - it must inherit the constantn=
ess of this.</div><div><br></div><div>Lets call it member_ptr&lt;T&gt; and =
see what I mean:</div><div><div><br></div><div>T *=C2=A0member_ptr&lt;T&gt;=
::operator-&gt;();</div><div>const T * member_ptr&lt;T&gt;::operator-&gt;()=
 const;<div><br></div><div>T &amp; member_ptr&lt;T&gt;::operator*();</div><=
div>const T=C2=A0&amp; member_ptr&lt;T&gt;::operator*() const;</div><div><b=
r></div><div>struct B</div><div>{</div><div>=C2=A0void f() =3D 0;</div><div=
>=C2=A0void f() const =3D 0;</div><div>};</div><div>struct S</div><div>{</d=
iv><div>=C2=A0member_ptr&lt;B&gt; m;</div><div>};</div><div><br></div><div>=
S s;</div><div>s.m-&gt;f(); // void f() is called<div>const S cs;</div><div=
>cs.m-&gt;f(); // void f() const is called</div><div><br></div><div>All oth=
er modifiers (volatile, rvalue) must be=C2=A0forwarded as well...=C2=A0</di=
v></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/28cf9d88-64c9-47c4-83f9-46843d869150%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/28cf9d88-64c9-47c4-83f9-46843d869150=
%40isocpp.org</a>.<br />

------=_Part_14_1925794906.1471888477900--

------=_Part_13_1398974973.1471888477900--

.


Author: Shahms King <shahms.king@gmail.com>
Date: Mon, 22 Aug 2016 18:11:34 +0000
Raw View
--001a1140a1b410c1cb053aacfb18
Content-Type: text/plain; charset=UTF-8

http://en.cppreference.com/w/cpp/experimental/propagate_const

--Shahms

On Mon, Aug 22, 2016 at 10:54 AM Alexey Mamontov <caracrist@gmail.com>
wrote:

> The idea is simple. I need to have some member by pointer (using the
> abstract base class, for example), but I want it to behave absolutely the
> same as member by value - it must inherit the constantness of this.
>
> Lets call it member_ptr<T> and see what I mean:
>
> T * member_ptr<T>::operator->();
> const T * member_ptr<T>::operator->() const;
>
> T & member_ptr<T>::operator*();
> const T & member_ptr<T>::operator*() const;
>
> struct B
> {
>  void f() = 0;
>  void f() const = 0;
> };
> struct S
> {
>  member_ptr<B> m;
> };
>
> S s;
> s.m->f(); // void f() is called
> const S cs;
> cs.m->f(); // void f() const is called
>
> All other modifiers (volatile, rvalue) must be forwarded as well...
>
> --
> 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/28cf9d88-64c9-47c4-83f9-46843d869150%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/28cf9d88-64c9-47c4-83f9-46843d869150%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/CAFmGaCoxuJ9LwinSRe3fV%3DWGwNmHOFNeyqsxajSicFzzsG_ogg%40mail.gmail.com.

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

<div dir=3D"ltr"><a href=3D"http://en.cppreference.com/w/cpp/experimental/p=
ropagate_const">http://en.cppreference.com/w/cpp/experimental/propagate_con=
st</a><br><div><br></div><div>--Shahms</div></div><br><div class=3D"gmail_q=
uote"><div dir=3D"ltr">On Mon, Aug 22, 2016 at 10:54 AM Alexey Mamontov &lt=
;<a href=3D"mailto:caracrist@gmail.com">caracrist@gmail.com</a>&gt; wrote:<=
br></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>The idea is s=
imple.=C2=A0I need to have some member by pointer (using the abstract base =
class, for example), but I want it to behave absolutely the same as member =
by value - it must inherit the constantness of this.</div><div><br></div><d=
iv>Lets call it member_ptr&lt;T&gt; and see what I mean:</div><div><div><br=
></div><div>T *=C2=A0member_ptr&lt;T&gt;::operator-&gt;();</div><div>const =
T * member_ptr&lt;T&gt;::operator-&gt;() const;<div><br></div><div>T &amp; =
member_ptr&lt;T&gt;::operator*();</div><div>const T=C2=A0&amp; member_ptr&l=
t;T&gt;::operator*() const;</div><div><br></div><div>struct B</div><div>{</=
div><div>=C2=A0void f() =3D 0;</div><div>=C2=A0void f() const =3D 0;</div><=
div>};</div><div>struct S</div><div>{</div><div>=C2=A0member_ptr&lt;B&gt; m=
;</div><div>};</div><div><br></div><div>S s;</div><div>s.m-&gt;f(); // void=
 f() is called<div>const S cs;</div><div>cs.m-&gt;f(); // void f() const is=
 called</div><div><br></div><div>All other modifiers (volatile, rvalue) mus=
t be=C2=A0forwarded as well...=C2=A0</div></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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/28cf9d88-64c9-47c4-83f9-46843d869150%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/28cf9d88-64c9-=
47c4-83f9-46843d869150%40isocpp.org</a>.<br>
</blockquote></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/CAFmGaCoxuJ9LwinSRe3fV%3DWGwNmHOFNeyq=
sxajSicFzzsG_ogg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFmGaCoxuJ9Lwi=
nSRe3fV%3DWGwNmHOFNeyqsxajSicFzzsG_ogg%40mail.gmail.com</a>.<br />

--001a1140a1b410c1cb053aacfb18--

.


Author: Jonathan Coe <jonathanbcoe@gmail.com>
Date: Mon, 22 Aug 2016 22:23:05 +0200
Raw View
--Apple-Mail-DE60B00A-899E-4042-8C71-347E3049C730
Content-Type: text/plain; charset=UTF-8



> On 22 Aug 2016, at 20:11, Shahms King <shahms.king@gmail.com> wrote:
>
> http://en.cppreference.com/w/cpp/experimental/propagate_const
>

libc++ and libstd++ both have implementations in trunk.

Please let me know if they don't do what you want.

The libc++ implementation should work pretty easily in VS without significant modification.

> --Shahms
>
>> On Mon, Aug 22, 2016 at 10:54 AM Alexey Mamontov <caracrist@gmail.com> wrote:
>> The idea is simple. I need to have some member by pointer (using the abstract base class, for example), but I want it to behave absolutely the same as member by value - it must inherit the constantness of this.
>>
>> Lets call it member_ptr<T> and see what I mean:
>>
>> T * member_ptr<T>::operator->();
>> const T * member_ptr<T>::operator->() const;
>>
>> T & member_ptr<T>::operator*();
>> const T & member_ptr<T>::operator*() const;
>>
>> struct B
>> {
>>  void f() = 0;
>>  void f() const = 0;
>> };
>> struct S
>> {
>>  member_ptr<B> m;
>> };
>>
>> S s;
>> s.m->f(); // void f() is called
>> const S cs;
>> cs.m->f(); // void f() const is called
>>
>> All other modifiers (volatile, rvalue) must be forwarded as well...
>> --
>> 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/28cf9d88-64c9-47c4-83f9-46843d869150%40isocpp.org.
>
> --
> 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/CAFmGaCoxuJ9LwinSRe3fV%3DWGwNmHOFNeyqsxajSicFzzsG_ogg%40mail.gmail.com.

--
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/48232D84-4D30-4F72-A309-2FB37B1380A7%40gmail.com.

--Apple-Mail-DE60B00A-899E-4042-8C71-347E3049C730
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=
=3Dutf-8"></head><body dir=3D"auto"><div></div><div><br></div><div><br>On 2=
2 Aug 2016, at 20:11, Shahms King &lt;<a href=3D"mailto:shahms.king@gmail.c=
om">shahms.king@gmail.com</a>&gt; wrote:<br><br></div><blockquote type=3D"c=
ite"><div><div dir=3D"ltr"><a href=3D"http://en.cppreference.com/w/cpp/expe=
rimental/propagate_const">http://en.cppreference.com/w/cpp/experimental/pro=
pagate_const</a><br><div><br></div></div></div></blockquote><div><br></div>=
<div>libc++ and libstd++ both have implementations in trunk.</div><div><br>=
</div><div>Please let me know if they don't do what you want.</div><div><br=
></div><div>The libc++ implementation should work pretty easily in VS witho=
ut significant modification.</div><br><blockquote type=3D"cite"><div><div d=
ir=3D"ltr"><div>--Shahms</div></div><br><div class=3D"gmail_quote"><div dir=
=3D"ltr">On Mon, Aug 22, 2016 at 10:54 AM Alexey Mamontov &lt;<a href=3D"ma=
ilto:caracrist@gmail.com">caracrist@gmail.com</a>&gt; wrote:<br></div><bloc=
kquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #cc=
c solid;padding-left:1ex"><div dir=3D"ltr"><div>The idea is simple.&nbsp;I =
need to have some member by pointer (using the abstract base class, for exa=
mple), but I want it to behave absolutely the same as member by value - it =
must inherit the constantness of this.</div><div><br></div><div>Lets call i=
t member_ptr&lt;T&gt; and see what I mean:</div><div><div><br></div><div>T =
*&nbsp;member_ptr&lt;T&gt;::operator-&gt;();</div><div>const T * member_ptr=
&lt;T&gt;::operator-&gt;() const;<div><br></div><div>T &amp; member_ptr&lt;=
T&gt;::operator*();</div><div>const T&nbsp;&amp; member_ptr&lt;T&gt;::opera=
tor*() const;</div><div><br></div><div>struct B</div><div>{</div><div>&nbsp=
;void f() =3D 0;</div><div>&nbsp;void f() const =3D 0;</div><div>};</div><d=
iv>struct S</div><div>{</div><div>&nbsp;member_ptr&lt;B&gt; m;</div><div>};=
</div><div><br></div><div>S s;</div><div>s.m-&gt;f(); // void f() is called=
<div>const S cs;</div><div>cs.m-&gt;f(); // void f() const is called</div><=
div><br></div><div>All other modifiers (volatile, rvalue) must be&nbsp;forw=
arded as well...&nbsp;</div></div></div></div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/28cf9d88-64c9-47c4-83f9-46843d869150%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/28cf9d88-64c9-=
47c4-83f9-46843d869150%40isocpp.org</a>.<br>
</blockquote></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAFmGaCoxuJ9LwinSRe3fV%3DWGwNmHOFNeyq=
sxajSicFzzsG_ogg%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFmGaCoxuJ=
9LwinSRe3fV%3DWGwNmHOFNeyqsxajSicFzzsG_ogg%40mail.gmail.com</a>.<br>
</div></blockquote></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/48232D84-4D30-4F72-A309-2FB37B1380A7%=
40gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/48232D84-4D30-4F72-A309-2FB37B1380A7%=
40gmail.com</a>.<br />

--Apple-Mail-DE60B00A-899E-4042-8C71-347E3049C730--

.