220 38901 <b2fb570b-aadb-423e-9821-025cb447cf60@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: Allow forward class declarations to match a type alias.
Date: Fri, 29 Jun 2018 00:56:26 -0700 (PDT)
Lines: 170
Approved: news@gmane.org
Message-ID: <b2fb570b-aadb-423e-9821-025cb447cf60@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_10954_67878902.1530258986119"
X-Trace: blaine.gmane.org 1530258862 31570 195.159.176.226 (29 Jun 2018 07:54:22 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 29 Jun 2018 07:54:22 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCRIRSPDTQIRBK6M27MQKGQEVAIXGBI@isocpp.org Fri Jun 29 09:54:17 2018
Return-path: <std-proposals+bncBCRIRSPDTQIRBK6M27MQKGQEVAIXGBI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yb0-f197.google.com ([209.85.213.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCRIRSPDTQIRBK6M27MQKGQEVAIXGBI@isocpp.org>)
	id 1fYoES-00086P-TI
	for gclcip-std-proposals@m.gmane.org; Fri, 29 Jun 2018 09:54:17 +0200
Original-Received: by mail-yb0-f197.google.com with SMTP id s16-v6sf6038420ybp.12
        for <gclcip-std-proposals@m.gmane.org>; Fri, 29 Jun 2018 00:56:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=42J8WypY/Bzx10JVfn/HKtAI379Gwv5Un6EU2ELFgnE=;
        b=svVNxYnNzgR8ecZ6WSDiu8cucHISfSmowHyPvT2uvVmZ7cJyeicB6oJ5O4Nq6ZThSv
         XjtI722nGiDrRq5kq0HOANOJLgj5wmqYL9YFwfSUeALD9ayqNRKLNfX6gdYeK6ZjpcQ4
         Qk53xJ70lWQ/KvR4F6Y8aO91r00zeWqI/7mTOucsgW2L4e4xjlnftnYiT+hStCDlrrNY
         xLtzydgw9S1HLkHEvU2IUSJAEOXaNQbqnN0f5lReIjfW+xzaFENUe/76nXfk+8++8usy
         SSqxaw+THbW44pPd6lQlV4O+P+RsUoYw9V/y8BARsxyDDyIuJZ8pAxfXfTZBf6xebi3Y
         3aBg==
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: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=42J8WypY/Bzx10JVfn/HKtAI379Gwv5Un6EU2ELFgnE=;
        b=DEkZR6XcOi3Jwt1O0CAeIzBkIfWGH6EaKX09gc/GWa1zcb4COgPKughow3oWBYUkL1
         Hyn3SAhydOVjII30CAU6o9v7GDUGnTNiGcGJ4AKn9iJQ1+uf/dYusm0s9p2yii7dAFeb
         +A+TBg9PeMt7uEDs71ygvh4eXQ0kz10cwjC5a9EFIHm+mu49clSN6rLjeNBnryA0jww+
         6iIjiTj1vyuH0KvRcfdssDlIbtCi/IfuFo68lre965qUUCIC9D1TWV2fUT4+SoTBU5P2
         rbZvXbDnpKs6Lvqhwe92kRGY5h5LKPpQBsEQlcZwXnBe7BCfSTknR4ofbzfSF1SgNY8v
         Jg9Q==
X-Gm-Message-State: APt69E0/d2WbIwAaD8i5TsdiN0BctxYBqz8i5H5btH13Kf0g9N6o5ZTO
	IWPyBfVwYMy3jze/McqAiQEenw==
X-Google-Smtp-Source: AAOMgpcSB/VN4KMTNRxtuTLhIbG54jKqYXUGMRomPFRngVBWQZ8tZGdBPyKUTUPTKJ5zJdcLxOkpAg==
X-Received: by 2002:a0d:e583:: with SMTP id o125-v6mr3809831ywe.50.1530258988281;
        Fri, 29 Jun 2018 00:56:28 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a25:ba4d:: with SMTP id z13-v6ls2825801ybj.8.gmail; Fri, 29
 Jun 2018 00:56:26 -0700 (PDT)
X-Received: by 2002:a25:8448:: with SMTP id r8-v6mr1298620ybm.2.1530258986719;
        Fri, 29 Jun 2018 00:56:26 -0700 (PDT)
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-Spam-Checked-In-Group: 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:38901
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/38901>

------=_Part_10954_67878902.1530258986119
Content-Type: multipart/alternative; 
	boundary="----=_Part_10955_1719410585.1530258986120"

------=_Part_10955_1719410585.1530258986120
Content-Type: text/plain; charset="UTF-8"

A forward declaration of a class name is currently not allowed to be 
resolved by a type alias of a class template. I don't see the logic to 
this, why is this illegal:

// forward declaration in one header file.
class FloatImage;


// Definition in another header file.
template<typename T> class CudaImage {
};

using FloatImage = CudaImage<float>;


Godbolt: https://godbolt.org/g/mmTTeQ shows that all compilers reject this.

This has  created a fair amount of trouble for me when trying to refactor 
what was previously a FloatImage class to a generic pixel type template. I 
don't see the logic to making this
illegal as FloatImage is still the name of a class, i.e. an instance of the 
CudaImage class template.

While I can update the forward declaration to:
// forward declaration in one header file.
template<typename T> class CudaImage;
using FloatImage = CudaImage<float>;

This seems to be an unnecessary leakage of implementation detail.

so is there a technical reason preventing this from being allowed or is it 
just an oversight that could be corrected?

-- 
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/b2fb570b-aadb-423e-9821-025cb447cf60%40isocpp.org.

------=_Part_10955_1719410585.1530258986120
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">A forward declaration of a class name is currently not all=
owed to be resolved by a type alias of a class template. I don&#39;t see th=
e logic to this, why is this illegal:<div><br></div><div><div style=3D"colo=
r: #000000;background-color: #fffffe;font-family: Consolas, " liberation=3D=
"" mono",=3D"" courier,=3D"" monospace;font-weight:=3D"" normal;font-size:=
=3D"" 14px;line-height:=3D"" 19px;white-space:=3D"" pre;"=3D""><div liberat=
ion=3D"" mono",=3D"" courier,=3D"" monospace;font-weight:=3D"" normal;font-=
size:=3D"" 14px;line-height:=3D"" 19px;white-space:=3D"" pre;"=3D""><div cl=
ass=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-c=
olor: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap=
: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><s=
pan style=3D"color: #800;" class=3D"styled-by-prettify">// forward declarat=
ion in one header file.</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">class</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">FloatIm=
age</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br></sp=
an><span style=3D"color: #800;" class=3D"styled-by-prettify">// Definition =
in another header file.</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">template</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">t=
ypename</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">class</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
606;" class=3D"styled-by-prettify">CudaImage</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
using</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #606;" class=3D"styled-by-prettify">FloatImage</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">CudaImage</span><span style=3D"color:=
 #080;" class=3D"styled-by-prettify">&lt;float&gt;</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span></div></code></div><br><br>Godbol=
t:=C2=A0https://godbolt.org/g/mmTTeQ shows that all compilers reject this.<=
/div><div liberation=3D"" mono",=3D"" courier,=3D"" monospace;font-weight:=
=3D"" normal;font-size:=3D"" 14px;line-height:=3D"" 19px;white-space:=3D"" =
pre;"=3D""><br></div><div liberation=3D"" mono",=3D"" courier,=3D"" monospa=
ce;font-weight:=3D"" normal;font-size:=3D"" 14px;line-height:=3D"" 19px;whi=
te-space:=3D"" pre;"=3D"">This has=C2=A0 created a fair amount of trouble f=
or me when trying to refactor what was previously a FloatImage class to a g=
eneric pixel type template. I don&#39;t see the logic to making this</div><=
div liberation=3D"" mono",=3D"" courier,=3D"" monospace;font-weight:=3D"" n=
ormal;font-size:=3D"" 14px;line-height:=3D"" 19px;white-space:=3D"" pre;"=
=3D"">illegal as FloatImage is still the name of a class, i.e. an instance =
of the CudaImage class template.</div><div liberation=3D"" mono",=3D"" cour=
ier,=3D"" monospace;font-weight:=3D"" normal;font-size:=3D"" 14px;line-heig=
ht:=3D"" 19px;white-space:=3D"" pre;"=3D""><br></div><div liberation=3D"" m=
ono",=3D"" courier,=3D"" monospace;font-weight:=3D"" normal;font-size:=3D""=
 14px;line-height:=3D"" 19px;white-space:=3D"" pre;"=3D"">While I can updat=
e the forward declaration to:</div><div class=3D"prettyprint" style=3D"back=
ground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-=
style: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"pre=
ttyprint"><div class=3D"subprettyprint"><span style=3D"color: #800;" class=
=3D"styled-by-prettify">// forward declaration in one header file.</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">template</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">CudaImage</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">using</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #606;" class=3D"styled-by-prettify">FloatImage</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">CudaImage</span><span style=3D"color: #080;" class=
=3D"styled-by-prettify">&lt;float&gt;</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br></span></div></code></div><div liberation=3D"" mono",=
=3D"" courier,=3D"" monospace;font-weight:=3D"" normal;font-size:=3D"" 14px=
;line-height:=3D"" 19px;white-space:=3D"" pre;"=3D""><div liberation=3D"" m=
ono",=3D"" courier,=3D"" monospace;font-weight:=3D"" normal;font-size:=3D""=
 14px;line-height:=3D"" 19px;white-space:=3D"" pre;"=3D""><br>This seems to=
 be an unnecessary leakage of implementation detail.</div><div liberation=
=3D"" mono",=3D"" courier,=3D"" monospace;font-weight:=3D"" normal;font-siz=
e:=3D"" 14px;line-height:=3D"" 19px;white-space:=3D"" pre;"=3D""><br></div>=
<div liberation=3D"" mono",=3D"" courier,=3D"" monospace;font-weight:=3D"" =
normal;font-size:=3D"" 14px;line-height:=3D"" 19px;white-space:=3D"" pre;"=
=3D"">so is there a technical reason preventing this from being allowed or =
is it just an oversight that could be corrected?</div><div liberation=3D"" =
mono",=3D"" courier,=3D"" monospace;font-weight:=3D"" normal;font-size:=3D"=
" 14px;line-height:=3D"" 19px;white-space:=3D"" pre;"=3D""><br></div></div>=
</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/b2fb570b-aadb-423e-9821-025cb447cf60%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b2fb570b-aadb-423e-9821-025cb447cf60=
%40isocpp.org</a>.<br />

------=_Part_10955_1719410585.1530258986120--

------=_Part_10954_67878902.1530258986119--

.
