220 5306 <6ed86280-bff9-4dc5-bef3-28be8981770b@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: andrewtomazos@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Overloaded Declarators
Date: Fri, 5 Jul 2013 16:05:18 -0700 (PDT)
Lines: 235
Approved: news@gmane.org
Message-ID: <6ed86280-bff9-4dc5-bef3-28be8981770b@isocpp.org>
References: <82b89c5e-ce4e-49c0-82b2-d6032631e3e3@isocpp.org>
 <CAEn_SP+DOsLN5NezjN-OvPoDfiyMEWYzXBzKhjJ88NB_-TnyOw@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_5125_32488359.1373065518132"
X-Trace: ger.gmane.org 1373065519 1377 80.91.229.3 (5 Jul 2013 23:05:19 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 5 Jul 2013 23:05:19 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD5KHQXXWYPRBLVC3WHAKGQEMHMOGVQ@isocpp.org Sat Jul 06 01:05:20 2013
Return-path: <std-proposals+bncBD5KHQXXWYPRBLVC3WHAKGQEMHMOGVQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qc0-f197.google.com ([209.85.216.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD5KHQXXWYPRBLVC3WHAKGQEMHMOGVQ@isocpp.org>)
	id 1UvF44-0003V5-Gd
	for gclcip-std-proposals@m.gmane.org; Sat, 06 Jul 2013 01:05:20 +0200
Original-Received: by mail-qc0-f197.google.com with SMTP id u12sf3252781qcx.8
        for <gclcip-std-proposals@m.gmane.org>; Fri, 05 Jul 2013 16:05:19 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-beenthere:date:from:to:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-google-group-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=vwq8uxvmNck/zpYNSCbuSHtsy/Ii1bJmTM07hCGq62E=;
        b=ealmEn7NBJqvLWD4jC9ooZRMkXh2FH4KJT00T6/lcH6m60KIwqcNZmH4Y+EvYpK9uR
         IgmCnsqy5Wa5XCqHS9HBKNQ7Sr6iUHuhXYt9slYeLuqH8fz6a0bj6Mv2xburAeZA41N8
         RGmqTAs52LLoFQ2H0zsZobdtp6nwIv6ApRVLiA5SB4/qnQG9oBThK8l/itot03a4Vbrr
         Q8QzkPNCNFJXKFkJc4rhKFrNfCNEXljAQou194zHY1esKm8dw1Xj7/VPndKBOw3Ivf+J
         8wvto/kYdjwr6foKpn+JrIfTfv0Ds/Cf1ysaOPuGHkK/07W3QmL/Xe4rPH/tBR9AjiMq
         R7Gw==
X-Received: by 10.224.55.200 with SMTP id v8mr14599698qag.7.1373065519618;
        Fri, 05 Jul 2013 16:05:19 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.108.74 with SMTP id hi10ls1205596qeb.50.gmail; Fri, 05 Jul
 2013 16:05:18 -0700 (PDT)
X-Received: by 10.49.63.195 with SMTP id i3mr273700qes.29.1373065518550;
        Fri, 05 Jul 2013 16:05:18 -0700 (PDT)
In-Reply-To: <CAEn_SP+DOsLN5NezjN-OvPoDfiyMEWYzXBzKhjJ88NB_-TnyOw@mail.gmail.com>
X-Original-Sender: andrewtomazos@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:5306
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/5306>

------=_Part_5125_32488359.1373065518132
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

> What if I want an actual pointer now?

Suppose you overload unary operator& on a class:

    struct X
    {
        Y operator&();
    }

What if I want the actual address of an object of type X now?  You use=20
std::addressof.

In a similar fashion alias templates could be provided in the standard=20
library, for example std::pointerto<T>, such that even if the * declarator=
=20
was overloaded for that class, pointerto<T> would always give you the type=
=20
"pointer to T":
    -Andrew.

On Friday, July 5, 2013 3:57:23 PM UTC+2, R. Martinho Fernandes wrote:
>
> What if I want an actual pointer now?=20
> Mit freundlichen Gr=FC=DFen,=20
>
> Martinho=20
>
>
> On Fri, Jul 5, 2013 at 8:32 AM,  <andrew...@gmail.com <javascript:>>=20
> wrote:=20
> > If we view for a moment the various parts of a declarator as operations=
=20
> on=20
> > types:=20
> >=20
> >     T*: T -> pointer-to-T=20
> >     T&: T -> lvalue-reference-to-T=20
> >     T&&: T -> rvalue-reference-to-T=20
> >     T[]: T -> array-of-T=20
> >     T(): T -> function-returning-T=20
> >     and so forth=20
> >=20
> > These operations take one or more types as input and produce a type as=
=20
> > output.=20
> >=20
> > This is not dissimilar to an alias template:=20
> >=20
> >    template<class T>=20
> >    using MakePointer =3D T*;=20
> >=20
> >    template<class T>=20
> >    using MakeReference =3D T&;=20
> >=20
> > In fact we could almost say that functions are to the built-in=20
> expression=20
> > operators, as alias templates are to the built-in declarators.=20
> >=20
> > So the proposed feature "Overloaded Declarators" is to enable a=20
> user-defined=20
> > alias template to redefine the built-in meaning of a declarator.=20
> >=20
> > Overloaded Declarators are to the built-in declarators, as Overloaded=
=20
> > Operators are to the built-in expression operators:=20
> >=20
> >    struct Foo{}=20
> >=20
> >    template<class T>=20
> >    using operator*<Foo> =3D shared_ptr<T>;=20
> >=20
> >    Foo* p;  // p has type shared_ptr<T>=20
> >=20
> > The above shows a key use case, specializing the declarator `T*` to=20
> > designate a user-defined smart pointer class instead of pointer-to-T fo=
r=20
> > some set of types.=20
> >=20
> > Just a random idea.=20
> >=20
> > Enjoy,=20
> > Andrew.=20
> >=20
> > --=20
> >=20
> > ---=20
> > You received this message because you are subscribed to the Google=20
> Groups=20
> > "ISO C++ Standard - Future Proposals" group.=20
> > To unsubscribe from this group and stop receiving emails from it, send=
=20
> an=20
> > email to std-proposal...@isocpp.org <javascript:>.=20
> > To post to this group, send email to std-pr...@isocpp.org <javascript:>=
..=20
>
> > Visit this group at=20
> > http://groups.google.com/a/isocpp.org/group/std-proposals/.=20
> >=20
> >=20
>

--=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_5125_32488359.1373065518132
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

&gt; What if I want an actual pointer now?<br><br>Suppose you overload unar=
y operator&amp; on a class:<br><br>&nbsp;&nbsp;&nbsp; struct X<br>&nbsp;&nb=
sp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Y operator&amp;()=
;<br>&nbsp;&nbsp;&nbsp; }<br><br>What if I want the actual address of an ob=
ject of type X now?&nbsp; You use std::addressof.<br><br>In a similar fashi=
on alias templates could be provided in the standard library, for example s=
td::pointerto&lt;T&gt;, such that even if the * declarator was overloaded f=
or that class, pointerto&lt;T&gt; would always give you the type "pointer t=
o T":<br>&nbsp;&nbsp;&nbsp; -Andrew.<br><br>On Friday, July 5, 2013 3:57:23=
 PM UTC+2, R. Martinho Fernandes wrote:<blockquote class=3D"gmail_quote" st=
yle=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-lef=
t: 1ex;">What if I want an actual pointer now?
<br>Mit freundlichen Gr=FC=DFen,
<br>
<br>Martinho
<br>
<br>
<br>On Fri, Jul 5, 2013 at 8:32 AM, &nbsp;&lt;<a href=3D"javascript:" targe=
t=3D"_blank" gdf-obfuscated-mailto=3D"iPeMfqXkGPUJ">andrew...@gmail.com</a>=
&gt; wrote:
<br>&gt; If we view for a moment the various parts of a declarator as opera=
tions on
<br>&gt; types:
<br>&gt;
<br>&gt; &nbsp; &nbsp; T*: T -&gt; pointer-to-T
<br>&gt; &nbsp; &nbsp; T&amp;: T -&gt; lvalue-reference-to-T
<br>&gt; &nbsp; &nbsp; T&amp;&amp;: T -&gt; rvalue-reference-to-T
<br>&gt; &nbsp; &nbsp; T[]: T -&gt; array-of-T
<br>&gt; &nbsp; &nbsp; T(): T -&gt; function-returning-T
<br>&gt; &nbsp; &nbsp; and so forth
<br>&gt;
<br>&gt; These operations take one or more types as input and produce a typ=
e as
<br>&gt; output.
<br>&gt;
<br>&gt; This is not dissimilar to an alias template:
<br>&gt;
<br>&gt; &nbsp; &nbsp;template&lt;class T&gt;
<br>&gt; &nbsp; &nbsp;using MakePointer =3D T*;
<br>&gt;
<br>&gt; &nbsp; &nbsp;template&lt;class T&gt;
<br>&gt; &nbsp; &nbsp;using MakeReference =3D T&amp;;
<br>&gt;
<br>&gt; In fact we could almost say that functions are to the built-in exp=
ression
<br>&gt; operators, as alias templates are to the built-in declarators.
<br>&gt;
<br>&gt; So the proposed feature "Overloaded Declarators" is to enable a us=
er-defined
<br>&gt; alias template to redefine the built-in meaning of a declarator.
<br>&gt;
<br>&gt; Overloaded Declarators are to the built-in declarators, as Overloa=
ded
<br>&gt; Operators are to the built-in expression operators:
<br>&gt;
<br>&gt; &nbsp; &nbsp;struct Foo{}
<br>&gt;
<br>&gt; &nbsp; &nbsp;template&lt;class T&gt;
<br>&gt; &nbsp; &nbsp;using operator*&lt;Foo&gt; =3D shared_ptr&lt;T&gt;;
<br>&gt;
<br>&gt; &nbsp; &nbsp;Foo* p; &nbsp;// p has type shared_ptr&lt;T&gt;
<br>&gt;
<br>&gt; The above shows a key use case, specializing the declarator `T*` t=
o
<br>&gt; designate a user-defined smart pointer class instead of pointer-to=
-T for
<br>&gt; some set of types.
<br>&gt;
<br>&gt; Just a random idea.
<br>&gt;
<br>&gt; Enjoy,
<br>&gt; Andrew.
<br>&gt;
<br>&gt; --
<br>&gt;
<br>&gt; ---
<br>&gt; You received this message because you are subscribed to the Google=
 Groups
<br>&gt; "ISO C++ Standard - Future Proposals" group.
<br>&gt; To unsubscribe from this group and stop receiving emails from it, =
send an
<br>&gt; email to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-=
mailto=3D"iPeMfqXkGPUJ">std-proposal...@<wbr>isocpp.org</a>.
<br>&gt; To post to this group, send email to <a href=3D"javascript:" targe=
t=3D"_blank" gdf-obfuscated-mailto=3D"iPeMfqXkGPUJ">std-pr...@isocpp.org</a=
>.
<br>&gt; Visit this group at
<br>&gt; <a href=3D"http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/" target=3D"_blank">http://groups.google.com/a/<wbr>isocpp.org/group/std=
-<wbr>proposals/</a>.
<br>&gt;
<br>&gt;
<br></blockquote>

<p></p>

-- <br />
&nbsp;<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />
&nbsp;<br />
&nbsp;<br />

------=_Part_5125_32488359.1373065518132--

.
