220 5297 <82b89c5e-ce4e-49c0-82b2-d6032631e3e3@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: andrewtomazos@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Overloaded Declarators
Date: Thu, 4 Jul 2013 23:32:01 -0700 (PDT)
Lines: 104
Approved: news@gmane.org
Message-ID: <82b89c5e-ce4e-49c0-82b2-d6032631e3e3@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_4435_27230862.1373005921884"
X-Trace: ger.gmane.org 1373032296 22942 80.91.229.3 (5 Jul 2013 13:51:36 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 5 Jul 2013 13:51:36 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD5KHQXXWYPRBZE63OHAKGQEW37GXUQ@isocpp.org Fri Jul 05 15:51:37 2013
Return-path: <std-proposals+bncBD5KHQXXWYPRBZE63OHAKGQEW37GXUQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vb0-f72.google.com ([209.85.212.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD5KHQXXWYPRBZE63OHAKGQEW37GXUQ@isocpp.org>)
	id 1Uv6QB-0005oW-0I
	for gclcip-std-proposals@m.gmane.org; Fri, 05 Jul 2013 15:51:35 +0200
Original-Received: by mail-vb0-f72.google.com with SMTP id p12sf2811830vbe.3
        for <gclcip-std-proposals@m.gmane.org>; Fri, 05 Jul 2013 06:51:34 -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: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=TU+fkcahuhGmo7JQeXs3MEIsls+ddi8NLE4KOEqXIzQ=;
        b=btny7F+SBRff2pLOKVrwRBz1MTa8q31PYf45E7GN5Bf6/80cyjepprMKfgpnBPlvd0
         uEOTlMU+bnagGTnbOp9nHBzHLOFwNvkvh1wSI1mguoNnYoOnL0J7Rk8Bdf4dPuGER/nN
         vsHKAsm/3eNUab127in/F9OS/p548hQxH4bZH7kpwsMTRqW05C9UtV2CHo9OosVoM692
         WrEdxM55QywCCUBSSRSJPp/wTRkVS0mx/m7GaSy8j5fxthklnaSkl3ejt1eiO8yS2EBu
         v/Td5SbdtV0nXRLjSDH1/mH2UfXgyzic3LmgZkB+1R1jMgCrBGCzLPGeHl2Jxidsqv7t
         Ibeg==
X-Received: by 10.236.88.231 with SMTP id a67mr4971890yhf.39.1373032294063;
        Fri, 05 Jul 2013 06:51:34 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.132.38 with SMTP id or6ls984919qeb.7.gmail; Fri, 05 Jul
 2013 06:51:32 -0700 (PDT)
X-Received: by 10.224.41.145 with SMTP id o17mr292984qae.3.1373032292438;
        Fri, 05 Jul 2013 06:51:32 -0700 (PDT)
Original-Received: by 10.224.52.77 with SMTP id h13msqag;
        Thu, 4 Jul 2013 23:32:02 -0700 (PDT)
X-Received: by 10.49.17.166 with SMTP id p6mr202976qed.18.1373005922449;
        Thu, 04 Jul 2013 23:32:02 -0700 (PDT)
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:5297
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/5297>

------=_Part_4435_27230862.1373005921884
Content-Type: text/plain; charset=ISO-8859-1

If we view for a moment the various parts of a declarator as operations on 
types:

    T*: T -> pointer-to-T
    T&: T -> lvalue-reference-to-T
    T&&: T -> rvalue-reference-to-T
    T[]: T -> array-of-T
    T(): T -> function-returning-T
    and so forth

These operations take one or more types as input and produce a type as 
output.

This is not dissimilar to an alias template:

   template<class T>
   using MakePointer = T*;

   template<class T>
   using MakeReference = T&;

In fact we could almost say that functions are to the built-in expression 
operators, as alias templates are to the built-in declarators.

So the proposed feature "Overloaded Declarators" is to enable a 
user-defined alias template to redefine the built-in meaning of a 
declarator.

Overloaded Declarators are to the built-in declarators, as Overloaded 
Operators are to the built-in expression operators:

   struct Foo{}

   template<class T>
   using operator*<Foo> = shared_ptr<T>;

   Foo* p;  // p has type shared_ptr<T>

The above shows a key use case, specializing the declarator `T*` to 
designate a user-defined smart pointer class instead of pointer-to-T for 
some set of types.

Just a random idea.

Enjoy,
Andrew.

-- 

--- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.



------=_Part_4435_27230862.1373005921884
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

If we view for a moment the various parts of a declarator as operations on =
types:<br><br>&nbsp;&nbsp;&nbsp; T*: T -&gt; pointer-to-T<br>&nbsp;&nbsp;&n=
bsp; T&amp;: T -&gt; lvalue-reference-to-T<br>&nbsp;&nbsp;&nbsp; T&amp;&amp=
;: T -&gt; rvalue-reference-to-T<br>&nbsp;&nbsp;&nbsp; T[]: T -&gt; array-o=
f-T<br>&nbsp;&nbsp;&nbsp; T(): T -&gt; function-returning-T<br>&nbsp;&nbsp;=
&nbsp; and so forth<br><br>These operations take one or more types as input=
 and produce a type as output.<br><br>This is not dissimilar to an alias te=
mplate:<br><br>&nbsp;&nbsp; template&lt;class T&gt;<br>&nbsp;&nbsp; using M=
akePointer =3D T*;<br><br>&nbsp;&nbsp; template&lt;class T&gt;<br>&nbsp;&nb=
sp; using MakeReference =3D T&amp;;<br><br>In fact we could almost say that=
 functions are to the built-in expression operators, as alias templates are=
 to the built-in declarators.<br><br>So the proposed feature "Overloaded De=
clarators" is to enable a user-defined alias template to redefine the built=
-in meaning of a declarator.<br><br>Overloaded Declarators are to the built=
-in declarators, as Overloaded Operators are to the built-in expression ope=
rators:<br><br>&nbsp;&nbsp; struct Foo{}<br><br>&nbsp;&nbsp; template&lt;cl=
ass 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 type shared_ptr&lt;T&gt;<br><=
br>The above shows a key use case, specializing the declarator `T*` to desi=
gnate a user-defined smart pointer class instead of pointer-to-T for some s=
et of types.<br><br>Just a random idea.<br><br>Enjoy,<br>Andrew.<br><br>

<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_4435_27230862.1373005921884--

.
