Topic: final template: unspecializable templates
Author: bastienpenava@gmail.com
Date: Wed, 18 Jul 2018 16:54:48 -0700 (PDT)
Raw View
------=_Part_1667_249679956.1531958088494
Content-Type: multipart/alternative;
boundary="----=_Part_1668_463491407.1531958088495"
------=_Part_1668_463491407.1531958088495
Content-Type: text/plain; charset="UTF-8"
Seeing the "thou shall not specialize std function templates" discussion it
might be interesting to have a way to express such an idea on the library
writer side.
For instance
//library header
final template<class T>
void a(T&&) {}
//user-land
template<>
void a(int&&) //error trying to specialize finalized template declaration
{}
//library header
template<class T>
void b(T&& t) {};
template<>
void b(int&&) //library defined specialization
{}
final template<class T>
void b(T&&); //finalizes the declaration
//user-land
template<>
void b(float&&) //error trying to specialize finalized template declaration
{}
It would also provide a way to prevent the specialization of templated
classes and would simplify a few cases
final template<class T>
struct Base
{
void func();
int i;
using type = ...;
};
template<class T>
void func()
{
//We can now perform lookup on Base<T>'s attributes as it wasn't
specialized and is finalized
T::type x; //no typename required
};
template<class T>
struct Child : Base<T>
{
//using Base<T>::X no longer required because we can lookup Base<T>::X
without T.
};
--
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/9723d300-fc93-44fc-8380-1c74cb5062ea%40isocpp.org.
------=_Part_1668_463491407.1531958088495
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Seeing the "thou shall not specialize std function te=
mplates" discussion it might be interesting to have a way to express s=
uch an idea on the library writer side.<div>For instance</div><div><br></di=
v><div class=3D"prettyprint" 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 class=3D"prettyprint"><div class=3D"subpretty=
print"><span style=3D"color: #800;" class=3D"styled-by-prettify">//library =
header</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">final</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">template</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">class</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">></span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> a</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&&)</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </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: #800;" class=3D"styled-by-prettify">//user-land</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">template</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><span style=3D"color: #008=
;" class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> a</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">int</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">&&)</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//erro=
r trying to specialize finalized template declaration</span><span style=3D"=
color: #000;" class=3D"styled-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: #800;" cl=
ass=3D"styled-by-prettify">//library header</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">template</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">></span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">void</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> b</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&&</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> t</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{};</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">template</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
><></span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">void</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> b</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&&)</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800=
;" class=3D"styled-by-prettify">//library defined specialization</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">{}</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">final</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">></span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">void</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> b</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&&);</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">//finalizes the declaration</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">//user-land</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">template</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><span style=3D"color: #008=
;" class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">float</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">&&)</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//er=
ror trying to specialize finalized template declaration</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">{}</span></div></code></div><div><=
br></div><div>It would also provide a way to prevent the specialization of =
templated classes and would simplify a few cases</div><div class=3D"prettyp=
rint" 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 class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">final</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">template</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">class</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">></span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">struc=
t</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #606;" class=3D"styled-by-prettify">Base</span><span s=
tyle=3D"color: #000;" class=3D"styled-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>=C2=A0 =C2=A0 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> func</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">();</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color:=
#008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> i</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">using</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> type </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </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: #660;" class=3D"styled-by-prettify">};</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">template</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">class</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">></span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> func</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0</span><span style=3D"color: #800;" class=3D"styled-by-prettify">//We ca=
n now perform lookup on Base<T>'s attributes as it wasn't spe=
cialized and is finalized</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0T</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">type x</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//no t=
ypename required</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><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">template</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">></span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"s=
tyled-by-prettify">Child</span><font color=3D"#666600"><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by=
-prettify">Base</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify"><</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">></span=
><span style=3D"color: #000;" class=3D"styled-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>=C2=A0 =C2=A0</span><span s=
tyle=3D"color: #800;" class=3D"styled-by-prettify">//using Base<T>::X=
no longer required because we can lookup Base<T>::X without T.</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">};</span></font></div>=
</code></div><div><br><br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/9723d300-fc93-44fc-8380-1c74cb5062ea%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/9723d300-fc93-44fc-8380-1c74cb5062ea=
%40isocpp.org</a>.<br />
------=_Part_1668_463491407.1531958088495--
------=_Part_1667_249679956.1531958088494--
.
Author: "'Johannes Schaub' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Thu, 19 Jul 2018 16:51:16 +0200
Raw View
--00000000000062413605715b505a
Content-Type: text/plain; charset="UTF-8"
<bastienpenava@gmail.com> schrieb am Do., 19. Juli 2018, 01:54:
> Seeing the "thou shall not specialize std function templates" discussion
> it might be interesting to have a way to express such an idea on the
> library writer side.
> For instance
>
> //library header
> final template<class T>
> void a(T&&) {}
>
> //user-land
> template<>
> void a(int&&) //error trying to specialize finalized template declaration
> {}
>
> //library header
> template<class T>
> void b(T&& t) {};
>
> template<>
> void b(int&&) //library defined specialization
> {}
>
> final template<class T>
> void b(T&&); //finalizes the declaration
>
> //user-land
> template<>
> void b(float&&) //error trying to specialize finalized template
> declaration
> {}
>
> It would also provide a way to prevent the specialization of templated
> classes and would simplify a few cases
> final template<class T>
> struct Base
> {
> void func();
> int i;
> using type = ...;
> };
>
> template<class T>
> void func()
> {
> //We can now perform lookup on Base<T>'s attributes as it wasn't
> specialized and is finalized
> T::type x; //no typename required
> };
>
> template<class T>
> struct Child : Base<T>
> {
> //using Base<T>::X no longer required because we can lookup Base<T>::X
> without T.
> };
>
>
Gut feeling about this keyword use: It's too confusing. "final" before a
template<> means something completely different than "final" afterwards?
>
--
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/CANu6V4XnC5k9Y77vdiuhm-BUXQVqmGwoToa93UcLhZVqrLAw8Q%40mail.gmail.com.
--00000000000062413605715b505a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"auto"><div><br><br><div class=3D"gmail_quote"><div dir=3D"ltr">=
<<a href=3D"mailto:bastienpenava@gmail.com">bastienpenava@gmail.com</a>=
> schrieb am Do., 19. Juli 2018, 01:54:<br></div><blockquote class=3D"gm=
ail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-le=
ft:1ex"><div dir=3D"ltr">Seeing the "thou shall not specialize std fun=
ction templates" discussion it might be interesting to have a way to e=
xpress such an idea on the library writer side.<div>For instance</div><div>=
<br></div><div class=3D"m_8215869843201724179prettyprint" style=3D"backgrou=
nd-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;=
border-width:1px;word-wrap:break-word"><code class=3D"m_8215869843201724179=
prettyprint"><div class=3D"m_8215869843201724179subprettyprint"><span style=
=3D"color:#800" class=3D"m_8215869843201724179styled-by-prettify">//library=
header</span><span style=3D"color:#000" class=3D"m_8215869843201724179styl=
ed-by-prettify"><br></span><span style=3D"color:#008" class=3D"m_8215869843=
201724179styled-by-prettify">final</span><span style=3D"color:#000" class=
=3D"m_8215869843201724179styled-by-prettify"> </span><span style=3D"color:#=
008" class=3D"m_8215869843201724179styled-by-prettify">template</span><span=
style=3D"color:#660" class=3D"m_8215869843201724179styled-by-prettify"><=
;</span><span style=3D"color:#008" class=3D"m_8215869843201724179styled-by-=
prettify">class</span><span style=3D"color:#000" class=3D"m_821586984320172=
4179styled-by-prettify"> T</span><span style=3D"color:#660" class=3D"m_8215=
869843201724179styled-by-prettify">></span><span style=3D"color:#000" cl=
ass=3D"m_8215869843201724179styled-by-prettify"><br></span><span style=3D"c=
olor:#008" class=3D"m_8215869843201724179styled-by-prettify">void</span><sp=
an style=3D"color:#000" class=3D"m_8215869843201724179styled-by-prettify"> =
a</span><span style=3D"color:#660" class=3D"m_8215869843201724179styled-by-=
prettify">(</span><span style=3D"color:#000" class=3D"m_8215869843201724179=
styled-by-prettify">T</span><span style=3D"color:#660" class=3D"m_821586984=
3201724179styled-by-prettify">&&)</span><span style=3D"color:#000" =
class=3D"m_8215869843201724179styled-by-prettify"> </span><span style=3D"co=
lor:#660" class=3D"m_8215869843201724179styled-by-prettify">{}</span><span =
style=3D"color:#000" class=3D"m_8215869843201724179styled-by-prettify"><br>=
<br></span><span style=3D"color:#800" class=3D"m_8215869843201724179styled-=
by-prettify">//user-land</span><span style=3D"color:#000" class=3D"m_821586=
9843201724179styled-by-prettify"><br></span><span style=3D"color:#008" clas=
s=3D"m_8215869843201724179styled-by-prettify">template</span><span style=3D=
"color:#660" class=3D"m_8215869843201724179styled-by-prettify"><></sp=
an><span style=3D"color:#000" class=3D"m_8215869843201724179styled-by-prett=
ify"><br></span><span style=3D"color:#008" class=3D"m_8215869843201724179st=
yled-by-prettify">void</span><span style=3D"color:#000" class=3D"m_82158698=
43201724179styled-by-prettify"> a</span><span style=3D"color:#660" class=3D=
"m_8215869843201724179styled-by-prettify">(</span><span style=3D"color:#008=
" class=3D"m_8215869843201724179styled-by-prettify">int</span><span style=
=3D"color:#660" class=3D"m_8215869843201724179styled-by-prettify">&&=
;)</span><span style=3D"color:#000" class=3D"m_8215869843201724179styled-by=
-prettify"> </span><span style=3D"color:#800" class=3D"m_821586984320172417=
9styled-by-prettify">//error trying to specialize finalized template declar=
ation</span><span style=3D"color:#000" class=3D"m_8215869843201724179styled=
-by-prettify"><br></span><span style=3D"color:#660" class=3D"m_821586984320=
1724179styled-by-prettify">{}</span><span style=3D"color:#000" class=3D"m_8=
215869843201724179styled-by-prettify"><br><br></span><span style=3D"color:#=
800" class=3D"m_8215869843201724179styled-by-prettify">//library header</sp=
an><span style=3D"color:#000" class=3D"m_8215869843201724179styled-by-prett=
ify"><br></span><span style=3D"color:#008" class=3D"m_8215869843201724179st=
yled-by-prettify">template</span><span style=3D"color:#660" class=3D"m_8215=
869843201724179styled-by-prettify"><</span><span style=3D"color:#008" cl=
ass=3D"m_8215869843201724179styled-by-prettify">class</span><span style=3D"=
color:#000" class=3D"m_8215869843201724179styled-by-prettify"> T</span><spa=
n style=3D"color:#660" class=3D"m_8215869843201724179styled-by-prettify">&g=
t;</span><span style=3D"color:#000" class=3D"m_8215869843201724179styled-by=
-prettify"><br></span><span style=3D"color:#008" class=3D"m_821586984320172=
4179styled-by-prettify">void</span><span style=3D"color:#000" class=3D"m_82=
15869843201724179styled-by-prettify"> b</span><span style=3D"color:#660" cl=
ass=3D"m_8215869843201724179styled-by-prettify">(</span><span style=3D"colo=
r:#000" class=3D"m_8215869843201724179styled-by-prettify">T</span><span sty=
le=3D"color:#660" class=3D"m_8215869843201724179styled-by-prettify">&&a=
mp;</span><span style=3D"color:#000" class=3D"m_8215869843201724179styled-b=
y-prettify"> t</span><span style=3D"color:#660" class=3D"m_8215869843201724=
179styled-by-prettify">)</span><span style=3D"color:#000" class=3D"m_821586=
9843201724179styled-by-prettify"> </span><span style=3D"color:#660" class=
=3D"m_8215869843201724179styled-by-prettify">{};</span><span style=3D"color=
:#000" class=3D"m_8215869843201724179styled-by-prettify"><br><br></span><sp=
an style=3D"color:#008" class=3D"m_8215869843201724179styled-by-prettify">t=
emplate</span><span style=3D"color:#660" class=3D"m_8215869843201724179styl=
ed-by-prettify"><></span><span style=3D"color:#000" class=3D"m_821586=
9843201724179styled-by-prettify"><br></span><span style=3D"color:#008" clas=
s=3D"m_8215869843201724179styled-by-prettify">void</span><span style=3D"col=
or:#000" class=3D"m_8215869843201724179styled-by-prettify"> b</span><span s=
tyle=3D"color:#660" class=3D"m_8215869843201724179styled-by-prettify">(</sp=
an><span style=3D"color:#008" class=3D"m_8215869843201724179styled-by-prett=
ify">int</span><span style=3D"color:#660" class=3D"m_8215869843201724179sty=
led-by-prettify">&&)</span><span style=3D"color:#000" class=3D"m_82=
15869843201724179styled-by-prettify"> </span><span style=3D"color:#800" cla=
ss=3D"m_8215869843201724179styled-by-prettify">//library defined specializa=
tion</span><span style=3D"color:#000" class=3D"m_8215869843201724179styled-=
by-prettify"><br></span><span style=3D"color:#660" class=3D"m_8215869843201=
724179styled-by-prettify">{}</span><span style=3D"color:#000" class=3D"m_82=
15869843201724179styled-by-prettify"><br><br></span><span style=3D"color:#0=
08" class=3D"m_8215869843201724179styled-by-prettify">final</span><span sty=
le=3D"color:#000" class=3D"m_8215869843201724179styled-by-prettify"> </span=
><span style=3D"color:#008" class=3D"m_8215869843201724179styled-by-prettif=
y">template</span><span style=3D"color:#660" class=3D"m_8215869843201724179=
styled-by-prettify"><</span><span style=3D"color:#008" class=3D"m_821586=
9843201724179styled-by-prettify">class</span><span style=3D"color:#000" cla=
ss=3D"m_8215869843201724179styled-by-prettify"> T</span><span style=3D"colo=
r:#660" class=3D"m_8215869843201724179styled-by-prettify">></span><span =
style=3D"color:#000" class=3D"m_8215869843201724179styled-by-prettify"><br>=
</span><span style=3D"color:#008" class=3D"m_8215869843201724179styled-by-p=
rettify">void</span><span style=3D"color:#000" class=3D"m_82158698432017241=
79styled-by-prettify"> b</span><span style=3D"color:#660" class=3D"m_821586=
9843201724179styled-by-prettify">(</span><span style=3D"color:#000" class=
=3D"m_8215869843201724179styled-by-prettify">T</span><span style=3D"color:#=
660" class=3D"m_8215869843201724179styled-by-prettify">&&);</span><=
span style=3D"color:#000" class=3D"m_8215869843201724179styled-by-prettify"=
> </span><span style=3D"color:#800" class=3D"m_8215869843201724179styled-by=
-prettify">//finalizes the declaration</span><span style=3D"color:#000" cla=
ss=3D"m_8215869843201724179styled-by-prettify"><br><br></span><span style=
=3D"color:#800" class=3D"m_8215869843201724179styled-by-prettify">//user-la=
nd</span><span style=3D"color:#000" class=3D"m_8215869843201724179styled-by=
-prettify"><br></span><span style=3D"color:#008" class=3D"m_821586984320172=
4179styled-by-prettify">template</span><span style=3D"color:#660" class=3D"=
m_8215869843201724179styled-by-prettify"><></span><span style=3D"colo=
r:#000" class=3D"m_8215869843201724179styled-by-prettify"><br></span><span =
style=3D"color:#008" class=3D"m_8215869843201724179styled-by-prettify">void=
</span><span style=3D"color:#000" class=3D"m_8215869843201724179styled-by-p=
rettify"> b</span><span style=3D"color:#660" class=3D"m_8215869843201724179=
styled-by-prettify">(</span><span style=3D"color:#008" class=3D"m_821586984=
3201724179styled-by-prettify">float</span><span style=3D"color:#660" class=
=3D"m_8215869843201724179styled-by-prettify">&&)</span><span style=
=3D"color:#000" class=3D"m_8215869843201724179styled-by-prettify"> </span><=
span style=3D"color:#800" class=3D"m_8215869843201724179styled-by-prettify"=
>//error trying to specialize finalized template declaration</span><span st=
yle=3D"color:#000" class=3D"m_8215869843201724179styled-by-prettify"><br></=
span><span style=3D"color:#660" class=3D"m_8215869843201724179styled-by-pre=
ttify">{}</span></div></code></div><div><br></div><div>It would also provid=
e a way to prevent the specialization of templated classes and would simpli=
fy a few cases</div><div class=3D"m_8215869843201724179prettyprint" 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 class=3D"m_8215869=
843201724179prettyprint"><div class=3D"m_8215869843201724179subprettyprint"=
><span style=3D"color:#008" class=3D"m_8215869843201724179styled-by-prettif=
y">final</span><span style=3D"color:#000" class=3D"m_8215869843201724179sty=
led-by-prettify"> </span><span style=3D"color:#008" class=3D"m_821586984320=
1724179styled-by-prettify">template</span><span style=3D"color:#660" class=
=3D"m_8215869843201724179styled-by-prettify"><</span><span style=3D"colo=
r:#008" class=3D"m_8215869843201724179styled-by-prettify">class</span><span=
style=3D"color:#000" class=3D"m_8215869843201724179styled-by-prettify"> T<=
/span><span style=3D"color:#660" class=3D"m_8215869843201724179styled-by-pr=
ettify">></span><span style=3D"color:#000" class=3D"m_821586984320172417=
9styled-by-prettify"><br></span><span style=3D"color:#008" class=3D"m_82158=
69843201724179styled-by-prettify">struct</span><span style=3D"color:#000" c=
lass=3D"m_8215869843201724179styled-by-prettify"> </span><span style=3D"col=
or:#606" class=3D"m_8215869843201724179styled-by-prettify">Base</span><span=
style=3D"color:#000" class=3D"m_8215869843201724179styled-by-prettify"><br=
></span><span style=3D"color:#660" class=3D"m_8215869843201724179styled-by-=
prettify">{</span><span style=3D"color:#000" class=3D"m_8215869843201724179=
styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008" cla=
ss=3D"m_8215869843201724179styled-by-prettify">void</span><span style=3D"co=
lor:#000" class=3D"m_8215869843201724179styled-by-prettify"> func</span><sp=
an style=3D"color:#660" class=3D"m_8215869843201724179styled-by-prettify">(=
);</span><span style=3D"color:#000" class=3D"m_8215869843201724179styled-by=
-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008" class=3D"m_8=
215869843201724179styled-by-prettify">int</span><span style=3D"color:#000" =
class=3D"m_8215869843201724179styled-by-prettify"> i</span><span style=3D"c=
olor:#660" class=3D"m_8215869843201724179styled-by-prettify">;</span><span =
style=3D"color:#000" class=3D"m_8215869843201724179styled-by-prettify"><br>=
=C2=A0 =C2=A0 </span><span style=3D"color:#008" class=3D"m_8215869843201724=
179styled-by-prettify">using</span><span style=3D"color:#000" class=3D"m_82=
15869843201724179styled-by-prettify"> type </span><span style=3D"color:#660=
" class=3D"m_8215869843201724179styled-by-prettify">=3D</span><span style=
=3D"color:#000" class=3D"m_8215869843201724179styled-by-prettify"> </span><=
span style=3D"color:#660" class=3D"m_8215869843201724179styled-by-prettify"=
>...;</span><span style=3D"color:#000" class=3D"m_8215869843201724179styled=
-by-prettify"><br></span><span style=3D"color:#660" class=3D"m_821586984320=
1724179styled-by-prettify">};</span><span style=3D"color:#000" class=3D"m_8=
215869843201724179styled-by-prettify"><br><br></span><span style=3D"color:#=
008" class=3D"m_8215869843201724179styled-by-prettify">template</span><span=
style=3D"color:#660" class=3D"m_8215869843201724179styled-by-prettify"><=
;</span><span style=3D"color:#008" class=3D"m_8215869843201724179styled-by-=
prettify">class</span><span style=3D"color:#000" class=3D"m_821586984320172=
4179styled-by-prettify"> T</span><span style=3D"color:#660" class=3D"m_8215=
869843201724179styled-by-prettify">></span><span style=3D"color:#000" cl=
ass=3D"m_8215869843201724179styled-by-prettify"><br></span><span style=3D"c=
olor:#008" class=3D"m_8215869843201724179styled-by-prettify">void</span><sp=
an style=3D"color:#000" class=3D"m_8215869843201724179styled-by-prettify"> =
func</span><span style=3D"color:#660" class=3D"m_8215869843201724179styled-=
by-prettify">()</span><span style=3D"color:#000" class=3D"m_821586984320172=
4179styled-by-prettify"><br></span><span style=3D"color:#660" class=3D"m_82=
15869843201724179styled-by-prettify">{</span><span style=3D"color:#000" cla=
ss=3D"m_8215869843201724179styled-by-prettify"><br>=C2=A0 =C2=A0</span><spa=
n style=3D"color:#800" class=3D"m_8215869843201724179styled-by-prettify">//=
We can now perform lookup on Base<T>'s attributes as it wasn'=
t specialized and is finalized</span><span style=3D"color:#000" class=3D"m_=
8215869843201724179styled-by-prettify"><br>=C2=A0 =C2=A0T</span><span style=
=3D"color:#660" class=3D"m_8215869843201724179styled-by-prettify">::</span>=
<span style=3D"color:#000" class=3D"m_8215869843201724179styled-by-prettify=
">type x</span><span style=3D"color:#660" class=3D"m_8215869843201724179sty=
led-by-prettify">;</span><span style=3D"color:#000" class=3D"m_821586984320=
1724179styled-by-prettify"> </span><span style=3D"color:#800" class=3D"m_82=
15869843201724179styled-by-prettify">//no typename required</span><span sty=
le=3D"color:#000" class=3D"m_8215869843201724179styled-by-prettify"><br></s=
pan><span style=3D"color:#660" class=3D"m_8215869843201724179styled-by-pret=
tify">};</span><span style=3D"color:#000" class=3D"m_8215869843201724179sty=
led-by-prettify"><br><br></span><span style=3D"color:#008" class=3D"m_82158=
69843201724179styled-by-prettify">template</span><span style=3D"color:#660"=
class=3D"m_8215869843201724179styled-by-prettify"><</span><span style=
=3D"color:#008" class=3D"m_8215869843201724179styled-by-prettify">class</sp=
an><span style=3D"color:#000" class=3D"m_8215869843201724179styled-by-prett=
ify"> T</span><span style=3D"color:#660" class=3D"m_8215869843201724179styl=
ed-by-prettify">></span><span style=3D"color:#000" class=3D"m_8215869843=
201724179styled-by-prettify"><br></span><span style=3D"color:#008" class=3D=
"m_8215869843201724179styled-by-prettify">struct</span><span style=3D"color=
:#000" class=3D"m_8215869843201724179styled-by-prettify"> </span><span styl=
e=3D"color:#606" class=3D"m_8215869843201724179styled-by-prettify">Child</s=
pan><font color=3D"#666600"><span style=3D"color:#000" class=3D"m_821586984=
3201724179styled-by-prettify"> </span><span style=3D"color:#660" class=3D"m=
_8215869843201724179styled-by-prettify">:</span><span style=3D"color:#000" =
class=3D"m_8215869843201724179styled-by-prettify"> </span><span style=3D"co=
lor:#606" class=3D"m_8215869843201724179styled-by-prettify">Base</span><spa=
n style=3D"color:#660" class=3D"m_8215869843201724179styled-by-prettify">&l=
t;</span><span style=3D"color:#000" class=3D"m_8215869843201724179styled-by=
-prettify">T</span><span style=3D"color:#660" class=3D"m_821586984320172417=
9styled-by-prettify">></span><span style=3D"color:#000" class=3D"m_82158=
69843201724179styled-by-prettify"><br></span><span style=3D"color:#660" cla=
ss=3D"m_8215869843201724179styled-by-prettify">{</span><span style=3D"color=
:#000" class=3D"m_8215869843201724179styled-by-prettify"><br>=C2=A0 =C2=A0<=
/span><span style=3D"color:#800" class=3D"m_8215869843201724179styled-by-pr=
ettify">//using Base<T>::X no longer required because we can lookup B=
ase<T>::X without T.</span><span style=3D"color:#000" class=3D"m_8215=
869843201724179styled-by-prettify"><br></span><span style=3D"color:#660" cl=
ass=3D"m_8215869843201724179styled-by-prettify">};</span></font></div></cod=
e></div><div><br></div></div></blockquote></div></div><div dir=3D"auto"><br=
></div><div dir=3D"auto">Gut feeling about this keyword use: It's too c=
onfusing. "final" before a template<> means something compl=
etely different than "final" afterwards?</div><div dir=3D"auto"><=
br></div><div dir=3D"auto"><br></div><div dir=3D"auto"><div class=3D"gmail_=
quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-=
left:1px #ccc solid;padding-left:1ex"><br>
</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" 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/CANu6V4XnC5k9Y77vdiuhm-BUXQVqmGwoToa9=
3UcLhZVqrLAw8Q%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANu6V4XnC5k9Y77v=
diuhm-BUXQVqmGwoToa93UcLhZVqrLAw8Q%40mail.gmail.com</a>.<br />
--00000000000062413605715b505a--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Thu, 19 Jul 2018 08:26:46 -0700 (PDT)
Raw View
------=_Part_3598_717925333.1532014006414
Content-Type: multipart/alternative;
boundary="----=_Part_3599_631663415.1532014006415"
------=_Part_3599_631663415.1532014006415
Content-Type: text/plain; charset="UTF-8"
On Thursday, July 19, 2018 at 10:51:29 AM UTC-4, Johannes Schaub wrote:
>
> <bastie...@gmail.com <javascript:>> schrieb am Do., 19. Juli 2018, 01:54:
>
>> Seeing the "thou shall not specialize std function templates" discussion
>> it might be interesting to have a way to express such an idea on the
>> library writer side.
>> For instance
>>
>> //library header
>> final template<class T>
>> void a(T&&) {}
>>
>> //user-land
>> template<>
>> void a(int&&) //error trying to specialize finalized template declaration
>> {}
>>
>> //library header
>> template<class T>
>> void b(T&& t) {};
>>
>> template<>
>> void b(int&&) //library defined specialization
>> {}
>>
>> final template<class T>
>> void b(T&&); //finalizes the declaration
>>
>> //user-land
>> template<>
>> void b(float&&) //error trying to specialize finalized template
>> declaration
>> {}
>>
>> It would also provide a way to prevent the specialization of templated
>> classes and would simplify a few cases
>> final template<class T>
>> struct Base
>> {
>> void func();
>> int i;
>> using type = ...;
>> };
>>
>> template<class T>
>> void func()
>> {
>> //We can now perform lookup on Base<T>'s attributes as it wasn't
>> specialized and is finalized
>> T::type x; //no typename required
>> };
>>
>> template<class T>
>> struct Child : Base<T>
>> {
>> //using Base<T>::X no longer required because we can lookup
>> Base<T>::X without T.
>> };
>>
>>
> Gut feeling about this keyword use: It's too confusing. "final" before a
> template<> means something completely different than "final" afterwards?
>
This seems like a place where an attribute is appropriate. So you could
just tag it with [[no_specialize]] on the base template; creating
specializations for them would elicit a warning, or be straight-up
ill-formed.
That being said, I don't think that this is entirely what we want. Or at
least not all the time. The behavior for the standard library is not that
specializations don't exist; it's that specializations *past some point*
can no longer be inserted. You may need to specialize some type you've
written, but you don't want others to specialize it for you.
So what you want is to define the base template, make some specializations,
and then employ some syntax that says "no more specializations". That might
be to re-declare the base template with [[no_specialize]].
Indeed, we may be looking at things from the wrong direction. In a modular
world, what we may want to do is to be able to close namespaces entirely.
If a module formally *owns* some namespace, then maybe the module should be
able to say "people who import this module cannot add to this namespace".
Including specializations.
In this case, we would want some syntax on a primary template to *allow*
users to specialize them. The number of templates where external
specializations are reasonable is much smaller than the number where
they're not meant to happen.
--
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/b35d9877-6a01-4be5-a8f6-119f2d51e840%40isocpp.org.
------=_Part_3599_631663415.1532014006415
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, July 19, 2018 at 10:51:29 AM UTC-4, Johannes =
Schaub wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"auto"=
><div><div class=3D"gmail_quote"><div dir=3D"ltr"> <<a href=3D"javascrip=
t:" target=3D"_blank" gdf-obfuscated-mailto=3D"rY9vI1zmAgAJ" rel=3D"nofollo=
w" onmousedown=3D"this.href=3D'javascript:';return true;" onclick=
=3D"this.href=3D'javascript:';return true;">bastie...@gmail.com</a>=
> schrieb am Do., 19. Juli 2018, 01:54:<br></div><blockquote class=3D"gm=
ail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-le=
ft:1ex"><div dir=3D"ltr">Seeing the "thou shall not specialize std fun=
ction templates" discussion it might be interesting to have a way to e=
xpress such an idea on the library writer side.<div>For instance</div><div>=
<br></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:#800">//library header</span><span style=3D"col=
or:#000"><br></span><span style=3D"color:#008">final</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#008">template</span><span style=3D=
"color:#660"><</span><span style=3D"color:#008">class</span><span style=
=3D"color:#000"> T</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"> a</span><span style=3D"color:#660">(</span><span style=3D=
"color:#000">T</span><span style=3D"color:#660">&&)</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#660">{}</span><span style=
=3D"color:#000"><br><br></span><span style=3D"color:#800">//user-land</span=
><span style=3D"color:#000"><br></span><span style=3D"color:#008">template<=
/span><span style=3D"color:#660"><></span><span style=3D"color:#000">=
<br></span><span style=3D"color:#008">void</span><span style=3D"color:#000"=
> a</span><span style=3D"color:#660">(</span><span style=3D"color:#008">int=
</span><span style=3D"color:#660">&&)</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#800">//error trying to specialize finaliz=
ed template declaration</span><span style=3D"color:#000"><br></span><span s=
tyle=3D"color:#660">{}</span><span style=3D"color:#000"><br><br></span><spa=
n style=3D"color:#800">//library header</span><span style=3D"color:#000"><b=
r></span><span style=3D"color:#008">template</span><span style=3D"color:#66=
0"><</span><span style=3D"color:#008">class</span><span style=3D"color:#=
000"> T</span><span style=3D"color:#660">></span><span style=3D"color:#0=
00"><br></span><span style=3D"color:#008">void</span><span style=3D"color:#=
000"> b</span><span style=3D"color:#660">(</span><span style=3D"color:#000"=
>T</span><span style=3D"color:#660">&&</span><span style=3D"color:#=
000"> t</span><span style=3D"color:#660">)</span><span style=3D"color:#000"=
> </span><span style=3D"color:#660">{};</span><span style=3D"color:#000"><b=
r><br></span><span style=3D"color:#008">template</span><span style=3D"color=
:#660"><></span><span style=3D"color:#000"><br></span><span style=3D"=
color:#008">void</span><span style=3D"color:#000"> b</span><span style=3D"c=
olor:#660">(</span><span style=3D"color:#008">int</span><span style=3D"colo=
r:#660">&&)</span><span style=3D"color:#000"> </span><span style=3D=
"color:#800">//library defined specialization</span><span style=3D"color:#0=
00"><br></span><span style=3D"color:#660">{}</span><span style=3D"color:#00=
0"><br><br></span><span style=3D"color:#008">final</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#008">template</span><span style=3D"c=
olor:#660"><</span><span style=3D"color:#008">class</span><span style=3D=
"color:#000"> T</span><span style=3D"color:#660">></span><span style=3D"=
color:#000"><br></span><span style=3D"color:#008">void</span><span style=3D=
"color:#000"> b</span><span style=3D"color:#660">(</span><span style=3D"col=
or:#000">T</span><span style=3D"color:#660">&&);</span><span style=
=3D"color:#000"> </span><span style=3D"color:#800">//finalizes the declarat=
ion</span><span style=3D"color:#000"><br><br></span><span style=3D"color:#8=
00">//user-land</span><span style=3D"color:#000"><br></span><span style=3D"=
color:#008">template</span><span style=3D"color:#660"><></span><span =
style=3D"color:#000"><br></span><span style=3D"color:#008">void</span><span=
style=3D"color:#000"> b</span><span style=3D"color:#660">(</span><span sty=
le=3D"color:#008">float</span><span style=3D"color:#660">&&)</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#800">//error tryin=
g to specialize finalized template declaration</span><span style=3D"color:#=
000"><br></span><span style=3D"color:#660">{}</span></div></code></div><div=
><br></div><div>It would also provide a way to prevent the specialization o=
f templated classes and would simplify a few cases</div><div style=3D"backg=
round-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:sol=
id;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#=
008">final</span><span style=3D"color:#000"> </span><span style=3D"color:#0=
08">template</span><span style=3D"color:#660"><</span><span style=3D"col=
or:#008">class</span><span style=3D"color:#000"> T</span><span style=3D"col=
or:#660">></span><span style=3D"color:#000"><br></span><span style=3D"co=
lor:#008">struct</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#606">Base</span><span style=3D"color:#000"><br></span><span style=3D"c=
olor:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><spa=
n style=3D"color:#008">void</span><span style=3D"color:#000"> func</span><s=
pan style=3D"color:#660">();</span><span style=3D"color:#000"><br>=C2=A0 =
=C2=A0 </span><span style=3D"color:#008">int</span><span style=3D"color:#00=
0"> i</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><=
br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">using</span><span style=
=3D"color:#000"> type </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000"> </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><br></span><span style=3D"color:#008">template</span><s=
pan style=3D"color:#660"><</span><span style=3D"color:#008">class</span>=
<span style=3D"color:#000"> T</span><span style=3D"color:#660">></span><=
span style=3D"color:#000"><br></span><span style=3D"color:#008">void</span>=
<span style=3D"color:#000"> func</span><span style=3D"color:#660">()</span>=
<span style=3D"color:#000"><br></span><span style=3D"color:#660">{</span><s=
pan style=3D"color:#000"><br>=C2=A0 =C2=A0</span><span style=3D"color:#800"=
>//We can now perform lookup on Base<T>'s attributes as it wasn&#=
39;t specialized and is finalized</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0T</span><span style=3D"color:#660">::</span><span style=3D"color:=
#000">type x</span><span style=3D"color:#660">;</span><span style=3D"color:=
#000"> </span><span style=3D"color:#800">//no typename required</span><span=
style=3D"color:#000"><br></span><span style=3D"color:#660">};</span><span =
style=3D"color:#000"><br><br></span><span style=3D"color:#008">template</sp=
an><span style=3D"color:#660"><</span><span style=3D"color:#008">class</=
span><span style=3D"color:#000"> T</span><span style=3D"color:#660">></s=
pan><span style=3D"color:#000"><br></span><span style=3D"color:#008">struct=
</span><span style=3D"color:#000"> </span><span style=3D"color:#606">Child<=
/span><font color=3D"#666600"><span style=3D"color:#000"> </span><span styl=
e=3D"color:#660">:</span><span style=3D"color:#000"> </span><span style=3D"=
color:#606">Base</span><span style=3D"color:#660"><</span><span style=3D=
"color:#000">T</span><span style=3D"color:#660">></span><span style=3D"c=
olor:#000"><br></span><span style=3D"color:#660">{</span><span style=3D"col=
or:#000"><br>=C2=A0 =C2=A0</span><span style=3D"color:#800">//using Base<=
;T>::X no longer required because we can lookup Base<T>::X without=
T.</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">=
};</span></font></div></code></div><div><br></div></div></blockquote></div>=
</div><div dir=3D"auto"><br></div><div dir=3D"auto">Gut feeling about this =
keyword use: It's too confusing. "final" before a template<=
;> means something completely different than "final" afterward=
s?</div></div></blockquote><div><br></div><div>This seems like a place wher=
e an attribute is appropriate. So you could just tag it with [[no_specializ=
e]] on the base template; creating specializations for them would elicit a =
warning, or be straight-up ill-formed.<br></div><div><br></div><div>That be=
ing said, I don't think that this is entirely what we want. Or at least=
not all the time. The behavior for the standard library is not that specia=
lizations don't exist; it's that specializations <i>past some point=
</i> can no longer be inserted. You may need to specialize some type you=
9;ve written, but you don't want others to specialize it for you.</div>=
<div><br></div><div>So what you want is to define the base template, make s=
ome specializations, and then employ some syntax that says "no more sp=
ecializations". That might be to re-declare the base template with [[n=
o_specialize]].</div><div><br></div><div>Indeed, we may be looking at thing=
s from the wrong direction. In a modular world, what we may want to do is t=
o be able to close namespaces entirely. If a module formally <i>owns</i> so=
me namespace, then maybe the module should be able to say "people who =
import this module cannot add to this namespace". Including specializa=
tions.<br></div><div><br></div><div>In this case, we would want some syntax=
on a primary template to <i>allow</i> users to specialize them. The number=
of templates where external specializations are reasonable is much smaller=
than the number where they're not meant to happen.<br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/b35d9877-6a01-4be5-a8f6-119f2d51e840%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b35d9877-6a01-4be5-a8f6-119f2d51e840=
%40isocpp.org</a>.<br />
------=_Part_3599_631663415.1532014006415--
------=_Part_3598_717925333.1532014006414--
.
Author: bastienpenava@gmail.com
Date: Thu, 19 Jul 2018 17:02:32 -0700 (PDT)
Raw View
------=_Part_4502_1004221495.1532044952930
Content-Type: multipart/alternative;
boundary="----=_Part_4503_1044808393.1532044952931"
------=_Part_4503_1044808393.1532044952931
Content-Type: text/plain; charset="UTF-8"
On Thursday, July 19, 2018 at 5:26:46 PM UTC+2, Nicol Bolas wrote:
>
> On Thursday, July 19, 2018 at 10:51:29 AM UTC-4, Johannes Schaub wrote:
>>
>> <bastie...@gmail.com> schrieb am Do., 19. Juli 2018, 01:54:
>>
>>> Seeing the "thou shall not specialize std function templates" discussion
>>> it might be interesting to have a way to express such an idea on the
>>> library writer side.
>>> For instance
>>>
>>> //library header
>>> final template<class T>
>>> void a(T&&) {}
>>>
>>> //user-land
>>> template<>
>>> void a(int&&) //error trying to specialize finalized template
>>> declaration
>>> {}
>>>
>>> //library header
>>> template<class T>
>>> void b(T&& t) {};
>>>
>>> template<>
>>> void b(int&&) //library defined specialization
>>> {}
>>>
>>> final template<class T>
>>> void b(T&&); //finalizes the declaration
>>>
>>> //user-land
>>> template<>
>>> void b(float&&) //error trying to specialize finalized template
>>> declaration
>>> {}
>>>
>>> It would also provide a way to prevent the specialization of templated
>>> classes and would simplify a few cases
>>> final template<class T>
>>> struct Base
>>> {
>>> void func();
>>> int i;
>>> using type = ...;
>>> };
>>>
>>> template<class T>
>>> void func()
>>> {
>>> //We can now perform lookup on Base<T>'s attributes as it wasn't
>>> specialized and is finalized
>>> T::type x; //no typename required
>>> };
>>>
>>> template<class T>
>>> struct Child : Base<T>
>>> {
>>> //using Base<T>::X no longer required because we can lookup
>>> Base<T>::X without T.
>>> };
>>>
>>>
>> Gut feeling about this keyword use: It's too confusing. "final" before a
>> template<> means something completely different than "final" afterwards?
>>
>
> This seems like a place where an attribute is appropriate. So you could
> just tag it with [[no_specialize]] on the base template; creating
> specializations for them would elicit a warning, or be straight-up
> ill-formed.
>
> That being said, I don't think that this is entirely what we want. Or at
> least not all the time. The behavior for the standard library is not that
> specializations don't exist; it's that specializations *past some point*
> can no longer be inserted. You may need to specialize some type you've
> written, but you don't want others to specialize it for you.
>
> So what you want is to define the base template, make some
> specializations, and then employ some syntax that says "no more
> specializations". That might be to re-declare the base template with
> [[no_specialize]].
>
> Indeed, we may be looking at things from the wrong direction. In a modular
> world, what we may want to do is to be able to close namespaces entirely.
> If a module formally *owns* some namespace, then maybe the module should
> be able to say "people who import this module cannot add to this
> namespace". Including specializations.
>
> In this case, we would want some syntax on a primary template to *allow*
> users to specialize them. The number of templates where external
> specializations are reasonable is much smaller than the number where
> they're not meant to happen.
>
I agree on both. For the module part this might be something to bring up
during the next meetings as its still not finished.
--
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/0b916254-97b2-4040-a620-f20f8f218926%40isocpp.org.
------=_Part_4503_1044808393.1532044952931
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Thursday, July 19, 2018 at 5:26:46 PM UTC+2, Ni=
col Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"lt=
r">On Thursday, July 19, 2018 at 10:51:29 AM UTC-4, Johannes Schaub wrote:<=
blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border=
-left:1px #ccc solid;padding-left:1ex"><div dir=3D"auto"><div><div class=3D=
"gmail_quote"><div dir=3D"ltr"> <<a rel=3D"nofollow">bastie...@gmail.com=
</a>> schrieb am Do., 19. Juli 2018, 01:54:<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex"><div dir=3D"ltr">Seeing the "thou shall not specialize s=
td function templates" discussion it might be interesting to have a wa=
y to express such an idea on the library writer side.<div>For instance</div=
><div><br></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:#800">//library header</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#008">final</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">template</span><span s=
tyle=3D"color:#660"><</span><span style=3D"color:#008">class</span><span=
style=3D"color:#000"> T</span><span style=3D"color:#660">></span><span =
style=3D"color:#000"><br></span><span style=3D"color:#008">void</span><span=
style=3D"color:#000"> a</span><span style=3D"color:#660">(</span><span sty=
le=3D"color:#000">T</span><span style=3D"color:#660">&&)</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#660">{}</span><span st=
yle=3D"color:#000"><br><br></span><span style=3D"color:#800">//user-land</s=
pan><span style=3D"color:#000"><br></span><span style=3D"color:#008">templa=
te</span><span style=3D"color:#660"><></span><span style=3D"color:#00=
0"><br></span><span style=3D"color:#008">void</span><span style=3D"color:#0=
00"> a</span><span style=3D"color:#660">(</span><span style=3D"color:#008">=
int</span><span style=3D"color:#660">&&)</span><span style=3D"color=
:#000"> </span><span style=3D"color:#800">//error trying to specialize fina=
lized template declaration</span><span style=3D"color:#000"><br></span><spa=
n style=3D"color:#660">{}</span><span style=3D"color:#000"><br><br></span><=
span style=3D"color:#800">//library header</span><span style=3D"color:#000"=
><br></span><span style=3D"color:#008">template</span><span style=3D"color:=
#660"><</span><span style=3D"color:#008">class</span><span style=3D"colo=
r:#000"> T</span><span style=3D"color:#660">></span><span style=3D"color=
:#000"><br></span><span style=3D"color:#008">void</span><span style=3D"colo=
r:#000"> b</span><span style=3D"color:#660">(</span><span style=3D"color:#0=
00">T</span><span style=3D"color:#660">&&</span><span style=3D"colo=
r:#000"> t</span><span style=3D"color:#660">)</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#660">{};</span><span style=3D"color:#000"=
><br><br></span><span style=3D"color:#008">template</span><span style=3D"co=
lor:#660"><></span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">void</span><span style=3D"color:#000"> b</span><span style=
=3D"color:#660">(</span><span style=3D"color:#008">int</span><span style=3D=
"color:#660">&&)</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#800">//library defined specialization</span><span style=3D"col=
or:#000"><br></span><span style=3D"color:#660">{}</span><span style=3D"colo=
r:#000"><br><br></span><span style=3D"color:#008">final</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">template</span><span sty=
le=3D"color:#660"><</span><span style=3D"color:#008">class</span><span s=
tyle=3D"color:#000"> T</span><span style=3D"color:#660">></span><span st=
yle=3D"color:#000"><br></span><span style=3D"color:#008">void</span><span s=
tyle=3D"color:#000"> b</span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">T</span><span style=3D"color:#660">&&);</span><span=
style=3D"color:#000"> </span><span style=3D"color:#800">//finalizes the de=
claration</span><span style=3D"color:#000"><br><br></span><span style=3D"co=
lor:#800">//user-land</span><span style=3D"color:#000"><br></span><span sty=
le=3D"color:#008">template</span><span style=3D"color:#660"><></span>=
<span style=3D"color:#000"><br></span><span style=3D"color:#008">void</span=
><span style=3D"color:#000"> b</span><span style=3D"color:#660">(</span><sp=
an style=3D"color:#008">float</span><span style=3D"color:#660">&&)<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#800">//error=
trying to specialize finalized template declaration</span><span style=3D"c=
olor:#000"><br></span><span style=3D"color:#660">{}</span></div></code></di=
v><div><br></div><div>It would also provide a way to prevent the specializa=
tion of templated classes and would simplify a few cases</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">final</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#008">template</span><span style=3D"color:#660"><</span><span style=
=3D"color:#008">class</span><span style=3D"color:#000"> T</span><span style=
=3D"color:#660">></span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#008">struct</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#606">Base</span><span style=3D"color:#000"><br></span><span sty=
le=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </sp=
an><span style=3D"color:#008">void</span><span style=3D"color:#000"> func</=
span><span style=3D"color:#660">();</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 </span><span style=3D"color:#008">int</span><span style=3D"co=
lor:#000"> i</span><span style=3D"color:#660">;</span><span style=3D"color:=
#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">using</span><span=
style=3D"color:#000"> type </span><span style=3D"color:#660">=3D</span><sp=
an style=3D"color:#000"> </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><br></span><span style=3D"color:#008">template</sp=
an><span style=3D"color:#660"><</span><span style=3D"color:#008">class</=
span><span style=3D"color:#000"> T</span><span style=3D"color:#660">></s=
pan><span style=3D"color:#000"><br></span><span style=3D"color:#008">void</=
span><span style=3D"color:#000"> func</span><span style=3D"color:#660">()</=
span><span style=3D"color:#000"><br></span><span style=3D"color:#660">{</sp=
an><span style=3D"color:#000"><br>=C2=A0 =C2=A0</span><span style=3D"color:=
#800">//We can now perform lookup on Base<T>'s attributes as it w=
asn't specialized and is finalized</span><span style=3D"color:#000"><br=
>=C2=A0 =C2=A0T</span><span style=3D"color:#660">::</span><span style=3D"co=
lor:#000">type x</span><span style=3D"color:#660">;</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#800">//no typename required</span><=
span style=3D"color:#000"><br></span><span style=3D"color:#660">};</span><s=
pan style=3D"color:#000"><br><br></span><span style=3D"color:#008">template=
</span><span style=3D"color:#660"><</span><span style=3D"color:#008">cla=
ss</span><span style=3D"color:#000"> T</span><span style=3D"color:#660">>=
;</span><span style=3D"color:#000"><br></span><span style=3D"color:#008">st=
ruct</span><span style=3D"color:#000"> </span><span style=3D"color:#606">Ch=
ild</span><font color=3D"#666600"><span style=3D"color:#000"> </span><span =
style=3D"color:#660">:</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">Base</span><span style=3D"color:#660"><</span><span styl=
e=3D"color:#000">T</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:#800">//using =
Base<T>::X no longer required because we can lookup Base<T>::X =
without T.</span><span style=3D"color:#000"><br></span><span style=3D"color=
:#660">};</span></font></div></code></div><div><br></div></div></blockquote=
></div></div><div dir=3D"auto"><br></div><div dir=3D"auto">Gut feeling abou=
t this keyword use: It's too confusing. "final" before a temp=
late<> means something completely different than "final" af=
terwards?</div></div></blockquote><div><br></div><div>This seems like a pla=
ce where an attribute is appropriate. So you could just tag it with [[no_sp=
ecialize]] on the base template; creating specializations for them would el=
icit a warning, or be straight-up ill-formed.<br></div><div><br></div><div>=
That being said, I don't think that this is entirely what we want. Or a=
t least not all the time. The behavior for the standard library is not that=
specializations don't exist; it's that specializations <i>past som=
e point</i> can no longer be inserted. You may need to specialize some type=
you've written, but you don't want others to specialize it for you=
..</div><div><br></div><div>So what you want is to define the base template,=
make some specializations, and then employ some syntax that says "no =
more specializations". That might be to re-declare the base template w=
ith [[no_specialize]].</div><div><br></div><div>Indeed, we may be looking a=
t things from the wrong direction. In a modular world, what we may want to =
do is to be able to close namespaces entirely. If a module formally <i>owns=
</i> some namespace, then maybe the module should be able to say "peop=
le who import this module cannot add to this namespace". Including spe=
cializations.<br></div><div><br></div><div>In this case, we would want some=
syntax on a primary template to <i>allow</i> users to specialize them. The=
number of templates where external specializations are reasonable is much =
smaller than the number where they're not meant to happen.<br></div></d=
iv></blockquote><div>I agree on both. For the module part this might be som=
ething to bring up during the next meetings as its still not finished.</div=
></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/0b916254-97b2-4040-a620-f20f8f218926%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0b916254-97b2-4040-a620-f20f8f218926=
%40isocpp.org</a>.<br />
------=_Part_4503_1044808393.1532044952931--
------=_Part_4502_1004221495.1532044952930--
.
Author: morwenn29@gmail.com
Date: Fri, 20 Jul 2018 02:50:40 -0700 (PDT)
Raw View
------=_Part_5370_1342001045.1532080241019
Content-Type: multipart/alternative;
boundary="----=_Part_5371_523956957.1532080241019"
------=_Part_5371_523956957.1532080241019
Content-Type: text/plain; charset="UTF-8"
IMO a simpler and more conservative solution would be to state that final
on a template means that there can't be specializations at all on it.
That way you would write an implementation template that you can specialize
as you want in your library and make the final template delegate
to this implementation template. Benefits: it's simple, you can specialize
theimplementation template all you want in your library, which users
aren't supposed to even see since it's an implementation detail, and you've
got a single unspecializable user-facing template that users can't
specialize at all.
--
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/797efcac-95f3-4bfe-bcf6-aa5f05a101dd%40isocpp.org.
------=_Part_5371_523956957.1532080241019
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>IMO a simpler and more conservative solution would be=
to state that
final on a template means that there can't be specializations at all o=
n
it.</div><div><br></div><div>That way you would write an implementation
template that you can specialize as you want in your library and make=20
the final template delegate</div><div>to this implementation template. Bene=
fits: it's simple, you can specialize theimplementation template all yo=
u want in your library, which users</div><div>aren't supposed to even s=
ee since it's an implementation detail, and you've got a single uns=
pecializable user-facing template that users can't</div><div>specialize=
at all.<br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/797efcac-95f3-4bfe-bcf6-aa5f05a101dd%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/797efcac-95f3-4bfe-bcf6-aa5f05a101dd=
%40isocpp.org</a>.<br />
------=_Part_5371_523956957.1532080241019--
------=_Part_5370_1342001045.1532080241019--
.
Author: florian.csdt@gmail.com
Date: Fri, 20 Jul 2018 04:16:19 -0700 (PDT)
Raw View
------=_Part_1988_2023079729.1532085379735
Content-Type: multipart/alternative;
boundary="----=_Part_1989_2064784615.1532085379735"
------=_Part_1989_2064784615.1532085379735
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Le vendredi 20 juillet 2018 11:50:41 UTC+2, morw...@gmail.com a =C3=A9crit =
:
>
> IMO a simpler and more conservative solution would be to state that final=
=20
> on a template means that there can't be specializations at all on it.
>
> That way you would write an implementation template that you can=20
> specialize as you want in your library and make the final template delega=
te
> to this implementation template. Benefits: it's simple, you can specializ=
e=20
> theimplementation template all you want in your library, which users
> aren't supposed to even see since it's an implementation detail, and=20
> you've got a single unspecializable user-facing template that users can't
> specialize at all.
>
That's actually already possible: you cannot specialize a using declaration=
..
namespace details {
template <class T> class Foo;
=20
/* details::Foo specializations */
}
template <class T>
using Foo =3D details::Foo<T>;
--=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/9b7fa816-4545-45ea-801a-0033e4cc0c7a%40isocpp.or=
g.
------=_Part_1989_2064784615.1532085379735
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>Le vendredi 20 juillet 2018 11:50:41 UTC+2, morw..=
..@gmail.com a =C3=A9crit=C2=A0:<blockquote class=3D"gmail_quote" style=3D"m=
argin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"=
><div dir=3D"ltr"><div>IMO a simpler and more conservative solution would b=
e to state that
final on a template means that there can't be specializations at all o=
n
it.</div><div><br></div><div>That way you would write an implementation
template that you can specialize as you want in your library and make=20
the final template delegate</div><div>to this implementation template. Bene=
fits: it's simple, you can specialize theimplementation template all yo=
u want in your library, which users</div><div>aren't supposed to even s=
ee since it's an implementation detail, and you've got a single uns=
pecializable user-facing template that users can't</div><div>specialize=
at all.<br></div></div></blockquote><div><br></div><div>That's actuall=
y already possible: you cannot specialize a using declaration.</div><div><d=
iv style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 18=
7, 187); border-style: solid; border-width: 1px; overflow-wrap: break-word;=
" class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subpretty=
print"><span style=3D"color: #008;" class=3D"styled-by-prettify">namespace<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> details </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">template</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">class</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">></span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">class</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Foo<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 <br>=C2=
=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/* det=
ails::Foo specializations */</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>template</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">></span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">using</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D=
"styled-by-prettify">Foo</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> d=
etails</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</=
span><span style=3D"color: #606;" class=3D"styled-by-prettify">Foo</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">>;</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br></span></div></code></div></div></d=
iv>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/9b7fa816-4545-45ea-801a-0033e4cc0c7a%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/9b7fa816-4545-45ea-801a-0033e4cc0c7a=
%40isocpp.org</a>.<br />
------=_Part_1989_2064784615.1532085379735--
------=_Part_1988_2023079729.1532085379735--
.