Topic: Pointer to pointer representation


Author: tecoberg@gmail.com
Date: Mon, 29 Oct 2018 00:00:15 -0700 (PDT)
Raw View
------=_Part_1390_8161898.1540796415852
Content-Type: multipart/alternative;
 boundary="----=_Part_1391_926821619.1540796415852"

------=_Part_1391_926821619.1540796415852
Content-Type: text/plain; charset="UTF-8"

Hi,

If we have a container of unitque_ptr/shared_ptr objects, to reference to
them we can usethe follow notations:

*p->FuncMember();*   //Same as *(*p).FuncMember();*

but, some times I need to create a pointer to this pointer and I use to
write the follow notation:

*(*p2p)->FuncMember();*

I think it will be a good idea if c++ could have a notation to this
situations like:

*p2p=>FuncMember() *//or

*p2p+>FuncMember()* //or

*p2p#>FuncMember()* //or

*p2p:>FuncMember()*

What do you think?

I hope I helped in some way.


--
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/eeb29435-11b6-424e-8434-c0aeef0977f1%40isocpp.org.

------=_Part_1391_926821619.1540796415852
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi,=C2=A0</div><div><br></div><div>If we have a conta=
iner of unitque_ptr/shared_ptr objects, to reference to them we can usethe =
follow notations:</div><div><br></div><div><b>p-&gt;FuncMember();</b>=C2=A0=
=C2=A0 //Same as <b>(*p).FuncMember();</b></div><div><br></div><div>but, so=
me times I need to create a pointer to this pointer and I use to write the =
follow notation:</div><div><br></div><div><b>(*p2p)-&gt;FuncMember();</b></=
div><div><br></div><div>I think it will be a good idea if c++ could have a =
notation to this situations like:</div><div><br></div><div><b>p2p=3D&gt;Fun=
cMember() </b>//or</div><div><br></div><div><b>p2p+&gt;FuncMember()</b> //o=
r</div><div><br></div><div><b>p2p#&gt;FuncMember()</b> //or</div><div><br><=
/div><div><b>p2p:&gt;FuncMember()</b><br></div><div><br></div><div>What do =
you think?</div><div><br></div><div>I hope I helped in some way.<br></div><=
div><br></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/eeb29435-11b6-424e-8434-c0aeef0977f1%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/eeb29435-11b6-424e-8434-c0aeef0977f1=
%40isocpp.org</a>.<br />

------=_Part_1391_926821619.1540796415852--

------=_Part_1390_8161898.1540796415852--

.


Author: mutant.sheepdog@gmail.com
Date: Mon, 29 Oct 2018 14:46:08 -0700 (PDT)
Raw View
------=_Part_1957_270047720.1540849569036
Content-Type: multipart/alternative;
 boundary="----=_Part_1958_886195860.1540849569036"

------=_Part_1958_886195860.1540849569036
Content-Type: text/plain; charset="UTF-8"

I don't think pointer-pointers are common enough to warrant adding their
own operator to the language when (*ptp)->FuncMember() and
**ptp.FuncMember() already work well enough.

I can think of 2 main situations where I've run into pointer pointers.
The first is functions that return a handle via an out param (which could
be replaced with an optional return val) and in those cases you wouldn't
typically be dereferencing the pointer-pointer in the body of the function,
and the calling function would probably only have a regular pointer
(passing the address of the pointer into the function).
The second case is iterators to pointers and in those cases it would often
better to use (*ptp)-> anyway so that the iterator type could change
without the dereference having to change.

I feel that pointer-pointers should be rare, and shouldn't get special
syntax when existing syntax works.


On Monday, 29 October 2018 18:00:15 UTC+11, teco...@gmail.com wrote:
>
> Hi,
>
> If we have a container of unitque_ptr/shared_ptr objects, to reference to
> them we can usethe follow notations:
>
> *p->FuncMember();*   //Same as *(*p).FuncMember();*
>
> but, some times I need to create a pointer to this pointer and I use to
> write the follow notation:
>
> *(*p2p)->FuncMember();*
>
> I think it will be a good idea if c++ could have a notation to this
> situations like:
>
> *p2p=>FuncMember() *//or
>
> *p2p+>FuncMember()* //or
>
> *p2p#>FuncMember()* //or
>
> *p2p:>FuncMember()*
>
> What do you think?
>
> I hope I helped in some way.
>
>
>

--
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/988bb886-95a1-4484-9461-824368477145%40isocpp.org.

------=_Part_1958_886195860.1540849569036
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I don&#39;t think pointer-pointers are common enough =
to warrant adding their own operator to the language when (*ptp)-&gt;FuncMe=
mber() and **ptp.FuncMember() already work well enough.</div><div><br></div=
><div>I can think of 2 main situations where I&#39;ve run into pointer poin=
ters.<br>The first is functions that return a handle via an out param (whic=
h could be replaced with an optional return val) and in those cases you wou=
ldn&#39;t typically be dereferencing the pointer-pointer in the body of the=
 function, and the calling function would probably only have a regular poin=
ter (passing the address of the pointer into the function).</div><div>The s=
econd case is iterators to pointers and in those cases it would often bette=
r to use (*ptp)-&gt; anyway so that the iterator type could change without =
the dereference having to change.<br></div><div><br></div><div>I feel that =
pointer-pointers should be rare, and shouldn&#39;t get special syntax when =
existing syntax works.</div><div><br></div><br>On Monday, 29 October 2018 1=
8:00:15 UTC+11, teco...@gmail.com  wrote:<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"><div>Hi,=C2=A0</div><div><br></div><div>If we h=
ave a container of unitque_ptr/shared_ptr objects, to reference to them we =
can usethe follow notations:</div><div><br></div><div><b>p-&gt;FuncMember()=
;</b>=C2=A0=C2=A0 //Same as <b>(*p).FuncMember();</b></div><div><br></div><=
div>but, some times I need to create a pointer to this pointer and I use to=
 write the follow notation:</div><div><br></div><div><b>(*p2p)-&gt;FuncMemb=
er();</b></div><div><br></div><div>I think it will be a good idea if c++ co=
uld have a notation to this situations like:</div><div><br></div><div><b>p2=
p=3D&gt;FuncMember() </b>//or</div><div><br></div><div><b>p2p+&gt;FuncMembe=
r()</b> //or</div><div><br></div><div><b>p2p#&gt;FuncMember()</b> //or</div=
><div><br></div><div><b>p2p:&gt;FuncMember()</b><br></div><div><br></div><d=
iv>What do you think?</div><div><br></div><div>I hope I helped in some way.=
<br></div><div><br></div><div><br></div></div></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/988bb886-95a1-4484-9461-824368477145%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/988bb886-95a1-4484-9461-824368477145=
%40isocpp.org</a>.<br />

------=_Part_1958_886195860.1540849569036--

------=_Part_1957_270047720.1540849569036--

.


Author: Itaj Sherman <itajsherman@gmail.com>
Date: Sun, 11 Nov 2018 18:41:04 -0800 (PST)
Raw View
------=_Part_1658_1845307955.1541990464656
Content-Type: multipart/alternative;
 boundary="----=_Part_1659_1014403419.1541990464657"

------=_Part_1659_1014403419.1541990464657
Content-Type: text/plain; charset="UTF-8"

Suppose you had a template function recursive_arrow_func(p) that
recursively applies operator-> on p, as
p.operator->().operator->().operator->() until it returns a pointer to an
object type that has no operator->

Then you could use it as:
recursive_arrow_func(p)->FuncMember();

Even if p was a pointer to pointer to pointer.

you could use this function to create one of several possible syntaxes,
using a keyword, say "arrows":

arrows(p)->FuncMember();
arrows[p]->FuncMember();
arrows{p}->FuncMember();
arrows--(p)->FuncMember();
arrows--[p]->FuncMember();
arrows(p).FuncMember();
arrows[p].FuncMember();
arrows{p}.FuncMember();
arrows--(p).FuncMember();
arrows--[p].FuncMember();

It could even do stuff like this:

template< typename T >
class my_ptr
{
private:
T* m;

public:
my_ptr(T* r) : m(r) {}

public:
T* operator->() const
{
return m;
}

T& operator*() const
{
return *m;
}
};


void g_test_recursive_arrow()
{
using element_t = std::pair< double, double >;
element_t a = { 1.5, 2.5 };

my_ptr< element_t > m = &a;
assert(a.first == arrows(m)->first);

my_ptr< my_ptr< element_t > > mm = &m;
assert(a.first == arrows(mm)->first);

my_ptr< my_ptr< my_ptr< element_t > > > mmm = &mm;
assert(a.first == arrows(mmm)->first);


element_t* p = &a;
assert(a.first == arrows(p)->first);

element_t** pp = &p;
assert(a.first == arrows(pp)->first);

element_t*** ppp = &pp;
assert(a.first == arrows(ppp)->first);


my_ptr< element_t >* pm = &m;
assert(a.first == arrows(pm)->first);

my_ptr< element_t* > mp = &p;
assert(a.first == arrows(mp)->first);


my_ptr< my_ptr< element_t >* > mpm = &pm;
assert(a.first == arrows(mpm)->first);

my_ptr< element_t* >* pmp = &mp;
assert(a.first == arrows(pmp)->first);

}



Here's a possible implementation.
I needed a traits 'has_arrow<T>' but I couldn't find it in boost, so I
used boost::has_dereference.
So classes with operator-> must has operator* to be usable.


namespace recursive_dereferencing {
namespace detail {


template <typename T>
class has_arrow
{
public: static const bool value = boost::has_dereference<T>::value;
};


template< typename T >
class recursive_arrow_result_impl;

template< typename T, bool >
class recursive_arrow_result_impl2
{
public: using type = typename recursive_arrow_result_impl<
std::invoke_result_t< decltype(&(T::operator->)), T > >::type;
};

template< typename T >
class recursive_arrow_result_impl2< T, false >
{
public: using type = T & ;
};

template< typename T >
class recursive_arrow_result_impl
{
public: using type = typename recursive_arrow_result_impl2<T,
has_arrow<T>::value >::type;
};

template< typename T >
class recursive_arrow_result_impl<T*>
{
public: using type = typename recursive_arrow_result_impl< T >::type;
};

template< typename T >
class recursive_arrow_result_impl<T&>
{
public: using type = typename recursive_arrow_result_impl< T >::type;
};

template< typename T >
class recursive_arrow_result_impl<T*&>
{
public: using type = typename recursive_arrow_result_impl< T >::type;
};

template< typename T >
using recursive_arrow_result_impl_t = typename
recursive_arrow_result_impl<T>::type;


template< typename T >
recursive_arrow_result_impl_t<T>
recursive_arrow_impl(T&& r
, typename std::enable_if< has_arrow< T >::value >::type* = NULL
)
{
return recursive_arrow_impl(std::forward<T>(r).operator->());
}

template< typename T >
T& recursive_arrow_impl(T& r
, typename std::enable_if< !has_arrow< T >::value >::type* = NULL
)
{
return r;
}

template< typename T >
recursive_arrow_result_impl_t<T*>
recursive_arrow_impl(T* r)
{
return recursive_arrow_impl(*r);
}


template< typename T >
using recursive_arrow_result_t = std::remove_reference_t<
recursive_arrow_result_impl_t< T > >*;

template< typename T >
recursive_arrow_result_t<T> recursive_arrow(T&& r)
{
return std::addressof(recursive_arrow_impl(std::forward<T>(r)));
}

}

template< typename T >
detail::recursive_arrow_result_t<T> recursive_arrow(T&& r)
{
return detail::recursive_arrow(std::forward<T>(r));
}

}


template< typename T >
std::invoke_result_t<
decltype(&recursive_dereferencing::recursive_arrow<T>), T&& >
recursive_arrow_func(T&& r)
{
return recursive_dereferencing::recursive_arrow(std::forward<T>(r));
}




On Monday, 29 October 2018 09:00:15 UTC+2, teco...@gmail.com wrote:
>
> Hi,
>
> If we have a container of unitque_ptr/shared_ptr objects, to reference to
> them we can usethe follow notations:
>
> *p->FuncMember();*   //Same as *(*p).FuncMember();*
>
> but, some times I need to create a pointer to this pointer and I use to
> write the follow notation:
>
> *(*p2p)->FuncMember();*
>
> I think it will be a good idea if c++ could have a notation to this
> situations like:
>
> *p2p=>FuncMember() *//or
>
> *p2p+>FuncMember()* //or
>
> *p2p#>FuncMember()* //or
>
> *p2p:>FuncMember()*
>
> What do you think?
>
> I hope I helped in some way.
>
>
>

--
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/467a0621-ed78-4a96-b8f2-3485e059d840%40isocpp.org.

------=_Part_1659_1014403419.1541990464657
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Suppose you had a template function recursive_arrow_f=
unc(p) that recursively applies operator-&gt; on p, as p.operator-&gt;().op=
erator-&gt;().operator-&gt;() until it returns a pointer to an object type =
that has no operator-&gt;<br><br>Then you could use it as:<br>recursive_arr=
ow_func(p)-&gt;FuncMember();<br></div><div><br></div><div>Even if p was a p=
ointer to pointer to pointer.<br><br>you could use this function to create =
one of several possible syntaxes, using a keyword, say &quot;arrows&quot;:<=
br><br><div>arrows(p)-&gt;FuncMember();</div><div>arrows[p]-&gt;FuncMember(=
);</div><div>arrows{p}-&gt;FuncMember();</div><div>arrows--(p)-&gt;FuncMemb=
er();</div></div><div><div>arrows--[p]-&gt;FuncMember();</div></div><div><d=
iv><div>arrows(p).FuncMember();</div><div>arrows[p].FuncMember();</div><div=
>arrows{p}.FuncMember();</div><div>arrows--(p).FuncMember();</div></div><di=
v>arrows--[p].FuncMember();</div></div><div><br></div><div>It could even do=
 stuff like this:<br><br>template&lt; typename T &gt;<br></div><div><div>cl=
ass my_ptr</div><div>{</div><div>private:</div><div><span style=3D"white-sp=
ace:pre"> </span>T* m;</div><div><br></div><div>public:</div><div><span sty=
le=3D"white-space:pre"> </span>my_ptr(T* r) : m(r) {}</div><div><br></div><=
div>public:</div><div><span style=3D"white-space:pre"> </span>T* operator-&=
gt;() const</div><div><span style=3D"white-space:pre"> </span>{</div><div><=
span style=3D"white-space:pre">  </span>return m;</div><div><span style=3D"=
white-space:pre"> </span>}</div><div><br></div><div><span style=3D"white-sp=
ace:pre"> </span>T&amp; operator*() const</div><div><span style=3D"white-sp=
ace:pre"> </span>{</div><div><span style=3D"white-space:pre">  </span>retur=
n *m;</div><div><span style=3D"white-space:pre"> </span>}</div><div>};</div=
><div><br></div><div><br></div><div>void g_test_recursive_arrow()<br></div>=
<div>{</div><div><span style=3D"white-space:pre"> </span>using element_t =
=3D std::pair&lt; double, double &gt;;</div><div><span style=3D"white-space=
:pre"> </span></div><div><span style=3D"white-space:pre"> </span>element_t =
a =3D { 1.5, 2.5 };</div><div><br></div><div><span style=3D"white-space:pre=
"> </span>my_ptr&lt; element_t &gt; m =3D &amp;a;</div><div><span style=3D"=
white-space:pre"> </span>assert(a.first =3D=3D arrows(m)-&gt;first);</div><=
div><br></div><div><span style=3D"white-space:pre"> </span>my_ptr&lt; my_pt=
r&lt; element_t &gt; &gt; mm =3D &amp;m;</div><div><span style=3D"white-spa=
ce:pre"> </span>assert(a.first =3D=3D arrows(mm)-&gt;first);</div><div><br>=
</div><div><span style=3D"white-space:pre"> </span>my_ptr&lt; my_ptr&lt; my=
_ptr&lt; element_t &gt; &gt; &gt; mmm =3D &amp;mm;</div><div><span style=3D=
"white-space:pre"> </span>assert(a.first =3D=3D arrows(mmm)-&gt;first);</di=
v><div><br></div><div><br></div><div><span style=3D"white-space:pre"> </spa=
n>element_t* p =3D &amp;a;</div><div><span style=3D"white-space:pre"> </spa=
n>assert(a.first =3D=3D arrows(p)-&gt;first);</div><div><br></div><div><spa=
n style=3D"white-space:pre"> </span>element_t** pp =3D &amp;p;</div><div><s=
pan style=3D"white-space:pre"> </span>assert(a.first =3D=3D arrows(pp)-&gt;=
first);</div><div><br></div><div><span style=3D"white-space:pre"> </span>el=
ement_t*** ppp =3D &amp;pp;</div><div><span style=3D"white-space:pre"> </sp=
an>assert(a.first =3D=3D arrows(ppp)-&gt;first);</div><div><br></div><div><=
br></div><div><span style=3D"white-space:pre"> </span>my_ptr&lt; element_t =
&gt;* pm =3D &amp;m;</div><div><span style=3D"white-space:pre"> </span>asse=
rt(a.first =3D=3D arrows(pm)-&gt;first);</div><div><br></div><div><span sty=
le=3D"white-space:pre"> </span>my_ptr&lt; element_t* &gt; mp =3D &amp;p;</d=
iv><div><span style=3D"white-space:pre"> </span>assert(a.first =3D=3D arrow=
s(mp)-&gt;first);</div><div><br></div><div><br></div><div><span style=3D"wh=
ite-space:pre"> </span>my_ptr&lt; my_ptr&lt; element_t &gt;* &gt; mpm =3D &=
amp;pm;</div><div><span style=3D"white-space:pre"> </span>assert(a.first =
=3D=3D arrows(mpm)-&gt;first);</div><div><br></div><div><span style=3D"whit=
e-space:pre"> </span>my_ptr&lt; element_t* &gt;* pmp =3D &amp;mp;</div><div=
><span style=3D"white-space:pre"> </span>assert(a.first =3D=3D arrows(pmp)-=
&gt;first);</div><div><br></div><div>}</div></div><div><br></div><div><br><=
/div><div><br></div><div>Here&#39;s a possible implementation.<br>I needed =
a traits &#39;has_arrow&lt;T&gt;&#39; but I couldn&#39;t find it in boost, =
so I used=C2=A0boost::has_dereference.<br>So classes with operator-&gt; mus=
t has operator* to be usable.<br><br><br></div><div><div>namespace recursiv=
e_dereferencing {</div><div><span style=3D"white-space:pre"> </span>namespa=
ce detail {</div><div><br></div><div><br></div><div><span style=3D"white-sp=
ace:pre">  </span>template &lt;typename T&gt;</div><div><span style=3D"whit=
e-space:pre">  </span>class has_arrow</div><div><span style=3D"white-space:=
pre">  </span>{</div><div><span style=3D"white-space:pre">  </span>public: =
static const bool value =3D boost::has_dereference&lt;T&gt;::value;</div><d=
iv><span style=3D"white-space:pre">  </span>};</div><div><br></div><div><br=
></div><div><span style=3D"white-space:pre">  </span>template&lt; typename =
T &gt;</div><div><span style=3D"white-space:pre">  </span>class recursive_a=
rrow_result_impl;</div><div><br></div><div><span style=3D"white-space:pre">=
  </span>template&lt; typename T, bool &gt;</div><div><span style=3D"white-=
space:pre">  </span>class recursive_arrow_result_impl2</div><div><span styl=
e=3D"white-space:pre">  </span>{</div><div><span style=3D"white-space:pre">=
  </span>public: using type =3D typename recursive_arrow_result_impl&lt; st=
d::invoke_result_t&lt; decltype(&amp;(T::operator-&gt;)), T &gt; &gt;::type=
;</div><div><span style=3D"white-space:pre">  </span>};</div><div><br></div=
><div><span style=3D"white-space:pre">  </span>template&lt; typename T &gt;=
</div><div><span style=3D"white-space:pre">  </span>class recursive_arrow_r=
esult_impl2&lt; T, false &gt;</div><div><span style=3D"white-space:pre">  <=
/span>{</div><div><span style=3D"white-space:pre">  </span>public: using ty=
pe =3D T &amp; ;</div><div><span style=3D"white-space:pre">  </span>};</div=
><div><br></div><div><span style=3D"white-space:pre">  </span>template&lt; =
typename T &gt;</div><div><span style=3D"white-space:pre">  </span>class re=
cursive_arrow_result_impl</div><div><span style=3D"white-space:pre">  </spa=
n>{</div><div><span style=3D"white-space:pre">  </span>public: using type =
=3D typename recursive_arrow_result_impl2&lt;T, has_arrow&lt;T&gt;::value &=
gt;::type;</div><div><span style=3D"white-space:pre">  </span>};</div><div>=
<br></div><div><span style=3D"white-space:pre">  </span>template&lt; typena=
me T &gt;</div><div><span style=3D"white-space:pre">  </span>class recursiv=
e_arrow_result_impl&lt;T*&gt;</div><div><span style=3D"white-space:pre">  <=
/span>{</div><div><span style=3D"white-space:pre">  </span>public: using ty=
pe =3D typename recursive_arrow_result_impl&lt; T &gt;::type;</div><div><sp=
an style=3D"white-space:pre">  </span>};</div><div><br></div><div><span sty=
le=3D"white-space:pre">  </span>template&lt; typename T &gt;</div><div><spa=
n style=3D"white-space:pre">  </span>class recursive_arrow_result_impl&lt;T=
&amp;&gt;</div><div><span style=3D"white-space:pre">  </span>{</div><div><s=
pan style=3D"white-space:pre">  </span>public: using type =3D typename recu=
rsive_arrow_result_impl&lt; T &gt;::type;</div><div><span style=3D"white-sp=
ace:pre">  </span>};</div><div><br></div><div><span style=3D"white-space:pr=
e">  </span>template&lt; typename T &gt;</div><div><span style=3D"white-spa=
ce:pre">  </span>class recursive_arrow_result_impl&lt;T*&amp;&gt;</div><div=
><span style=3D"white-space:pre">  </span>{</div><div><span style=3D"white-=
space:pre">  </span>public: using type =3D typename recursive_arrow_result_=
impl&lt; T &gt;::type;</div><div><span style=3D"white-space:pre">  </span>}=
;</div><div><br></div><div><span style=3D"white-space:pre">  </span>templat=
e&lt; typename T &gt;</div><div><span style=3D"white-space:pre">  </span>us=
ing recursive_arrow_result_impl_t =3D typename recursive_arrow_result_impl&=
lt;T&gt;::type;</div><div><br></div><div><br></div><div><span style=3D"whit=
e-space:pre">  </span>template&lt; typename T &gt;</div><div><span style=3D=
"white-space:pre">  </span>recursive_arrow_result_impl_t&lt;T&gt;</div><div=
><span style=3D"white-space:pre">   </span>recursive_arrow_impl(T&amp;&amp;=
 r</div><div><span style=3D"white-space:pre">    </span>, typename std::ena=
ble_if&lt; has_arrow&lt; T &gt;::value &gt;::type* =3D NULL</div><div><span=
 style=3D"white-space:pre">   </span>)</div><div><span style=3D"white-space=
:pre">  </span>{</div><div><span style=3D"white-space:pre">   </span>return=
 recursive_arrow_impl(std::forward&lt;T&gt;(r).operator-&gt;());</div><div>=
<span style=3D"white-space:pre">  </span>}</div><div><br></div><div><span s=
tyle=3D"white-space:pre">  </span>template&lt; typename T &gt;</div><div><s=
pan style=3D"white-space:pre">  </span>T&amp; recursive_arrow_impl(T&amp; r=
</div><div><span style=3D"white-space:pre">   </span>, typename std::enable=
_if&lt; !has_arrow&lt; T &gt;::value &gt;::type* =3D NULL</div><div><span s=
tyle=3D"white-space:pre">  </span>)</div><div><span style=3D"white-space:pr=
e">  </span>{</div><div><span style=3D"white-space:pre">   </span>return r;=
</div><div><span style=3D"white-space:pre">  </span>}</div><div><br></div><=
div><span style=3D"white-space:pre">  </span>template&lt; typename T &gt;</=
div><div><span style=3D"white-space:pre">  </span>recursive_arrow_result_im=
pl_t&lt;T*&gt;</div><div><span style=3D"white-space:pre">   </span>recursiv=
e_arrow_impl(T* r)</div><div><span style=3D"white-space:pre">  </span>{</di=
v><div><span style=3D"white-space:pre">   </span>return recursive_arrow_imp=
l(*r);</div><div><span style=3D"white-space:pre">  </span>}</div><div><br><=
/div><div><br></div><div><span style=3D"white-space:pre">  </span>template&=
lt; typename T &gt;</div><div><span style=3D"white-space:pre">  </span>usin=
g recursive_arrow_result_t =3D std::remove_reference_t&lt; recursive_arrow_=
result_impl_t&lt; T &gt; &gt;*;</div><div><br></div><div><span style=3D"whi=
te-space:pre">  </span>template&lt; typename T &gt;</div><div><span style=
=3D"white-space:pre">  </span>recursive_arrow_result_t&lt;T&gt; recursive_a=
rrow(T&amp;&amp; r)</div><div><span style=3D"white-space:pre">  </span>{</d=
iv><div><span style=3D"white-space:pre">   </span>return std::addressof(rec=
ursive_arrow_impl(std::forward&lt;T&gt;(r)));</div><div><span style=3D"whit=
e-space:pre">  </span>}</div><div><br></div><div><span style=3D"white-space=
:pre"> </span>}</div><div><br></div><div><span style=3D"white-space:pre"> <=
/span>template&lt; typename T &gt;</div><div><span style=3D"white-space:pre=
"> </span>detail::recursive_arrow_result_t&lt;T&gt; recursive_arrow(T&amp;&=
amp; r)</div><div><span style=3D"white-space:pre"> </span>{</div><div><span=
 style=3D"white-space:pre">  </span>return detail::recursive_arrow(std::for=
ward&lt;T&gt;(r));</div><div><span style=3D"white-space:pre"> </span>}</div=
><div><br></div><div>}</div><div><br></div><div><br></div><div>template&lt;=
 typename T &gt;</div><div>std::invoke_result_t&lt; decltype(&amp;recursive=
_dereferencing::recursive_arrow&lt;T&gt;), T&amp;&amp; &gt;</div><div>recur=
sive_arrow_func(T&amp;&amp; r)</div><div>{</div><div><span style=3D"white-s=
pace:pre"> </span>return recursive_dereferencing::recursive_arrow(std::forw=
ard&lt;T&gt;(r));</div><div>}</div><div><br></div><br></div><div><br></div>=
<br>On Monday, 29 October 2018 09:00:15 UTC+2, teco...@gmail.com  wrote:<bl=
ockquote 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>Hi,=C2=A0</=
div><div><br></div><div>If we have a container of unitque_ptr/shared_ptr ob=
jects, to reference to them we can usethe follow notations:</div><div><br><=
/div><div><b>p-&gt;FuncMember();</b>=C2=A0=C2=A0 //Same as <b>(*p).FuncMemb=
er();</b></div><div><br></div><div>but, some times I need to create a point=
er to this pointer and I use to write the follow notation:</div><div><br></=
div><div><b>(*p2p)-&gt;FuncMember();</b></div><div><br></div><div>I think i=
t will be a good idea if c++ could have a notation to this situations like:=
</div><div><br></div><div><b>p2p=3D&gt;FuncMember() </b>//or</div><div><br>=
</div><div><b>p2p+&gt;FuncMember()</b> //or</div><div><br></div><div><b>p2p=
#&gt;FuncMember()</b> //or</div><div><br></div><div><b>p2p:&gt;FuncMember()=
</b><br></div><div><br></div><div>What do you think?</div><div><br></div><d=
iv>I hope I helped in some way.<br></div><div><br></div><div><br></div></di=
v></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/467a0621-ed78-4a96-b8f2-3485e059d840%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/467a0621-ed78-4a96-b8f2-3485e059d840=
%40isocpp.org</a>.<br />

------=_Part_1659_1014403419.1541990464657--

------=_Part_1658_1845307955.1541990464656--

.


Author: Itaj Sherman <itajsherman@gmail.com>
Date: Sun, 11 Nov 2018 18:53:12 -0800 (PST)
Raw View
------=_Part_1724_1356553565.1541991192228
Content-Type: multipart/alternative;
 boundary="----=_Part_1725_850149995.1541991192229"

------=_Part_1725_850149995.1541991192229
Content-Type: text/plain; charset="UTF-8"

....But I wholeheartedly recommend you don't do stuff like that.
Dereferencing is an important construction in the logic of your code. The
different between none, one or two dereferencing might be very meaningful
to a reader of the code - these differences should be readily explicit.
It might only make sense in extremely specialized situations, and I'd
recommend that it you ever use such function make sure it only compiles for
classes of a specialized concept.

On Monday, 12 November 2018 04:41:04 UTC+2, Itaj Sherman wrote:
>
> Suppose you had a template function recursive_arrow_func(p) that
> recursively applies operator-> on p, as
> p.operator->().operator->().operator->() until it returns a pointer to an
> object type that has no operator->
>
> Then you could use it as:
> recursive_arrow_func(p)->FuncMember();
>
> Even if p was a pointer to pointer to pointer.
>
> you could use this function to create one of several possible syntaxes,
> using a keyword, say "arrows":
>
> arrows(p)->FuncMember();
> arrows[p]->FuncMember();
> arrows{p}->FuncMember();
> arrows--(p)->FuncMember();
> arrows--[p]->FuncMember();
> arrows(p).FuncMember();
> arrows[p].FuncMember();
> arrows{p}.FuncMember();
> arrows--(p).FuncMember();
> arrows--[p].FuncMember();
>
> It could even do stuff like this:
>
> template< typename T >
> class my_ptr
> {
> private:
> T* m;
>
> public:
> my_ptr(T* r) : m(r) {}
>
> public:
> T* operator->() const
> {
> return m;
> }
>
> T& operator*() const
> {
> return *m;
> }
> };
>
>
> void g_test_recursive_arrow()
> {
> using element_t = std::pair< double, double >;
> element_t a = { 1.5, 2.5 };
>
> my_ptr< element_t > m = &a;
> assert(a.first == arrows(m)->first);
>
> my_ptr< my_ptr< element_t > > mm = &m;
> assert(a.first == arrows(mm)->first);
>
> my_ptr< my_ptr< my_ptr< element_t > > > mmm = &mm;
> assert(a.first == arrows(mmm)->first);
>
>
> element_t* p = &a;
> assert(a.first == arrows(p)->first);
>
> element_t** pp = &p;
> assert(a.first == arrows(pp)->first);
>
> element_t*** ppp = &pp;
> assert(a.first == arrows(ppp)->first);
>
>
> my_ptr< element_t >* pm = &m;
> assert(a.first == arrows(pm)->first);
>
> my_ptr< element_t* > mp = &p;
> assert(a.first == arrows(mp)->first);
>
>
> my_ptr< my_ptr< element_t >* > mpm = &pm;
> assert(a.first == arrows(mpm)->first);
>
> my_ptr< element_t* >* pmp = &mp;
> assert(a.first == arrows(pmp)->first);
>
> }
>
>
>
> Here's a possible implementation.
> I needed a traits 'has_arrow<T>' but I couldn't find it in boost, so I
> used boost::has_dereference.
> So classes with operator-> must has operator* to be usable.
>
>
> namespace recursive_dereferencing {
> namespace detail {
>
>
> template <typename T>
> class has_arrow
> {
> public: static const bool value = boost::has_dereference<T>::value;
> };
>
>
> template< typename T >
> class recursive_arrow_result_impl;
>
> template< typename T, bool >
> class recursive_arrow_result_impl2
> {
> public: using type = typename recursive_arrow_result_impl<
> std::invoke_result_t< decltype(&(T::operator->)), T > >::type;
> };
>
> template< typename T >
> class recursive_arrow_result_impl2< T, false >
> {
> public: using type = T & ;
> };
>
> template< typename T >
> class recursive_arrow_result_impl
> {
> public: using type = typename recursive_arrow_result_impl2<T,
> has_arrow<T>::value >::type;
> };
>
> template< typename T >
> class recursive_arrow_result_impl<T*>
> {
> public: using type = typename recursive_arrow_result_impl< T >::type;
> };
>
> template< typename T >
> class recursive_arrow_result_impl<T&>
> {
> public: using type = typename recursive_arrow_result_impl< T >::type;
> };
>
> template< typename T >
> class recursive_arrow_result_impl<T*&>
> {
> public: using type = typename recursive_arrow_result_impl< T >::type;
> };
>
> template< typename T >
> using recursive_arrow_result_impl_t = typename
> recursive_arrow_result_impl<T>::type;
>
>
> template< typename T >
> recursive_arrow_result_impl_t<T>
> recursive_arrow_impl(T&& r
> , typename std::enable_if< has_arrow< T >::value >::type* = NULL
> )
> {
> return recursive_arrow_impl(std::forward<T>(r).operator->());
> }
>
> template< typename T >
> T& recursive_arrow_impl(T& r
> , typename std::enable_if< !has_arrow< T >::value >::type* = NULL
> )
> {
> return r;
> }
>
> template< typename T >
> recursive_arrow_result_impl_t<T*>
> recursive_arrow_impl(T* r)
> {
> return recursive_arrow_impl(*r);
> }
>
>
> template< typename T >
> using recursive_arrow_result_t = std::remove_reference_t<
> recursive_arrow_result_impl_t< T > >*;
>
> template< typename T >
> recursive_arrow_result_t<T> recursive_arrow(T&& r)
> {
> return std::addressof(recursive_arrow_impl(std::forward<T>(r)));
> }
>
> }
>
> template< typename T >
> detail::recursive_arrow_result_t<T> recursive_arrow(T&& r)
> {
> return detail::recursive_arrow(std::forward<T>(r));
> }
>
> }
>
>
> template< typename T >
> std::invoke_result_t<
> decltype(&recursive_dereferencing::recursive_arrow<T>), T&& >
> recursive_arrow_func(T&& r)
> {
> return recursive_dereferencing::recursive_arrow(std::forward<T>(r));
> }
>
>
>
>
> On Monday, 29 October 2018 09:00:15 UTC+2, teco...@gmail.com wrote:
>>
>> Hi,
>>
>> If we have a container of unitque_ptr/shared_ptr objects, to reference to
>> them we can usethe follow notations:
>>
>> *p->FuncMember();*   //Same as *(*p).FuncMember();*
>>
>> but, some times I need to create a pointer to this pointer and I use to
>> write the follow notation:
>>
>> *(*p2p)->FuncMember();*
>>
>> I think it will be a good idea if c++ could have a notation to this
>> situations like:
>>
>> *p2p=>FuncMember() *//or
>>
>> *p2p+>FuncMember()* //or
>>
>> *p2p#>FuncMember()* //or
>>
>> *p2p:>FuncMember()*
>>
>> What do you think?
>>
>> I hope I helped in some way.
>>
>>
>>

--
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/f8cda263-6bfd-477e-b4eb-ad73f6c7e915%40isocpp.org.

------=_Part_1725_850149995.1541991192229
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">...But I wholeheartedly recommend you don&#39;t do stuff l=
ike that.<br>Dereferencing is an important construction in the logic of you=
r code. The different between none, one or two dereferencing might be very =
meaningful to a reader of the code - these differences should be readily ex=
plicit.<br>It might only make sense in extremely specialized situations, an=
d I&#39;d recommend that it you ever use such function make sure it only co=
mpiles for classes of a specialized concept.<br><br>On Monday, 12 November =
2018 04:41:04 UTC+2, Itaj Sherman  wrote:<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"><div>Suppose you had a template function recurs=
ive_arrow_func(p) that recursively applies operator-&gt; on p, as p.operato=
r-&gt;().operator-&gt;().<wbr>operator-&gt;() until it returns a pointer to=
 an object type that has no operator-&gt;<br><br>Then you could use it as:<=
br>recursive_arrow_func(p)-&gt;<wbr>FuncMember();<br></div><div><br></div><=
div>Even if p was a pointer to pointer to pointer.<br><br>you could use thi=
s function to create one of several possible syntaxes, using a keyword, say=
 &quot;arrows&quot;:<br><br><div>arrows(p)-&gt;FuncMember();</div><div>arro=
ws[p]-&gt;FuncMember();</div><div>arrows{p}-&gt;FuncMember();</div><div>arr=
ows--(p)-&gt;FuncMember();</div></div><div><div>arrows--[p]-&gt;FuncMember(=
);</div></div><div><div><div>arrows(p).FuncMember();</div><div>arrows[p].Fu=
ncMember();</div><div>arrows{p}.FuncMember();</div><div>arrows--(p).FuncMem=
ber();</div></div><div>arrows--[p].FuncMember();</div></div><div><br></div>=
<div>It could even do stuff like this:<br><br>template&lt; typename T &gt;<=
br></div><div><div>class my_ptr</div><div>{</div><div>private:</div><div><s=
pan style=3D"white-space:pre"> </span>T* m;</div><div><br></div><div>public=
:</div><div><span style=3D"white-space:pre"> </span>my_ptr(T* r) : m(r) {}<=
/div><div><br></div><div>public:</div><div><span style=3D"white-space:pre">=
 </span>T* operator-&gt;() const</div><div><span style=3D"white-space:pre">=
 </span>{</div><div><span style=3D"white-space:pre">  </span>return m;</div=
><div><span style=3D"white-space:pre"> </span>}</div><div><br></div><div><s=
pan style=3D"white-space:pre"> </span>T&amp; operator*() const</div><div><s=
pan style=3D"white-space:pre"> </span>{</div><div><span style=3D"white-spac=
e:pre">  </span>return *m;</div><div><span style=3D"white-space:pre"> </spa=
n>}</div><div>};</div><div><br></div><div><br></div><div>void g_test_recurs=
ive_arrow()<br></div><div>{</div><div><span style=3D"white-space:pre"> </sp=
an>using element_t =3D std::pair&lt; double, double &gt;;</div><div><span s=
tyle=3D"white-space:pre"> </span></div><div><span style=3D"white-space:pre"=
> </span>element_t a =3D { 1.5, 2.5 };</div><div><br></div><div><span style=
=3D"white-space:pre"> </span>my_ptr&lt; element_t &gt; m =3D &amp;a;</div><=
div><span style=3D"white-space:pre"> </span>assert(a.first =3D=3D arrows(m)=
-&gt;first);</div><div><br></div><div><span style=3D"white-space:pre"> </sp=
an>my_ptr&lt; my_ptr&lt; element_t &gt; &gt; mm =3D &amp;m;</div><div><span=
 style=3D"white-space:pre"> </span>assert(a.first =3D=3D arrows(mm)-&gt;fir=
st);</div><div><br></div><div><span style=3D"white-space:pre"> </span>my_pt=
r&lt; my_ptr&lt; my_ptr&lt; element_t &gt; &gt; &gt; mmm =3D &amp;mm;</div>=
<div><span style=3D"white-space:pre"> </span>assert(a.first =3D=3D arrows(m=
mm)-&gt;first);</div><div><br></div><div><br></div><div><span style=3D"whit=
e-space:pre"> </span>element_t* p =3D &amp;a;</div><div><span style=3D"whit=
e-space:pre"> </span>assert(a.first =3D=3D arrows(p)-&gt;first);</div><div>=
<br></div><div><span style=3D"white-space:pre"> </span>element_t** pp =3D &=
amp;p;</div><div><span style=3D"white-space:pre"> </span>assert(a.first =3D=
=3D arrows(pp)-&gt;first);</div><div><br></div><div><span style=3D"white-sp=
ace:pre"> </span>element_t*** ppp =3D &amp;pp;</div><div><span style=3D"whi=
te-space:pre"> </span>assert(a.first =3D=3D arrows(ppp)-&gt;first);</div><d=
iv><br></div><div><br></div><div><span style=3D"white-space:pre"> </span>my=
_ptr&lt; element_t &gt;* pm =3D &amp;m;</div><div><span style=3D"white-spac=
e:pre"> </span>assert(a.first =3D=3D arrows(pm)-&gt;first);</div><div><br><=
/div><div><span style=3D"white-space:pre"> </span>my_ptr&lt; element_t* &gt=
; mp =3D &amp;p;</div><div><span style=3D"white-space:pre"> </span>assert(a=
..first =3D=3D arrows(mp)-&gt;first);</div><div><br></div><div><br></div><di=
v><span style=3D"white-space:pre"> </span>my_ptr&lt; my_ptr&lt; element_t &=
gt;* &gt; mpm =3D &amp;pm;</div><div><span style=3D"white-space:pre"> </spa=
n>assert(a.first =3D=3D arrows(mpm)-&gt;first);</div><div><br></div><div><s=
pan style=3D"white-space:pre"> </span>my_ptr&lt; element_t* &gt;* pmp =3D &=
amp;mp;</div><div><span style=3D"white-space:pre"> </span>assert(a.first =
=3D=3D arrows(pmp)-&gt;first);</div><div><br></div><div>}</div></div><div><=
br></div><div><br></div><div><br></div><div>Here&#39;s a possible implement=
ation.<br>I needed a traits &#39;has_arrow&lt;T&gt;&#39; but I couldn&#39;t=
 find it in boost, so I used=C2=A0boost::has_dereference.<br>So classes wit=
h operator-&gt; must has operator* to be usable.<br><br><br></div><div><div=
>namespace recursive_dereferencing {</div><div><span style=3D"white-space:p=
re"> </span>namespace detail {</div><div><br></div><div><br></div><div><spa=
n style=3D"white-space:pre">  </span>template &lt;typename T&gt;</div><div>=
<span style=3D"white-space:pre">  </span>class has_arrow</div><div><span st=
yle=3D"white-space:pre">  </span>{</div><div><span style=3D"white-space:pre=
">  </span>public: static const bool value =3D boost::has_dereference&lt;T&=
gt;::<wbr>value;</div><div><span style=3D"white-space:pre">  </span>};</div=
><div><br></div><div><br></div><div><span style=3D"white-space:pre">  </spa=
n>template&lt; typename T &gt;</div><div><span style=3D"white-space:pre">  =
</span>class recursive_arrow_result_impl;</div><div><br></div><div><span st=
yle=3D"white-space:pre">  </span>template&lt; typename T, bool &gt;</div><d=
iv><span style=3D"white-space:pre">  </span>class recursive_arrow_result_im=
pl2</div><div><span style=3D"white-space:pre">  </span>{</div><div><span st=
yle=3D"white-space:pre">  </span>public: using type =3D typename recursive_=
arrow_result_impl&lt; std::invoke_result_t&lt; decltype(&amp;(T::operator-&=
gt;)), T &gt; &gt;::type;</div><div><span style=3D"white-space:pre">  </spa=
n>};</div><div><br></div><div><span style=3D"white-space:pre">  </span>temp=
late&lt; typename T &gt;</div><div><span style=3D"white-space:pre">  </span=
>class recursive_arrow_result_impl2&lt; T, false &gt;</div><div><span style=
=3D"white-space:pre">  </span>{</div><div><span style=3D"white-space:pre"> =
 </span>public: using type =3D T &amp; ;</div><div><span style=3D"white-spa=
ce:pre">  </span>};</div><div><br></div><div><span style=3D"white-space:pre=
">  </span>template&lt; typename T &gt;</div><div><span style=3D"white-spac=
e:pre">  </span>class recursive_arrow_result_impl</div><div><span style=3D"=
white-space:pre">  </span>{</div><div><span style=3D"white-space:pre">  </s=
pan>public: using type =3D typename recursive_arrow_result_impl2&lt;<wbr>T,=
 has_arrow&lt;T&gt;::value &gt;::type;</div><div><span style=3D"white-space=
:pre">  </span>};</div><div><br></div><div><span style=3D"white-space:pre">=
  </span>template&lt; typename T &gt;</div><div><span style=3D"white-space:=
pre">  </span>class recursive_arrow_result_impl&lt;T*<wbr>&gt;</div><div><s=
pan style=3D"white-space:pre">  </span>{</div><div><span style=3D"white-spa=
ce:pre">  </span>public: using type =3D typename recursive_arrow_result_imp=
l&lt; T &gt;::type;</div><div><span style=3D"white-space:pre">  </span>};</=
div><div><br></div><div><span style=3D"white-space:pre">  </span>template&l=
t; typename T &gt;</div><div><span style=3D"white-space:pre">  </span>class=
 recursive_arrow_result_impl&lt;T&amp;<wbr>&gt;</div><div><span style=3D"wh=
ite-space:pre">  </span>{</div><div><span style=3D"white-space:pre">  </spa=
n>public: using type =3D typename recursive_arrow_result_impl&lt; T &gt;::t=
ype;</div><div><span style=3D"white-space:pre">  </span>};</div><div><br></=
div><div><span style=3D"white-space:pre">  </span>template&lt; typename T &=
gt;</div><div><span style=3D"white-space:pre">  </span>class recursive_arro=
w_result_impl&lt;T*<wbr>&amp;&gt;</div><div><span style=3D"white-space:pre"=
>  </span>{</div><div><span style=3D"white-space:pre">  </span>public: usin=
g type =3D typename recursive_arrow_result_impl&lt; T &gt;::type;</div><div=
><span style=3D"white-space:pre">  </span>};</div><div><br></div><div><span=
 style=3D"white-space:pre">  </span>template&lt; typename T &gt;</div><div>=
<span style=3D"white-space:pre">  </span>using recursive_arrow_result_impl_=
t =3D typename recursive_arrow_result_impl&lt;T&gt;<wbr>::type;</div><div><=
br></div><div><br></div><div><span style=3D"white-space:pre">  </span>templ=
ate&lt; typename T &gt;</div><div><span style=3D"white-space:pre">  </span>=
recursive_arrow_result_impl_t&lt;<wbr>T&gt;</div><div><span style=3D"white-=
space:pre">   </span>recursive_arrow_impl(T&amp;&amp; r</div><div><span sty=
le=3D"white-space:pre">    </span>, typename std::enable_if&lt; has_arrow&l=
t; T &gt;::value &gt;::type* =3D NULL</div><div><span style=3D"white-space:=
pre">   </span>)</div><div><span style=3D"white-space:pre">  </span>{</div>=
<div><span style=3D"white-space:pre">   </span>return recursive_arrow_impl(=
std::<wbr>forward&lt;T&gt;(r).operator-&gt;());</div><div><span style=3D"wh=
ite-space:pre">  </span>}</div><div><br></div><div><span style=3D"white-spa=
ce:pre">  </span>template&lt; typename T &gt;</div><div><span style=3D"whit=
e-space:pre">  </span>T&amp; recursive_arrow_impl(T&amp; r</div><div><span =
style=3D"white-space:pre">   </span>, typename std::enable_if&lt; !has_arro=
w&lt; T &gt;::value &gt;::type* =3D NULL</div><div><span style=3D"white-spa=
ce:pre">  </span>)</div><div><span style=3D"white-space:pre">  </span>{</di=
v><div><span style=3D"white-space:pre">   </span>return r;</div><div><span =
style=3D"white-space:pre">  </span>}</div><div><br></div><div><span style=
=3D"white-space:pre">  </span>template&lt; typename T &gt;</div><div><span =
style=3D"white-space:pre">  </span>recursive_arrow_result_impl_t&lt;<wbr>T*=
&gt;</div><div><span style=3D"white-space:pre">   </span>recursive_arrow_im=
pl(T* r)</div><div><span style=3D"white-space:pre">  </span>{</div><div><sp=
an style=3D"white-space:pre">   </span>return recursive_arrow_impl(*r);</di=
v><div><span style=3D"white-space:pre">  </span>}</div><div><br></div><div>=
<br></div><div><span style=3D"white-space:pre">  </span>template&lt; typena=
me T &gt;</div><div><span style=3D"white-space:pre">  </span>using recursiv=
e_arrow_result_t =3D std::remove_reference_t&lt; recursive_arrow_result_imp=
l_t&lt; T &gt; &gt;*;</div><div><br></div><div><span style=3D"white-space:p=
re">  </span>template&lt; typename T &gt;</div><div><span style=3D"white-sp=
ace:pre">  </span>recursive_arrow_result_t&lt;T&gt; recursive_arrow(T&amp;&=
amp; r)</div><div><span style=3D"white-space:pre">  </span>{</div><div><spa=
n style=3D"white-space:pre">   </span>return std::addressof(recursive_<wbr>=
arrow_impl(std::forward&lt;T&gt;(r))<wbr>);</div><div><span style=3D"white-=
space:pre">  </span>}</div><div><br></div><div><span style=3D"white-space:p=
re"> </span>}</div><div><br></div><div><span style=3D"white-space:pre"> </s=
pan>template&lt; typename T &gt;</div><div><span style=3D"white-space:pre">=
 </span>detail::recursive_arrow_<wbr>result_t&lt;T&gt; recursive_arrow(T&am=
p;&amp; r)</div><div><span style=3D"white-space:pre"> </span>{</div><div><s=
pan style=3D"white-space:pre">  </span>return detail::recursive_arrow(std::=
<wbr>forward&lt;T&gt;(r));</div><div><span style=3D"white-space:pre"> </spa=
n>}</div><div><br></div><div>}</div><div><br></div><div><br></div><div>temp=
late&lt; typename T &gt;</div><div>std::invoke_result_t&lt; decltype(&amp;r=
ecursive_<wbr>dereferencing::recursive_<wbr>arrow&lt;T&gt;), T&amp;&amp; &g=
t;</div><div>recursive_arrow_func(T&amp;&amp; r)</div><div>{</div><div><spa=
n style=3D"white-space:pre"> </span>return recursive_dereferencing::<wbr>re=
cursive_arrow(std::forward&lt;<wbr>T&gt;(r));</div><div>}</div><div><br></d=
iv><br></div><div><br></div><br>On Monday, 29 October 2018 09:00:15 UTC+2, =
<a>teco...@gmail.com</a>  wrote:<blockquote class=3D"gmail_quote" style=3D"=
margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><di=
v dir=3D"ltr"><div>Hi,=C2=A0</div><div><br></div><div>If we have a containe=
r of unitque_ptr/shared_ptr objects, to reference to them we can usethe fol=
low notations:</div><div><br></div><div><b>p-&gt;FuncMember();</b>=C2=A0=C2=
=A0 //Same as <b>(*p).FuncMember();</b></div><div><br></div><div>but, some =
times I need to create a pointer to this pointer and I use to write the fol=
low notation:</div><div><br></div><div><b>(*p2p)-&gt;FuncMember();</b></div=
><div><br></div><div>I think it will be a good idea if c++ could have a not=
ation to this situations like:</div><div><br></div><div><b>p2p=3D&gt;FuncMe=
mber() </b>//or</div><div><br></div><div><b>p2p+&gt;FuncMember()</b> //or</=
div><div><br></div><div><b>p2p#&gt;FuncMember()</b> //or</div><div><br></di=
v><div><b>p2p:&gt;FuncMember()</b><br></div><div><br></div><div>What do you=
 think?</div><div><br></div><div>I hope I helped in some way.<br></div><div=
><br></div><div><br></div></div></blockquote></div></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/f8cda263-6bfd-477e-b4eb-ad73f6c7e915%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/f8cda263-6bfd-477e-b4eb-ad73f6c7e915=
%40isocpp.org</a>.<br />

------=_Part_1725_850149995.1541991192229--

------=_Part_1724_1356553565.1541991192228--

.


Author: Daniel Gutson <danielgutson@gmail.com>
Date: Mon, 12 Nov 2018 00:37:13 -0300
Raw View
--0000000000007e3361057a6f6b22
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I can think of:

template<class T, unsigned int N>
indirections_type<T, N>::type

That would represent N indirections to an object of type T (this can be
easily done with TMP).

Then a function can be provided to dereference one of those types:

template<class T, unsigned int N>
T& dereference_indirections(indirections_type<T, N>::type ptr);

Would this solve your issue?

El lun., 29 oct. 2018 4:00, <tecoberg@gmail.com> escribi=C3=B3:

> Hi,
>
> If we have a container of unitque_ptr/shared_ptr objects, to reference to
> them we can usethe follow notations:
>
> *p->FuncMember();*   //Same as *(*p).FuncMember();*
>
> but, some times I need to create a pointer to this pointer and I use to
> write the follow notation:
>
> *(*p2p)->FuncMember();*
>
> I think it will be a good idea if c++ could have a notation to this
> situations like:
>
> *p2p=3D>FuncMember() *//or
>
> *p2p+>FuncMember()* //or
>
> *p2p#>FuncMember()* //or
>
> *p2p:>FuncMember()*
>
> What do you think?
>
> I hope I helped in some way.
>
>
> --
> 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/eeb29435-11b=
6-424e-8434-c0aeef0977f1%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/eeb29435-11=
b6-424e-8434-c0aeef0977f1%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>

--=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/CAFdMc-0MkQhLbiY64uSYXd8U4URzkukz3beO3Hgrx9Ni8y7=
rBA%40mail.gmail.com.

--0000000000007e3361057a6f6b22
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">I can think of:<div dir=3D"auto"><br></div><div dir=3D"au=
to"><span style=3D"font-family:sans-serif">template&lt;class T, unsigned in=
t N&gt;</span><br></div><div dir=3D"auto">indirections_type&lt;T, N&gt;::ty=
pe</div><div dir=3D"auto"><br></div><div dir=3D"auto">That would represent =
N indirections to an object of type T (this can be easily done with TMP).</=
div><div dir=3D"auto"><br></div><div dir=3D"auto">Then a function can be pr=
ovided to dereference one of those types:</div><div dir=3D"auto"><br></div>=
<div dir=3D"auto">template&lt;class T, unsigned int N&gt;</div><div dir=3D"=
auto">T&amp; dereference_indirections(indirections_type&lt;T, N&gt;::type p=
tr);</div><div dir=3D"auto"><br></div><div dir=3D"auto">Would this solve yo=
ur issue?</div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">El lun=
.., 29 oct. 2018 4:00,  &lt;<a href=3D"mailto:tecoberg@gmail.com">tecoberg@g=
mail.com</a>&gt; escribi=C3=B3:<br></div><blockquote class=3D"gmail_quote" =
style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><di=
v dir=3D"ltr"><div>Hi,=C2=A0</div><div><br></div><div>If we have a containe=
r of unitque_ptr/shared_ptr objects, to reference to them we can usethe fol=
low notations:</div><div><br></div><div><b>p-&gt;FuncMember();</b>=C2=A0=C2=
=A0 //Same as <b>(*p).FuncMember();</b></div><div><br></div><div>but, some =
times I need to create a pointer to this pointer and I use to write the fol=
low notation:</div><div><br></div><div><b>(*p2p)-&gt;FuncMember();</b></div=
><div><br></div><div>I think it will be a good idea if c++ could have a not=
ation to this situations like:</div><div><br></div><div><b>p2p=3D&gt;FuncMe=
mber() </b>//or</div><div><br></div><div><b>p2p+&gt;FuncMember()</b> //or</=
div><div><br></div><div><b>p2p#&gt;FuncMember()</b> //or</div><div><br></di=
v><div><b>p2p:&gt;FuncMember()</b><br></div><div><br></div><div>What do you=
 think?</div><div><br></div><div>I hope I helped in some way.<br></div><div=
><br></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" target=3D"_=
blank" rel=3D"noreferrer">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" rel=3D"noreferrer">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/eeb29435-11b6-424e-8434-c0aeef0977f1%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank" =
rel=3D"noreferrer">https://groups.google.com/a/isocpp.org/d/msgid/std-propo=
sals/eeb29435-11b6-424e-8434-c0aeef0977f1%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/CAFdMc-0MkQhLbiY64uSYXd8U4URzkukz3beO=
3Hgrx9Ni8y7rBA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFdMc-0MkQhLbiY6=
4uSYXd8U4URzkukz3beO3Hgrx9Ni8y7rBA%40mail.gmail.com</a>.<br />

--0000000000007e3361057a6f6b22--

.