220 5310 <3ab6aadf-3c8b-4054-87bb-9db8a786f847@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: Sat, 6 Jul 2013 00:23:02 -0700 (PDT)
Lines: 377
Approved: news@gmane.org
Message-ID: <3ab6aadf-3c8b-4054-87bb-9db8a786f847@isocpp.org>
References: <82b89c5e-ce4e-49c0-82b2-d6032631e3e3@isocpp.org>
 <CAEn_SP+DOsLN5NezjN-OvPoDfiyMEWYzXBzKhjJ88NB_-TnyOw@mail.gmail.com>
 <6ed86280-bff9-4dc5-bef3-28be8981770b@isocpp.org>
 <CAEn_SP+jA2r6OjupsbkBDQpuPxZTJP-HFtBp-XBasf+LuA8psA@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_5183_30927408.1373095382936"
X-Trace: ger.gmane.org 1373095387 13159 80.91.229.3 (6 Jul 2013 07:23:07 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 6 Jul 2013 07:23:07 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD5KHQXXWYPRBV4L36HAKGQEX6KPBOY@isocpp.org Sat Jul 06 09:23:07 2013
Return-path: <std-proposals+bncBD5KHQXXWYPRBV4L36HAKGQEX6KPBOY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qe0-f72.google.com ([209.85.128.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD5KHQXXWYPRBV4L36HAKGQEX6KPBOY@isocpp.org>)
	id 1UvMpl-0003wE-QK
	for gclcip-std-proposals@m.gmane.org; Sat, 06 Jul 2013 09:23:06 +0200
Original-Received: by mail-qe0-f72.google.com with SMTP id 1sf3622320qec.3
        for <gclcip-std-proposals@m.gmane.org>; Sat, 06 Jul 2013 00:23:05 -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=TTticQNxHIHk1a0WXVG7RmIqEHD9lit82XMmLFMClvU=;
        b=ehFauL3Fx/njx+LH4jYQqxrkblLR8P4OIIDtS0OFEPv+1GPW4foVidTHpV0XdEyAwG
         8W4+EPz9gG1UCRTUQI/0P2pzAdoBXiZ3s0shEi6BdG7rjRo92O0IYc2UUof7qb0Xq1lu
         oQbkRspw1bG4TM1Zv67fzYq2L1VRcPybM7nosapvqTy6+xrFYyNCMCvbKkaJ3BaMWqTM
         b2acC5QhusUitusnFgeF5DDfK5gUJCpwPPUrnUjHMglu6ENSYbqH7Vuy3D4VaT87U7Rs
         zObGpR0R5yu/A3xOzvaSAH/I4QxDMvvlnbdq/aGUzU9f0O0NjmDf2CM0DvbhpkovQrRn
         ODiQ==
X-Received: by 10.224.37.3 with SMTP id v3mr8631054qad.2.1373095384980;
        Sat, 06 Jul 2013 00:23:04 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.26.70 with SMTP id j6ls1271336qeg.94.gmail; Sat, 06 Jul
 2013 00:23:03 -0700 (PDT)
X-Received: by 10.49.47.10 with SMTP id z10mr292946qem.7.1373095383313;
        Sat, 06 Jul 2013 00:23:03 -0700 (PDT)
In-Reply-To: <CAEn_SP+jA2r6OjupsbkBDQpuPxZTJP-HFtBp-XBasf+LuA8psA@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:5310
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/5310>

------=_Part_5183_30927408.1373095382936
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable


Have you understood that the declarator meaning is only overloaded for the=
=20
user-defined set of types nominated by the declarator overload declaration=
=20
(for example just for one class, or one hierarchy of classes)?  The=20
suggestion is not to overload the meaning of the declarator in general.

As such the declarator, so overloaded, would not effect existing code -=20
except where it applies to those user-defined class.

This is the same argument as existing overloaded operators.  You wouldn't=
=20
argue that being able to define:

    Bar operator+(Foo a, Foo b);

affects existing code that expects the built-in meaning of 3 + 4.  Such a=
=20
case still dispatches to built-in addition.  Likewise with usages of `T*`,=
=20
for Ts other then the nominated types, still produces "pointer to T".  For=
=20
example:

   struct Foo{}

   template<class T>
   using operator*<Foo> =3D shared_ptr<T>;

   Foo* p;  // p has type shared_ptr<Foo>

   int* q; // q still has type "pointer to int" <---- HERE


On Saturday, July 6, 2013 3:03:37 AM UTC+2, R. Martinho Fernandes wrote:
>
> There is a big problem in that the existing code that wants pointers=20
> uses T*, not std::pointerto<T>. And that's a rather *large* body of=20
> code.=20
> Mit freundlichen Gr=FC=DFen,=20
>
> Martinho=20
>
>
> On Sat, Jul 6, 2013 at 1:05 AM,  <andrew...@gmail.com <javascript:>>=20
> wrote:=20
> >> What if I want an actual pointer now?=20
> >=20
> > Suppose you overload unary operator& on a class:=20
> >=20
> >     struct X=20
> >     {=20
> >         Y operator&();=20
> >     }=20
> >=20
> > What if I want the actual address of an object of type X now?  You use=
=20
> > std::addressof.=20
> >=20
> > In a similar fashion alias templates could be provided in the standard=
=20
> > library, for example std::pointerto<T>, such that even if the *=20
> declarator=20
> > was overloaded for that class, pointerto<T> would always give you the=
=20
> type=20
> > "pointer to T":=20
> >     -Andrew.=20
> >=20
> >=20
> > On Friday, July 5, 2013 3:57:23 PM UTC+2, R. Martinho Fernandes wrote:=
=20
> >>=20
> >> What if I want an actual pointer now?=20
> >> Mit freundlichen Gr=FC=DFen,=20
> >>=20
> >> Martinho=20
> >>=20
> >>=20
> >> On Fri, Jul 5, 2013 at 8:32 AM,  <andrew...@gmail.com> wrote:=20
> >> > If we view for a moment the various parts of a declarator as=20
> 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=
=20
> 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 Overloade=
d=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=
=20
> for=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,=20
> send=20
> >> > an=20
> >> > email to std-proposal...@isocpp.org.=20
> >> > To post to this group, send email to std-pr...@isocpp.org.=20
> >> > Visit this group at=20
> >> > http://groups.google.com/a/isocpp.org/group/std-proposals/.=20
> >> >=20
> >> >=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_5183_30927408.1373095382936
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br>Have you understood that the declarator meaning is only overloaded for =
the user-defined set of types nominated by the declarator overload declarat=
ion (for example just for one class, or one hierarchy of classes)?&nbsp; Th=
e suggestion is not to overload the meaning of the declarator in general.<b=
r><br>As such the declarator, so overloaded, would not effect existing code=
 - except where it applies to those user-defined class.<br><br>This is the =
same argument as existing overloaded operators.&nbsp; You wouldn't argue th=
at being able to define:<br><br>&nbsp;&nbsp;&nbsp; Bar operator+(Foo a, Foo=
 b);<br><br>affects existing code that expects the built-in meaning of 3 + =
4.&nbsp; Such a case still dispatches to built-in addition.&nbsp; Likewise =
with usages of `T*`, for Ts other then the nominated types, still produces =
"pointer to T".&nbsp; For example:<br><br>&nbsp;&nbsp; struct Foo{}<br><br>=
&nbsp;&nbsp; template&lt;class T&gt;<br>&nbsp;&nbsp; using operator*&lt;Foo=
&gt; =3D shared_ptr&lt;T&gt;;<br><br>&nbsp;&nbsp; Foo* p;&nbsp; // p has ty=
pe shared_ptr&lt;Foo&gt;<br><br>&nbsp;&nbsp; int* q; // q still has type "p=
ointer to int" &lt;---- HERE<br><br><br>On Saturday, July 6, 2013 3:03:37 A=
M UTC+2, R. Martinho Fernandes wrote:<blockquote class=3D"gmail_quote" styl=
e=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left:=
 1ex;">There is a big problem in that the existing code that wants pointers
<br>uses T*, not std::pointerto&lt;T&gt;. And that's a rather *large* body =
of
<br>code.
<br>Mit freundlichen Gr=FC=DFen,
<br>
<br>Martinho
<br>
<br>
<br>On Sat, Jul 6, 2013 at 1:05 AM, &nbsp;&lt;<a href=3D"javascript:" targe=
t=3D"_blank" gdf-obfuscated-mailto=3D"5Heb6YLZ61cJ">andrew...@gmail.com</a>=
&gt; wrote:
<br>&gt;&gt; What if I want an actual pointer now?
<br>&gt;
<br>&gt; Suppose you overload unary operator&amp; on a class:
<br>&gt;
<br>&gt; &nbsp; &nbsp; struct X
<br>&gt; &nbsp; &nbsp; {
<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; Y operator&amp;();
<br>&gt; &nbsp; &nbsp; }
<br>&gt;
<br>&gt; What if I want the actual address of an object of type X now? &nbs=
p;You use
<br>&gt; std::addressof.
<br>&gt;
<br>&gt; In a similar fashion alias templates could be provided in the stan=
dard
<br>&gt; library, for example std::pointerto&lt;T&gt;, such that even if th=
e * declarator
<br>&gt; was overloaded for that class, pointerto&lt;T&gt; would always giv=
e you the type
<br>&gt; "pointer to T":
<br>&gt; &nbsp; &nbsp; -Andrew.
<br>&gt;
<br>&gt;
<br>&gt; On Friday, July 5, 2013 3:57:23 PM UTC+2, R. Martinho Fernandes wr=
ote:
<br>&gt;&gt;
<br>&gt;&gt; What if I want an actual pointer now?
<br>&gt;&gt; Mit freundlichen Gr=FC=DFen,
<br>&gt;&gt;
<br>&gt;&gt; Martinho
<br>&gt;&gt;
<br>&gt;&gt;
<br>&gt;&gt; On Fri, Jul 5, 2013 at 8:32 AM, &nbsp;&lt;<a>andrew...@gmail.c=
om</a>&gt; wrote:
<br>&gt;&gt; &gt; If we view for a moment the various parts of a declarator=
 as operations
<br>&gt;&gt; &gt; on
<br>&gt;&gt; &gt; types:
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; &nbsp; &nbsp; T*: T -&gt; pointer-to-T
<br>&gt;&gt; &gt; &nbsp; &nbsp; T&amp;: T -&gt; lvalue-reference-to-T
<br>&gt;&gt; &gt; &nbsp; &nbsp; T&amp;&amp;: T -&gt; rvalue-reference-to-T
<br>&gt;&gt; &gt; &nbsp; &nbsp; T[]: T -&gt; array-of-T
<br>&gt;&gt; &gt; &nbsp; &nbsp; T(): T -&gt; function-returning-T
<br>&gt;&gt; &gt; &nbsp; &nbsp; and so forth
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; These operations take one or more types as input and prod=
uce a type as
<br>&gt;&gt; &gt; output.
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; This is not dissimilar to an alias template:
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; &nbsp; &nbsp;template&lt;class T&gt;
<br>&gt;&gt; &gt; &nbsp; &nbsp;using MakePointer =3D T*;
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; &nbsp; &nbsp;template&lt;class T&gt;
<br>&gt;&gt; &gt; &nbsp; &nbsp;using MakeReference =3D T&amp;;
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; In fact we could almost say that functions are to the bui=
lt-in
<br>&gt;&gt; &gt; expression
<br>&gt;&gt; &gt; operators, as alias templates are to the built-in declara=
tors.
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; So the proposed feature "Overloaded Declarators" is to en=
able a
<br>&gt;&gt; &gt; user-defined
<br>&gt;&gt; &gt; alias template to redefine the built-in meaning of a decl=
arator.
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; Overloaded Declarators are to the built-in declarators, a=
s Overloaded
<br>&gt;&gt; &gt; Operators are to the built-in expression operators:
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; &nbsp; &nbsp;struct Foo{}
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; &nbsp; &nbsp;template&lt;class T&gt;
<br>&gt;&gt; &gt; &nbsp; &nbsp;using operator*&lt;Foo&gt; =3D shared_ptr&lt=
;T&gt;;
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; &nbsp; &nbsp;Foo* p; &nbsp;// p has type shared_ptr&lt;T&=
gt;
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; The above shows a key use case, specializing the declarat=
or `T*` to
<br>&gt;&gt; &gt; designate a user-defined smart pointer class instead of p=
ointer-to-T for
<br>&gt;&gt; &gt; some set of types.
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; Just a random idea.
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; Enjoy,
<br>&gt;&gt; &gt; Andrew.
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; --
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt; ---
<br>&gt;&gt; &gt; You received this message because you are subscribed to t=
he Google
<br>&gt;&gt; &gt; Groups
<br>&gt;&gt; &gt; "ISO C++ Standard - Future Proposals" group.
<br>&gt;&gt; &gt; To unsubscribe from this group and stop receiving emails =
from it, send
<br>&gt;&gt; &gt; an
<br>&gt;&gt; &gt; email to <a>std-proposal...@isocpp.org</a>.
<br>&gt;&gt; &gt; To post to this group, send email to <a>std-pr...@isocpp.=
org</a>.
<br>&gt;&gt; &gt; Visit this group at
<br>&gt;&gt; &gt; <a href=3D"http://groups.google.com/a/isocpp.org/group/st=
d-proposals/" target=3D"_blank">http://groups.google.com/a/<wbr>isocpp.org/=
group/std-<wbr>proposals/</a>.
<br>&gt;&gt; &gt;
<br>&gt;&gt; &gt;
<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"5Heb6YLZ61cJ">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"5Heb6YLZ61cJ">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_5183_30927408.1373095382936--

.
