Topic: would n3601 allow this?


Author: Larry Evans <cppljevans@suddenlink.net>
Date: Wed, 12 Aug 2015 06:03:39 -0500
Raw View
This is a multi-part message in MIME format.
--------------030202090506010303040204
Content-Type: text/plain; charset=UTF-8

The attached, when compiled *without*:

#define IMPLICIT_TEMPLATE_PARAMETERS

with clang 3.5 claims the specialization:

type_param
  < Tmpl<Valu>
  >

on about line 34, will not be considered
because Type cannot be deduced; hence,
main returns 0.

OTOH, *with*:

#define IMPLICIT_TEMPLATE_PARAMETERS

will the specialization be considered; hence,
main returns 1?

TIA.

-regards,
Larry

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--------------030202090506010303040204
Content-Type: text/x-c++src;
 name="non_type_tmpl_type.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="non_type_tmpl_type.cpp"

//Purpose:
//  Reproduce the non-deducible Type
//  in a specialization using non-type
//  template class.
//
//#define IMPLICIT_TEMPLATE_PARAMETERS
  //The "IMPLICIT_TEMPLATE_PARAMETERS"
  //refers to the term, "Implicit template parameters"
  //as used in these places:
  //  https://isocpp.org/files/papers/n3601.html
  //  http://open-std.org/JTC1/SC22/WG21/docs/papers/2015/n4469.html
  template
  < typename Type
  >
  struct
type_param
  {
    static int _(){ return 0;}
  };
  template
  <
  #ifdef IMPLICIT_TEMPLATE_PARAMETERS
    using
    //This syntax is from the n3601.html reference.
    //Would this allow this specialization
    //to be used, and consequently, cause
    //the main function to return 1 instead of 0?
  #endif
    typename Type
  , Type Valu
  , template<Type>class Tmpl
  >
  struct
type_param
  < Tmpl<Valu>
  >
  //the specialization.
  {
    static Type _(){ return Valu;}
  };
  template
  < int
  >
  struct
non_type//the non-type template class.
  {};
  int
main()
  {
    return type_param<non_type<1>>::_();
  }



--------------030202090506010303040204--


.


Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Date: Wed, 12 Aug 2015 17:02:09 -0700 (PDT)
Raw View
------=_Part_1436_1500088673.1439424129304
Content-Type: multipart/alternative;
 boundary="----=_Part_1437_1693241943.1439424129305"

------=_Part_1437_1693241943.1439424129305
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Out of the goodness of my heart, I've unfuxored Larry's code:
http://melpon.org/wandbox/permlink/kbQDGh7Y7gKRdCCM

template <class Type>
struct type_param {
    static int _() { return 0;}
};

template <USING typename Type, Type Valu, template<Type> class Tmpl>
struct type_param<Tmpl<Valu>> {
    static Type _() { return Valu; }
};

template<int> struct non_type {};

int main()
{
    return type_param<non_type<1>>::_();
}

Larry points out that the above code compiled with -DUSING=3D emits a warni=
ng=20
and returns 0; he asks whether it would compile with -DUSING=3Dusing if N36=
01=20
"Implicit template parameters" <https://isocpp.org/files/papers/n3601.html>=
 were=20
to be adopted (and if so, whether it would return 0 or 1).

=E2=80=93Arthur


On Wednesday, August 12, 2015 at 4:10:09 AM UTC-7, Larry Evans wrote:
>
> The attached, when compiled *without*:=20
>
> #define IMPLICIT_TEMPLATE_PARAMETERS=20
>
> with clang 3.5 claims the specialization:=20
>
> type_param=20
>   < Tmpl<Valu>=20
>   >=20
>
> on about line 34, will not be considered=20
> because Type cannot be deduced; hence,=20
> main returns 0.=20
>
> OTOH, *with*:=20
>
> #define IMPLICIT_TEMPLATE_PARAMETERS=20
>
> will the specialization be considered; hence,=20
> main returns 1?=20
>
> TIA.=20
>
> -regards,=20
> Larry=20
>

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_1437_1693241943.1439424129305
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Out of the goodness of my heart, I&#39;ve unfuxored L=
arry&#39;s code:</div><div><a href=3D"http://melpon.org/wandbox/permlink/kb=
QDGh7Y7gKRdCCM">http://melpon.org/wandbox/permlink/kbQDGh7Y7gKRdCCM<br></a>=
</div><div><br></div><div class=3D"prettyprint" style=3D"background-color: =
rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-wrap: break-=
word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span styl=
e=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">&lt;</span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">Type</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> typ=
e_param </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">sta=
tic</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">int</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: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">return</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</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></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">template</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">USING </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">typename</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pret=
tify">Type</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">Type</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #606;" class=3D"styled-by-prettify">Valu</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">template</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&lt;</span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">Type</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">&gt;</span><span style=3D"color: #000;" 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"> </span><span st=
yle=3D"color: #606;" class=3D"styled-by-prettify">Tmpl</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&gt;</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"> type_param</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">Tmpl</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&lt;</span><span style=3D"color: #606;" class=3D"styled-b=
y-prettify">Valu</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&gt;&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><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">static=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #606;" class=3D"styled-by-prettify">Type</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> _</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">()</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"> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">return</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Valu</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n 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></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: #080;" class=
=3D"styled-by-prettify">&lt;int&gt;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> non_type </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">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> mai=
n</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: #008;" class=3D"styled-by-prettify">return</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> type_param</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">non_type</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #0=
66;" class=3D"styled-by-prettify">1</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">&gt;&gt;::</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">_</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span></div></code></div><br>Larry points out that the above code compiled w=
ith=C2=A0<font face=3D"courier new, monospace">-DUSING=3D</font>=C2=A0emits=
 a warning and returns 0; he asks whether it would compile with <font face=
=3D"courier new, monospace">-DUSING=3Dusing</font> if <a href=3D"https://is=
ocpp.org/files/papers/n3601.html">N3601 &quot;Implicit template parameters&=
quot;</a>=C2=A0were to be adopted (and if so, whether it would return 0 or =
1).<div><br></div><div>=E2=80=93Arthur<br><br><br>On Wednesday, August 12, =
2015 at 4:10:09 AM UTC-7, Larry Evans wrote:<blockquote class=3D"gmail_quot=
e" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;paddin=
g-left: 1ex;">The attached, when compiled *without*:
<br>
<br>#define IMPLICIT_TEMPLATE_PARAMETERS
<br>
<br>with clang 3.5 claims the specialization:
<br>
<br>type_param
<br>=C2=A0 &lt; Tmpl&lt;Valu&gt;
<br>=C2=A0 &gt;
<br>
<br>on about line 34, will not be considered
<br>because Type cannot be deduced; hence,
<br>main returns 0.
<br>
<br>OTOH, *with*:
<br>
<br>#define IMPLICIT_TEMPLATE_PARAMETERS
<br>
<br>will the specialization be considered; hence,
<br>main returns 1?
<br>
<br>TIA.
<br>
<br>-regards,
<br>Larry
<br></blockquote></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1437_1693241943.1439424129305--
------=_Part_1436_1500088673.1439424129304--

.