220 30772 <cd4db888-d877-4249-91f6-cfacda0a2afe@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Bengt Gustafsson <bengt.gustafsson@beamways.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Make Typedef Great Again
Date: Sun, 5 Feb 2017 02:03:45 -0800 (PST)
Lines: 506
Approved: news@gmane.org
Message-ID: <cd4db888-d877-4249-91f6-cfacda0a2afe@isocpp.org>
References: <cfbe556f-214a-4245-b257-f746424c63f2@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_893_1943674408.1486289025814"
X-Trace: blaine.gmane.org 1486289027 17468 195.159.176.226 (5 Feb 2017 10:03:47 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 5 Feb 2017 10:03:47 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCRIRSPDTQIRBAXR3PCAKGQETXC7KQI@isocpp.org Sun Feb 05 11:03:43 2017
Return-path: <std-proposals+bncBCRIRSPDTQIRBAXR3PCAKGQETXC7KQI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-it0-f72.google.com ([209.85.214.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCRIRSPDTQIRBAXR3PCAKGQETXC7KQI@isocpp.org>)
	id 1caJfa-0004Iy-Fz
	for gclcip-std-proposals@m.gmane.org; Sun, 05 Feb 2017 11:03:42 +0100
Original-Received: by mail-it0-f72.google.com with SMTP id s10sf56391278itb.7
        for <gclcip-std-proposals@m.gmane.org>; Sun, 05 Feb 2017 02:03:48 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=D+LN1ZeeRhFS6aB4SLhX6y3fU8zpiCpC/BW+dkdE+4Y=;
        b=pcQG9+d5oV0CXWnrKaMXMxgLYiTDUlkSgpHaL3e2bCJFZYW6un4+lOZTpItq6qDbnE
         hddHJsdon20y2654HD9WF8r9fOb4zYsQP3maanjrs12fajL78fnb43FumLd6/AZ/KroH
         fG/8wyXFZBaOtErP23gywVIoZqiy2+NysFIUuvY9zbOkBNgJxKpq0AMu4cG3EVkxQe8V
         fLHaxlj0M0fUrXYe19JHQOO1kKcy2GPS2OnNptEV+OxgvMm87VZuxvPOvs6XilvaDSDK
         R3SVm6gAHkiPp1tyMx076MJsyj5k3ybE8R8S/suGYS213RRijwJc7kKnuIEBJoymbhwD
         AKNA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=D+LN1ZeeRhFS6aB4SLhX6y3fU8zpiCpC/BW+dkdE+4Y=;
        b=W0N9fyGG99sukLLuAfQEV9ZAVXM2HpKrAtmLCFSWk5M3aqLL3qBdC0Im2wCfDoyzvJ
         wn03oM5kD4ycfmGi3QNBUOKQPcgMj6NNY8En8Et5AW0EcnhabtOJtfooDWcrJ4uiJivI
         EBqYFvROaKiUor0GUPREJVtMaGkx3eXkD237A47s7714qE4OoBpFv12J4LNMXpEAOCM7
         LqopiVgOfuLmODtsnKooeC1rwaa/HpeZkpUrLKtRQJXXJPIZDAMdjMAl4CdFo5fGlDIU
         L8madfrlvlbyV/t8oBuxUJUhyC5cZCXfh56dbgI338VM4m40T0qcerRSMLIlmObWjbFA
         KPxA==
X-Gm-Message-State: AMke39n7luotY39mGaiJhjle2G7XGkdLOFHxy6nJvLpIayobhqHWkYTmRlYGs820uxkGyQ==
X-Received: by 10.107.150.18 with SMTP id y18mr1006632iod.78.1486289027765;
        Sun, 05 Feb 2017 02:03:47 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.42.46 with SMTP id t43ls11958913ota.17.gmail; Sun, 05 Feb
 2017 02:03:46 -0800 (PST)
X-Received: by 10.157.41.149 with SMTP id n21mr300124otb.4.1486289026588;
        Sun, 05 Feb 2017 02:03:46 -0800 (PST)
In-Reply-To: <cfbe556f-214a-4245-b257-f746424c63f2@isocpp.org>
X-Original-Sender: bengt.gustafsson@beamways.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: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:30772
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30772>

------=_Part_893_1943674408.1486289025814
Content-Type: multipart/alternative; 
	boundary="----=_Part_894_1115334187.1486289025816"

------=_Part_894_1115334187.1486289025816
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

I like it, but it does take some getting used to the stacking of=20
identifiers in parameter and variable declaration cases. Also, in these=20
cases, I suspect there could be some parsing issues, especially if the name=
=20
of the type is defined in an outer scope. Maybe you'd have to
clarify why this is not a problem. Then again, I can't really produce a=20
problematic example so maybe I'm just seeing ghosts here. However, an=20
example involving an array size bracket would be interesting as it comes=20
after the identifier. This brings up a wrinkle in the last example:

typedef int* P p1 =3D nullptr, p2 =3D nullptr, *p3 =3D nullptr; // p1 & p2 =
are=20
both `int*`, and p3 is `int**`

Here you must make it clear that there is a new rule in play compared to=20
what would be the most logical interpretation compared to current language=
=20
rules: That the * would only apply to the next identifier being declared.=
=20
Instead the new rule is as you explain, which is necessary for the use case=
=20
of return type.


Den m=C3=A5ndag 26 december 2016 kl. 08:38:48 UTC+1 skrev TONGARI J:
>
> Typedef declaration is superseded by type alias declaration since C++11,=
=20
> its legend seems to come to the end. However, we can make typedef much=20
> more useful than it is, by allowing it to be used in accompany with=20
> variable declarations (including parameters and return types) and=20
> base-clause in a class declaration.
>
> The problem
>
> Everyone who loves templates are likely to face a problem - the name of=
=20
> the type being specified is too long that we don't want to spell it out=
=20
> twice!
> Although we have type alias, but unfortunately in many cases, it cannot b=
e=20
> used at the first place and we are forced to spell the irritating names a=
t=20
> least twice if we have to refer to the type more than once.
> Here are some examples:
>
> In function return type:
> template<blahblah...>
> typename MetaFunc<blahblah...>::type f()
> {
>     using T =3D typename MetaFunc<blahblah...>::type; // yuck!
>     // Use `T` from now on...
> }
>
> In base-clause:
> template<blahblah...>
> class Derived : public typename MetaFunc<blahblah...>::type
> {
>     using Base =3D typename MetaFunc<blahblah...>::type; // yuck!
>     // Use `Base` from now on...
> }
>
> In parameter list:
> template<blahblah...>
> void f(SomeTemplate<blahblah...> a, SomeTemplate<blahblah...> b/*yuck!*/)=
;
>
> In deduced type:
> auto& ref =3D getSomeRef(...);
> using T =3D std::remove_reference_t<decltype(ref)>; // yuck!
> // Use `T` from now on...
>
> Evidence
>
> These discussions on the std-proposals list are also arose from the same=
=20
> problem:
>
>    - Named base classes=20
>    <https://groups.google.com/a/isocpp.org/d/topic/std-proposals/TKyHxlc-=
-B8/discussion>
>    - decltype(return)=20
>    <https://groups.google.com/a/isocpp.org/d/topic/std-proposals/sfeZ_rR2=
BvQ/discussion>
>   =20
>
> The solution
>
> The problem comes from the inability to declare the type alias at the=20
> first place, and the solution is gonna to enable it - with the extended=
=20
> typedef.
>
> In function return type:
> template<blahblah...>
> typedef typename MetaFunc<blahblah...>::type T f() // yay!
> {
>     // Use `T` from now on...
> }
>
> In base-clause:
> template<blahblah...>
> class Derived : typedef public typename MetaFunc<blahblah...>::type Base =
//=20
> yay!
> {
>     // Use `Base` from now on...
> }
>
> Note how the occurrence of *access-specifier* in base-clause differ in=20
> semantic:
> class C : typedef T B // T: private base; B: private typedef
> class C : typedef public T B // T: public base; B: private typedef
> class C : public typedef T B // T: private base; B: public typedef
> class C : public typedef public T B // T: public base; B: public typedef
>
> In parameter list:
> template<blahblah...>
> void f(typedef SomeTemplate<blahblah...> T a, T b); // yay!
>
> In deduced type:
> typedef auto T& ref =3D getSomeRef(...); // yay!
> // Use `T` from now on...
>
> Note how the the type aliases declared differ:
> U u;
> typedef auto const& T1 t1 =3D u; // T1 -> U const&
> typedef auto T2 const& t2 =3D u; // T2 -> U
>
> Suppose we have Concept TS and its abbreviated template syntax, we can do=
=20
> this:
> void f1(typedef auto T a, T b);
> void f2(typedef ConceptName T a, T b);
>
>
> Typedef and tag declaration
>
> If the typedef contains a tag declaration, the extended usage is=20
> disabled. For example:
> typedef struct {...} R f(); // ill-formed
> void f(typedef struct {...} A a); // ill-formed
> typedef struct {...} S s; // ill-formed
>
>
> Extended typedef with mutiple indentifiers
>
> If the extended typedef has mutiple indentifiers follw the typedef-name,=
=20
> each identifier separated by , declares a variable. For example:
> typedef int* P p1 =3D nullptr, p2 =3D nullptr, *p3 =3D nullptr; // p1 & p=
2 are=20
> both `int*`, and p3 is `int**`
>
>
> That's the rough idea I have, I haven't think about the technical aspect=
=20
> of this approach.
> Feedbacks are welcome!
>

--=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/cd4db888-d877-4249-91f6-cfacda0a2afe%40isocpp.or=
g.

------=_Part_894_1115334187.1486289025816
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I like it, but it does take some getting used to the stack=
ing of identifiers in parameter and variable declaration cases. Also, in th=
ese cases, I suspect there could be some parsing issues, especially if the =
name of the type is defined in an outer scope. Maybe you&#39;d have to<div>=
clarify why this is not a problem. Then again, I can&#39;t really produce a=
 problematic example so maybe I&#39;m just seeing ghosts here. However, an =
example involving an array size bracket would be interesting as it comes af=
ter the identifier. This brings up a wrinkle in the last example:</div><div=
><br></div><div><div><div style=3D"border-width: 1px; border-style: solid; =
border-color: rgb(187, 187, 187); background-color: rgb(250, 250, 250); wor=
d-wrap: break-word;"><code><span style=3D"color: rgb(0, 0, 136);">typedef</=
span><span style=3D"color: rgb(0, 0, 0);">=C2=A0</span><span style=3D"color=
: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(102, 102, 0);">*</sp=
an><span style=3D"color: rgb(0, 0, 0);">=C2=A0P p1=C2=A0</span><span style=
=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, 0, 0);=
">=C2=A0</span><span style=3D"color: rgb(0, 0, 136);">nullptr</span><span s=
tyle=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0=
);">=C2=A0p2=C2=A0</span><span style=3D"color: rgb(102, 102, 0);">=3D</span=
><span style=3D"color: rgb(0, 0, 0);">=C2=A0</span><span style=3D"color: rg=
b(0, 0, 136);">nullptr</span><span style=3D"color: rgb(102, 102, 0);">,</sp=
an><span style=3D"color: rgb(0, 0, 0);">=C2=A0</span><span style=3D"color: =
rgb(102, 102, 0);">*</span><span style=3D"color: rgb(0, 0, 0);">p3=C2=A0</s=
pan><span style=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color=
: rgb(0, 0, 0);">=C2=A0</span><span style=3D"color: rgb(0, 0, 136);">nullpt=
r</span><span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"col=
or: rgb(0, 0, 0);">=C2=A0</span><span style=3D"color: rgb(136, 0, 0);">// p=
1 &amp; p2 are both `int*`, and p3 is `int**`</span></code></div></div><div=
><code><span style=3D"color: rgb(136, 0, 0);"><br></span></code></div><div>=
<font color=3D"#880000" face=3D"monospace">Here you must make it clear that=
 there is a new rule in play compared to what would be the most logical int=
erpretation compared to current language rules: That the * would only apply=
 to the next identifier being declared. Instead the new rule is as you expl=
ain, which is necessary for the use case of return type.</font></div><div><=
br><br>Den m=C3=A5ndag 26 december 2016 kl. 08:38:48 UTC+1 skrev TONGARI J:=
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>Typedef =
declaration is superseded by type alias declaration since C++11, its legend=
 seems to come to the end. However, we can make <font face=3D"courier new, =
monospace">typedef</font>=C2=A0much more useful than it is, by allowing it =
to be used in accompany with variable declarations (including parameters an=
d return types) and base-clause in a class declaration.<br></div><div><br><=
/div><div><font size=3D"6">The problem</font></div><div><br></div><div>Ever=
yone who loves templates are likely to face a problem - the name of the typ=
e being specified is too long that we don&#39;t want to spell it out twice!=
</div><div>Although we have type alias, but unfortunately in many cases, it=
 cannot be used at the first place and we are forced to spell the irritatin=
g names at least twice if we have to refer to the type more than once.</div=
><div>Here are some examples:</div><div><br></div><div>In function return t=
ype:</div><div style=3D"background-color:rgb(250,250,250);border-color:rgb(=
187,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><cod=
e><div><span style=3D"color:#008">template</span><span style=3D"color:#660"=
>&lt;</span><span style=3D"color:#000">blahblah</span><span style=3D"color:=
#660">...&gt;</span><span style=3D"color:#000"><br></span><span style=3D"co=
lor:#008">typename</span><span style=3D"color:#000"> </span><span style=3D"=
color:#606">MetaFunc</span><span style=3D"color:#660">&lt;</span><span styl=
e=3D"color:#000">blahblah</span><span style=3D"color:#660">...&gt;::</span>=
<span style=3D"color:#000">type f</span><span style=3D"color:#660">()</span=
><span style=3D"color:#000"><br></span><span style=3D"color:#660">{</span><=
span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#00=
8">using</span><span style=3D"color:#000"> T </span><span style=3D"color:#6=
60">=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>typename</span><span style=3D"color:#000"> </span><span style=3D"color:#60=
6">MetaFunc</span><span style=3D"color:#660">&lt;</span><span style=3D"colo=
r:#000">blahblah</span><span style=3D"color:#660">...&gt;::</span><span sty=
le=3D"color:#000">type</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"> </span><span style=3D"color:#800">// yuck!</span><span sty=
le=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#800">// Us=
e `T` from now on...</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#660">}</span></div></code></div><div><br></div><div>In base-cla=
use:</div><div style=3D"background-color:rgb(250,250,250);border-color:rgb(=
187,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><cod=
e><div><span style=3D"color:#008">template</span><span style=3D"color:#660"=
>&lt;</span><span style=3D"color:#000">blahblah</span><span style=3D"color:=
#660">...&gt;</span><span style=3D"color:#000"><br></span><span style=3D"co=
lor:#008">class</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#606">Derived</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#660">:</span><span style=3D"color:#000"> </span><span style=3D"color:#=
008">public</span><span style=3D"color:#000"> </span><span style=3D"color:#=
008">typename</span><span style=3D"color:#000"> </span><span style=3D"color=
:#606">MetaFunc</span><span style=3D"color:#660">&lt;</span><span style=3D"=
color:#000">blahblah</span><span style=3D"color:#660">...&gt;::</span><span=
 style=3D"color:#000">type<br></span><span style=3D"color:#660">{</span><sp=
an style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008"=
>using</span><span style=3D"color:#000"> </span><span style=3D"color:#606">=
Base</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#008">typ=
ename</span><span style=3D"color:#000"> </span><span style=3D"color:#606">M=
etaFunc</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#0=
00">blahblah</span><span style=3D"color:#660">...&gt;::</span><span style=
=3D"color:#000">type</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"> </span><span style=3D"color:#800">// yuck!</span><span sty=
le=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#800">// Us=
e `Base` from now on...</span><span style=3D"color:#000"><br></span><span s=
tyle=3D"color:#660">}</span></div></code></div><div><br></div><div>In param=
eter list:</div><div style=3D"background-color:rgb(250,250,250);border-colo=
r:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word=
"><code><div><span style=3D"color:#008">template</span><span style=3D"color=
:#660">&lt;</span><span style=3D"color:#000">blahblah</span><span style=3D"=
color:#660">...&gt;</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">void</span><span style=3D"color:#000"> f</span><span style=
=3D"color:#660">(</span><span style=3D"color:#606">SomeTemplate</span><span=
 style=3D"color:#660">&lt;</span><span style=3D"color:#000">blahblah</span>=
<span style=3D"color:#660">...&gt;</span><span style=3D"color:#000"> a</spa=
n><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#606">SomeTemplate</span><span style=3D"color:#660">&lt;<=
/span><span style=3D"color:#000">blahblah</span><span style=3D"color:#660">=
....&gt;</span><span style=3D"color:#000"> b</span><span style=3D"color:#800=
">/*yuck!*/</span><span style=3D"color:#660">);</span></div></code></div><d=
iv><br></div><div>In deduced type:</div><div style=3D"background-color:rgb(=
250,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:=
1px;word-wrap:break-word"><code><div><span style=3D"color:#008">auto</span>=
<span style=3D"color:#660">&amp;</span><span style=3D"color:#000"> </span><=
span style=3D"color:#008">ref</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#660">=3D</span><span style=3D"color:#000"> getSomeRef</sp=
an><span style=3D"color:#660">(...);</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#008">using</span><span style=3D"color:#000"> T =
</span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> std=
</span><span style=3D"color:#660">::</span><span style=3D"color:#000">remov=
e_reference_t</span><span style=3D"color:#660">&lt;</span><span style=3D"co=
lor:#008">declty<wbr>pe</span><span style=3D"color:#660">(</span><span styl=
e=3D"color:#008">ref</span><span style=3D"color:#660">)&gt;;</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#800">// yuck!</span><span =
style=3D"color:#000"><br></span><span style=3D"color:#800">// Use `T` from =
now on...</span></div></code></div><div><br></div><div><font size=3D"4">Evi=
dence</font></div><div><font size=3D"4"><br></font></div><div>These discuss=
ions on the std-proposals list are also arose from the same problem:</div><=
div><ul><li><a href=3D"https://groups.google.com/a/isocpp.org/d/topic/std-p=
roposals/TKyHxlc--B8/discussion" target=3D"_blank" rel=3D"nofollow" onmouse=
down=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/topic/std=
-proposals/TKyHxlc--B8/discussion&#39;;return true;" onclick=3D"this.href=
=3D&#39;https://groups.google.com/a/isocpp.org/d/topic/std-proposals/TKyHxl=
c--B8/discussion&#39;;return true;">Named base classes</a><br></li><li><a h=
ref=3D"https://groups.google.com/a/isocpp.org/d/topic/std-proposals/sfeZ_rR=
2BvQ/discussion" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.hre=
f=3D&#39;https://groups.google.com/a/isocpp.org/d/topic/std-proposals/sfeZ_=
rR2BvQ/discussion&#39;;return true;" onclick=3D"this.href=3D&#39;https://gr=
oups.google.com/a/isocpp.org/d/topic/std-proposals/sfeZ_rR2BvQ/discussion&#=
39;;return true;">decltype(return)</a><br></li></ul></div><div><br></div><d=
iv><font size=3D"6">The solution</font></div><div><br></div><div>The proble=
m comes from the inability to declare the type alias at the first place, an=
d the solution is gonna to enable it - with the extended <font face=3D"cour=
ier new, monospace">typedef</font>.</div><div><br></div><div>In function re=
turn type:</div><div style=3D"background-color:rgb(250,250,250);border-colo=
r:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word=
"><code><div><span style=3D"color:#008">template</span><span style=3D"color=
:#660">&lt;</span><span style=3D"color:#000">blahblah</span><span style=3D"=
color:#660">...&gt;</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">typedef</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#008">typename</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#606">MetaFunc</span><span style=3D"color:#660">&lt;</span><sp=
an style=3D"color:#000">blahblah</span><span style=3D"color:#660">...&gt;::=
</span><span style=3D"color:#000">type T f</span><span style=3D"color:#660"=
>()</span><span style=3D"color:#000"> </span><span style=3D"color:#800">// =
yay!</span><span style=3D"color:#000"><br></span><span style=3D"color:#660"=
>{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D=
"color:#800">// Use `T` from now on...</span><span style=3D"color:#000"><br=
></span><span style=3D"color:#660">}</span></div></code></div><div><br></di=
v><div>In base-clause:</div><div style=3D"background-color:rgb(250,250,250)=
;border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wra=
p:break-word"><code><div><span style=3D"color:#008">template</span><span st=
yle=3D"color:#660">&lt;</span><span style=3D"color:#000">blahblah</span><sp=
an style=3D"color:#660">...&gt;</span><span style=3D"color:#000"><br></span=
><span style=3D"color:#008">class</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#606">Derived</span><span style=3D"color:#000"> </span=
><span style=3D"color:#660">:</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#008">typedef</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#008">public</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#008">typename</span><span style=3D"color:#000"> </span><=
span style=3D"color:#606">MetaFunc</span><span style=3D"color:#660">&lt;</s=
pan><span style=3D"color:#000">blahblah</span><span style=3D"color:#660">..=
..&gt;::</span><span style=3D"color:#000">type </span><span style=3D"color:#=
606">Base</span><span style=3D"color:#000"> </span><span style=3D"color:#80=
0">// yay!</span><span style=3D"color:#000"><br></span><span style=3D"color=
:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span st=
yle=3D"color:#800">// Use `Base` from now on...</span><span style=3D"color:=
#000"><br></span><span style=3D"color:#660">}</span></div></code></div><div=
><br></div><div>Note how the occurrence of <i>access-specifier</i>=C2=A0in =
base-clause differ in semantic:</div><div style=3D"background-color:rgb(250=
,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px=
;word-wrap:break-word"><code><div><span style=3D"color:#008">class</span><s=
pan style=3D"color:#000"> C </span><span style=3D"color:#660">:</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#008">typedef</span><spa=
n style=3D"color:#000"> T B </span><span style=3D"color:#800">// T: private=
 base; B: private typedef</span><span style=3D"color:#000"><br></span><span=
 style=3D"color:#008">class</span><span style=3D"color:#000"> C </span><spa=
n style=3D"color:#660">:</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">typedef</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#008">public</span><span style=3D"color:#000"> T B </span><spa=
n style=3D"color:#800">// T: public base; B: private typedef</span><span st=
yle=3D"color:#000"><br></span><span style=3D"color:#008">class</span><span =
style=3D"color:#000"> C </span><span style=3D"color:#660">:</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">public</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">typedef</span><span st=
yle=3D"color:#000"> T B </span><span style=3D"color:#800">// T: private bas=
e; B: public typedef</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#008">class</span><span style=3D"color:#000"> C </span><span sty=
le=3D"color:#660">:</span><span style=3D"color:#000"> </span><span style=3D=
"color:#008">public</span><span style=3D"color:#000"> </span><span style=3D=
"color:#008">typedef</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">public</span><span style=3D"color:#000"> T B </span><span s=
tyle=3D"color:#800">// T: public base; B: public typedef</span></div></code=
></div><div><br></div><div>In parameter list:</div><div style=3D"background=
-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bo=
rder-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#008">=
template</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#=
000">blahblah</span><span style=3D"color:#660">...&gt;</span><span style=3D=
"color:#000"><br></span><span style=3D"color:#008">void</span><span style=
=3D"color:#000"> f</span><span style=3D"color:#660">(</span><span style=3D"=
color:#008">typedef</span><span style=3D"color:#000"> </span><span style=3D=
"color:#606">SomeTemplate</span><span style=3D"color:#660">&lt;</span><span=
 style=3D"color:#000">blahblah</span><span style=3D"color:#660">...&gt;</sp=
an><span style=3D"color:#000"> T a</span><span style=3D"color:#660">,</span=
><span style=3D"color:#000"> T b</span><span style=3D"color:#660">);</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#800">// yay!</span=
></div></code></div><div><br></div><div>In deduced type:</div><div style=3D=
"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-sty=
le:solid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"c=
olor:#008">typedef</span><span style=3D"color:#000"> </span><span style=3D"=
color:#008">auto</span><span style=3D"color:#000"> T</span><span style=3D"c=
olor:#660">&amp;</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#008">ref</span><span style=3D"color:#000"> </span><span style=3D"color=
:#660">=3D</span><span style=3D"color:#000"> getSomeRef</span><span style=
=3D"color:#660">(...);</span><span style=3D"color:#000"> </span><span style=
=3D"color:#800">// yay!</span><span style=3D"color:#000"><br></span><span s=
tyle=3D"color:#800">// Use `T` from now on...</span></div></code></div><div=
><br></div><div>Note how the the type aliases declared differ:</div><div st=
yle=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);bord=
er-style:solid;border-width:1px;word-wrap:break-word"><code><div><span styl=
e=3D"color:#000">U u</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#008">typedef</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#008">auto</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">const</span><span styl=
e=3D"color:#660">&amp;</span><span style=3D"color:#000"> T1 t1 </span><span=
 style=3D"color:#660">=3D</span><span style=3D"color:#000"> u</span><span s=
tyle=3D"color:#660">;</span><span style=3D"color:#000"> </span><span style=
=3D"color:#800">// T1 -&gt; U const&amp;</span><span style=3D"color:#000"><=
br></span><span style=3D"color:#008">typedef</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#008">auto</span><span style=3D"color:#000"=
> T2 </span><span style=3D"color:#008">const</span><span style=3D"color:#66=
0">&amp;</span><span style=3D"color:#000"> t2 </span><span style=3D"color:#=
660">=3D</span><span style=3D"color:#000"> u</span><span style=3D"color:#66=
0">;</span><span style=3D"color:#000"> </span><span style=3D"color:#800">//=
 T2 -&gt; U</span></div></code></div><div><br></div><div>Suppose we have Co=
ncept TS and its abbreviated template syntax, we can do this:</div><div sty=
le=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);borde=
r-style:solid;border-width:1px;word-wrap:break-word"><code><div><span style=
=3D"color:#008">void</span><span style=3D"color:#000"> f1</span><span style=
=3D"color:#660">(</span><span style=3D"color:#008">typedef</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#008">auto</span><span style=
=3D"color:#000"> T a</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> T b</span><span style=3D"color:#660">);</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#008">void</span><span styl=
e=3D"color:#000"> f2</span><span style=3D"color:#660">(</span><span style=
=3D"color:#008">typedef</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#606">ConceptName</span><span style=3D"color:#000"> T a</span><s=
pan style=3D"color:#660">,</span><span style=3D"color:#000"> T b</span><spa=
n style=3D"color:#660">);</span></div></code></div><div><br></div><div><br>=
</div><div><font size=3D"4">Typedef and tag declaration</font></div><div><b=
r></div><div>If the <font face=3D"courier new, monospace">typedef</font>=C2=
=A0contains a tag declaration, the extended usage is disabled. For example:=
</div><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,=
187,187);border-style:solid;border-width:1px;word-wrap:break-word"><code><d=
iv><span style=3D"color:#008">typedef</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#008">struct</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#660">{...}</span><span style=3D"color:#000"> R f<=
/span><span style=3D"color:#660">();</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#800">// ill-formed</span><span style=3D"color:#000=
"><br></span><span style=3D"color:#008">void</span><span style=3D"color:#00=
0"> f</span><span style=3D"color:#660">(</span><span style=3D"color:#008">t=
ypedef</span><span style=3D"color:#000"> </span><span style=3D"color:#008">=
struct</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
{...}</span><span style=3D"color:#000"> A a</span><span style=3D"color:#660=
">);</span><span style=3D"color:#000"> </span><span style=3D"color:#800">//=
 ill-formed</span><span style=3D"color:#000"><br></span><span style=3D"colo=
r:#008">typedef</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#008">struct</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#660">{...}</span><span style=3D"color:#000"> S s</span><span style=3D"c=
olor:#660">;</span><span style=3D"color:#000"> </span><span style=3D"color:=
#800">// ill-formed</span></div></code></div><div><br></div><div><br></div>=
<div><font size=3D"4">Extended typedef with mutiple indentifiers</font></di=
v><div><br></div><div>If the extended typedef has mutiple indentifiers foll=
w the typedef-name, each identifier separated by <font face=3D"courier new,=
 monospace" color=3D"#000000" style=3D"background-color:rgb(204,204,204)">,=
</font>=C2=A0declares a variable. For example:</div><div><div style=3D"back=
ground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:so=
lid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color:=
#008">typedef</span><span style=3D"color:#000"> </span><span style=3D"color=
:#008">int</span><span style=3D"color:#660">*</span><span style=3D"color:#0=
00"> P p1 </span><span style=3D"color:#660">=3D</span><span style=3D"color:=
#000"> </span><span style=3D"color:#008">nullptr</span><span style=3D"color=
:#660">,</span><span style=3D"color:#000"> p2 </span><span style=3D"color:#=
660">=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#008=
">nullptr</span><span style=3D"color:#660">,</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#660">*</span><span style=3D"color:#000">p3=
 </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </=
span><span style=3D"color:#008">nullptr</span><span style=3D"color:#660">;<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#800">// p1 &=
amp; p2 are both `int*`, and p3 is `int**`</span></div></code></div></div><=
div><br></div><div><br></div><div>That&#39;s the rough idea I have, I haven=
&#39;t think about the technical aspect of this approach.</div><div>Feedbac=
ks are welcome!</div></div></blockquote></div></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/cd4db888-d877-4249-91f6-cfacda0a2afe%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/cd4db888-d877-4249-91f6-cfacda0a2afe=
%40isocpp.org</a>.<br />

------=_Part_894_1115334187.1486289025816--

------=_Part_893_1943674408.1486289025814--

.
