Topic: std::visit() is a bad name (std::variant visitor)


Author: Victor Dyachenko <victor.dyachenko@gmail.com>
Date: Mon, 8 Aug 2016 03:01:03 -0700 (PDT)
Raw View
------=_Part_3983_862546047.1470650463731
Content-Type: multipart/alternative;
 boundary="----=_Part_3984_730746489.1470650463731"

------=_Part_3984_730746489.1470650463731
Content-Type: text/plain; charset=UTF-8

In the current draft std::visit() looks like

template <class Visitor, class... Variants>
constexpr /*see below*/ visit(Visitor&& vis, Variants&&... vars);

I think it's a bad idea to give such generic name, because all function
parameters are template parameters. It would be OK if the prototype looked
like

template <class Visitor>
constexpr /*see below*/ visit(Visitor&& vis, std::variant &var);

In this case we can reuse this generic function name for different types

template <class Visitor>
constexpr /*see below*/ visit(Visitor&& vis, std::any-another-type &var);

I think the name like visit_variant() would be better.

--
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/19b2bf30-020c-4c43-82bf-be7934f48c2b%40isocpp.org.

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

<div dir=3D"ltr">In the current draft <span style=3D"font-family: courier n=
ew,monospace;">std::visit()</span> looks like<br><br><div class=3D"prettypr=
int" 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"co=
lor: #008;" class=3D"styled-by-prettify">template</span><span style=3D"colo=
r: #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;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">Visitor</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</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: #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">Variants</span><span style=3D"co=
lor: #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">constexpr</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"s=
tyled-by-prettify">/*see below*/</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> visit</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"color: #606;" class=3D"styled-by=
-prettify">Visitor</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">&amp;&amp;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> vis</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">Variants</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;&amp;...</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> vars</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">);</span></div></cod=
e></div><span class=3D"sy4" style=3D"line-height: 14.08px; margin: 0px; pad=
ding: 0px; color: rgb(0, 128, 128); font-family: DejaVuSansMono, &quot;Deja=
Vu Sans Mono&quot;, courier, monospace; font-size: 12.8px; font-style: norm=
al; font-variant-ligatures: normal; font-variant-caps: normal; font-weight:=
 normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent=
: 0px; text-transform: none; white-space: nowrap; widows: 2; word-spacing: =
0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"=
><br></span>I think it&#39;s a bad idea to give such generic name, because =
all function parameters are template parameters. It would be OK if the prot=
otype looked like<br><br><div class=3D"prettyprint" style=3D"background-col=
or: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: sol=
id; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint">=
<div class=3D"subprettyprint"><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=
">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">clas=
s</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #606;" class=3D"styled-by-prettify">Visitor</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</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">constexpr</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800=
;" class=3D"styled-by-prettify">/*see below*/</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> visit</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(</span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">Visitor</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&amp;&amp;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> vis</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">variant =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">var</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">);</span></div></code>=
</div><br>In this case we can reuse this generic function name for differen=
t types<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(25=
0, 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"color: #008;" class=3D"styled-by-prettif=
y">template</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Visitor</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">constexpr</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">/*see below*/</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> visit</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">Visitor</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">&amp;&amp;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> vis</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> st=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">any</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">-</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">another</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">type </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">&amp;</span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">var</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">);</span></div></code></div><br>I think the name like <span st=
yle=3D"font-family: courier new,monospace;">visit_variant()</span> would be=
 better.<br></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/19b2bf30-020c-4c43-82bf-be7934f48c2b%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/19b2bf30-020c-4c43-82bf-be7934f48c2b=
%40isocpp.org</a>.<br />

------=_Part_3984_730746489.1470650463731--

------=_Part_3983_862546047.1470650463731--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Mon, 8 Aug 2016 07:43:46 -0700 (PDT)
Raw View
------=_Part_83_222693502.1470667426491
Content-Type: multipart/alternative;
 boundary="----=_Part_84_1058269417.1470667426492"

------=_Part_84_1058269417.1470667426492
Content-Type: text/plain; charset=UTF-8

On Monday, August 8, 2016 at 6:01:04 AM UTC-4, Victor Dyachenko wrote:
>
> In the current draft std::visit() looks like
>
> template <class Visitor, class... Variants>
> constexpr /*see below*/ visit(Visitor&& vis, Variants&&... vars);
>
> I think it's a bad idea to give such generic name, because all function
> parameters are template parameters. It would be OK if the prototype looked
> like
>
> template <class Visitor>
> constexpr /*see below*/ visit(Visitor&& vis, std::variant &var);
>
>
You would lose a lot of the functionality. `vars` is a parameter pack. That
allows multi-visitation to work. That is, you can pass multiple variants to
`visit`, and it will call the members of `vis` with a parameter for each
element in `var`.

That is a highly useful thing to be able to do.


> In this case we can reuse this generic function name for different types
>
> template <class Visitor>
> constexpr /*see below*/ visit(Visitor&& vis, std::any-another-type &var);
>
>
If we wanted to expand `visit` to types other than `std::variant`, then
odds are good that we'd build some kind of VariantLike concept which
`visit` would use. It could therefore take *any* type which the user
provides, so long as it fits VariantLike.

--
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/9dc33478-a51e-41f9-8881-9922635cd537%40isocpp.org.

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

<div dir=3D"ltr">On Monday, August 8, 2016 at 6:01:04 AM UTC-4, Victor Dyac=
henko wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">I=
n the current draft <span style=3D"font-family:courier new,monospace">std::=
visit()</span> looks like<br><br><div style=3D"background-color:rgb(250,250=
,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px;wor=
d-wrap:break-word"><code><div><span style=3D"color:#008">template</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><span=
 style=3D"color:#008">class</span><span style=3D"color:#000"> </span><span =
style=3D"color:#606">Visitor</span><span style=3D"color:#660">,</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#008">class</span><span =
style=3D"color:#660">...</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#606">Variants</span><span style=3D"color:#660">&gt;</span><spa=
n style=3D"color:#000"><br></span><span style=3D"color:#008">constexpr</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#800">/*see below=
*/</span><span style=3D"color:#000"> visit</span><span style=3D"color:#660"=
>(</span><span style=3D"color:#606">Visitor</span><span style=3D"color:#660=
">&amp;&amp;</span><span style=3D"color:#000"> vis</span><span style=3D"col=
or:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#6=
06">Variants</span><span style=3D"color:#660">&amp;&amp;...</span><span sty=
le=3D"color:#000"> vars</span><span style=3D"color:#660">);</span></div></c=
ode></div><span style=3D"line-height:14.08px;margin:0px;padding:0px;color:r=
gb(0,128,128);font-family:DejaVuSansMono,&quot;DejaVu Sans Mono&quot;,couri=
er,monospace;font-size:12.8px;font-style:normal;font-weight:normal;letter-s=
pacing:normal;text-align:start;text-indent:0px;text-transform:none;white-sp=
ace:nowrap;word-spacing:0px;background-color:rgb(255,255,255)"><br></span>I=
 think it&#39;s a bad idea to give such generic name, because all function =
parameters are template parameters. It would be OK if the prototype looked =
like<br><br><div style=3D"background-color:rgb(250,250,250);border-color:rg=
b(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><c=
ode><div><span style=3D"color:#008">template</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#660">&lt;</span><span style=3D"color:#008"=
>class</span><span style=3D"color:#000"> </span><span style=3D"color:#606">=
Visitor</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#0=
00"><br></span><span style=3D"color:#008">constexpr</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#800">/*see below*/</span><span styl=
e=3D"color:#000"> visit</span><span style=3D"color:#660">(</span><span styl=
e=3D"color:#606">Visitor</span><span style=3D"color:#660">&amp;&amp;</span>=
<span style=3D"color:#000"> vis</span><span style=3D"color:#660">,</span><s=
pan style=3D"color:#000"> std</span><span style=3D"color:#660">::</span><sp=
an style=3D"color:#000">variant </span><span style=3D"color:#660">&amp;</sp=
an><span style=3D"color:#008">var</span><span style=3D"color:#660">);</span=
></div></code></div><br></div></blockquote><div><br>You would lose a lot of=
 the functionality. `vars` is a parameter pack. That allows multi-visitatio=
n to work. That is, you can pass multiple variants to `visit`, and it will =
call the members of `vis` with a parameter for each element in `var`.<br><b=
r>That is a highly useful thing to be able to do.<br>=C2=A0</div><blockquot=
e class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: =
1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">In this case we can reu=
se this generic function name for different types<br><br><div style=3D"back=
ground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:so=
lid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color:=
#008">template</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#660">&lt;</span><span style=3D"color:#008">class</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#606">Visitor</span><span style=3D"c=
olor:#660">&gt;</span><span style=3D"color:#000"><br></span><span style=3D"=
color:#008">constexpr</span><span style=3D"color:#000"> </span><span style=
=3D"color:#800">/*see below*/</span><span style=3D"color:#000"> visit</span=
><span style=3D"color:#660">(</span><span style=3D"color:#606">Visitor</spa=
n><span style=3D"color:#660">&amp;&amp;</span><span style=3D"color:#000"> v=
is</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> std=
</span><span style=3D"color:#660">::</span><span style=3D"color:#000">any</=
span><span style=3D"color:#660">-</span><span style=3D"color:#000">another<=
/span><span style=3D"color:#660">-</span><span style=3D"color:#000">type </=
span><span style=3D"color:#660">&amp;</span><span style=3D"color:#008">var<=
/span><span style=3D"color:#660">);</span></div></code></div><br></div></bl=
ockquote><div><br>If we wanted to expand `visit` to types other than `std::=
variant`, then odds are good that we&#39;d build some kind of VariantLike c=
oncept which `visit` would use. It could therefore take <i>any</i> type whi=
ch the user provides, so long as it fits VariantLike.</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/9dc33478-a51e-41f9-8881-9922635cd537%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/9dc33478-a51e-41f9-8881-9922635cd537=
%40isocpp.org</a>.<br />

------=_Part_84_1058269417.1470667426492--

------=_Part_83_222693502.1470667426491--

.


Author: Victor Dyachenko <victor.dyachenko@gmail.com>
Date: Mon, 8 Aug 2016 08:08:40 -0700 (PDT)
Raw View
------=_Part_164_93806207.1470668920642
Content-Type: multipart/alternative;
 boundary="----=_Part_165_491792455.1470668920642"

------=_Part_165_491792455.1470668920642
Content-Type: text/plain; charset=UTF-8


>
> That is a highly useful thing to be able to do.
>
I know that multi-visitation is useful and didn't write anything against it.


> If we wanted to expand `visit` to types other than `std::variant`, then
> odds are good that we'd build some kind of VariantLike concept which
> `visit` would use. It could therefore take *any* type which the user
> provides, so long as it fits VariantLike.
>
The visitor pattern is not tied exclusively to variant! It is applicable to
variant type but also can be used without it.

Again. My main point is that function should use generic name only if it
can be easily overloaded for another types, like

auto abs(int );
auto abs(long );
auto abs(MyNumericType );

So the name can be easily reused for another functions. It's not the case
if there is no specific type in the parameters list and we don't have
Concepts-based functions overloading in the language. (enable_if is just an
ugly hack). You cannot do this:

template<class Iterator>
void sort(Iterator begin, Iterator end);

template<class Container, class Comparator>
void sort(Container &cont, Comparator comp);

--
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/5cd9f987-c00b-4231-b593-7298a2a9f05e%40isocpp.org.

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

<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr">That is a highly useful thing to be able to do.<br></div></blockquote><=
div>I know that multi-visitation is useful and didn&#39;t write anything ag=
ainst it.<br>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:=
 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div =
dir=3D"ltr"><div>If we wanted to expand `visit` to types other than `std::v=
ariant`, then odds are good that we&#39;d build some kind of VariantLike co=
ncept which `visit` would use. It could therefore take <i>any</i> type whic=
h the user provides, so long as it fits VariantLike.</div></div></blockquot=
e><div>The visitor pattern is not tied exclusively to variant! It is applic=
able to variant type but also can be used without it.<br><br>Again. My main=
 point is that function should use generic name only if it can be easily ov=
erloaded for another types, like<br><br><div class=3D"prettyprint" style=3D=
"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); bo=
rder-style: solid; border-width: 1px; word-wrap: break-word;"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> abs</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: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> abs</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">long</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">auto</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a=
bs</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span>=
<span style=3D"color: #606;" class=3D"styled-by-prettify">MyNumericType</sp=
an><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></span></div></code></div><=
br>So the name can be easily reused for another functions. It&#39;s not the=
 case if there is no specific type in the parameters list and we don&#39;t =
have Concepts-based functions overloading in the language. (<span style=3D"=
font-family: courier new,monospace;">enable_if</span> is just an ugly hack)=
.. You cannot do this:<br><br><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"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">template</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">class</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Itera=
tor</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> sort</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">Iterator</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">begin</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pret=
tify">Iterator</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">end</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><sp=
an 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 s=
tyle=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"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #60=
6;" class=3D"styled-by-prettify">Container</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: #008;" class=3D"style=
d-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"=
>Comparator</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">void</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> sort</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #606;" class=3D"styled-by-prettify">Container</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">cont</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pret=
tify">Comparator</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> comp</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></div></code></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/5cd9f987-c00b-4231-b593-7298a2a9f05e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/5cd9f987-c00b-4231-b593-7298a2a9f05e=
%40isocpp.org</a>.<br />

------=_Part_165_491792455.1470668920642--

------=_Part_164_93806207.1470668920642--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Mon, 8 Aug 2016 08:28:34 -0700 (PDT)
Raw View
------=_Part_664_1149408721.1470670114440
Content-Type: multipart/alternative;
 boundary="----=_Part_665_1737024680.1470670114440"

------=_Part_665_1737024680.1470670114440
Content-Type: text/plain; charset=UTF-8



On Monday, August 8, 2016 at 11:08:41 AM UTC-4, Victor Dyachenko wrote:

> If we wanted to expand `visit` to types other than `std::variant`, then
>> odds are good that we'd build some kind of VariantLike concept which
>> `visit` would use. It could therefore take *any* type which the user
>> provides, so long as it fits VariantLike.
>>
> The visitor pattern is not tied exclusively to variant! It is applicable
> to variant type but also can be used without it.
>
> Again. My main point is that function should use generic name only if it
> can be easily overloaded for another types, like
>
> auto abs(int );
> auto abs(long );
> auto abs(MyNumericType );
>
>
But that's *not legal*.

See, `abs` and `visit` live in the `std::` namespace. And you are *not
allowed* to overload functions in the `std::` namespace. The standard
expressly forbids this.

You *can* create specializations of templates defined in the `std::`
namespace. But you cannot create true *overloads* of `std::` functions.

And as I pointed out, if the standard library adopted another variant type,
then it could still use `visit` with that type.

--
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/e29ce6fb-93b5-432e-82f0-28d7a7ca5a8f%40isocpp.org.

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

<div dir=3D"ltr"><br><br>On Monday, August 8, 2016 at 11:08:41 AM UTC-4, Vi=
ctor Dyachenko wrote: <br><blockquote class=3D"gmail_quote" style=3D"margin=
: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div=
 dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-lef=
t:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>=
If we wanted to expand `visit` to types other than `std::variant`, then odd=
s are good that we&#39;d build some kind of VariantLike concept which `visi=
t` would use. It could therefore take <i>any</i> type which the user provid=
es, so long as it fits VariantLike.</div></div></blockquote><div>The visito=
r pattern is not tied exclusively to variant! It is applicable to variant t=
ype but also can be used without it.<br><br>Again. My main point is that fu=
nction should use generic name only if it can be easily overloaded for anot=
her types, like<br><br><div style=3D"background-color:rgb(250,250,250);bord=
er-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:bre=
ak-word"><code><div><span style=3D"color:#008">auto</span><span style=3D"co=
lor:#000"> abs</span><span style=3D"color:#660">(</span><span style=3D"colo=
r:#008">int</span><span style=3D"color:#000"> </span><span style=3D"color:#=
660">);</span><span style=3D"color:#000"><br></span><span style=3D"color:#0=
08">auto</span><span style=3D"color:#000"> abs</span><span style=3D"color:#=
660">(</span><span style=3D"color:#008">long</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#660">);</span><span style=3D"color:#000"><=
br></span><span style=3D"color:#008">auto</span><span style=3D"color:#000">=
 abs</span><span style=3D"color:#660">(</span><span style=3D"color:#606">My=
NumericType</span><span style=3D"color:#000"> </span><span style=3D"color:#=
660">);</span><span style=3D"color:#000"><br></span></div></code></div><br>=
</div></div></blockquote><div><br>But that&#39;s <i>not legal</i>.<br><br>S=
ee, `abs` and `visit` live in the `std::` namespace. And you are <i>not all=
owed</i> to overload functions in the `std::` namespace. The standard expre=
ssly forbids this.<br><br>You <i>can</i> create specializations of template=
s defined in the `std::` namespace. But you cannot create true <i>overloads=
</i> of `std::` functions.<br><br>And as I pointed out, if the standard lib=
rary adopted another variant type, then it could still use `visit` with tha=
t type.<br></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/e29ce6fb-93b5-432e-82f0-28d7a7ca5a8f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/e29ce6fb-93b5-432e-82f0-28d7a7ca5a8f=
%40isocpp.org</a>.<br />

------=_Part_665_1737024680.1470670114440--

------=_Part_664_1149408721.1470670114440--

.


Author: Victor Dyachenko <victor.dyachenko@gmail.com>
Date: Mon, 8 Aug 2016 08:37:24 -0700 (PDT)
Raw View
------=_Part_672_647338088.1470670644427
Content-Type: multipart/alternative;
 boundary="----=_Part_673_1756226566.1470670644427"

------=_Part_673_1756226566.1470670644427
Content-Type: text/plain; charset=UTF-8

On Monday, August 8, 2016 at 6:28:34 PM UTC+3, Nicol Bolas wrote:
>
> But that's *not legal*.
>
Adding new functions to the std in the future is not legal for C++ std
committee? Interesting...


> And as I pointed out, if the standard library adopted another variant
> type, then it could still use `visit` with that type.
>
"visit" name can be applied not only to variant! It can be object with
totally different interface.

--
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/30f2590f-2aef-4775-b8df-cabf4a89345e%40isocpp.org.

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

<div dir=3D"ltr">On Monday, August 8, 2016 at 6:28:34 PM UTC+3, Nicol 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"ltr">But th=
at&#39;s <i>not legal</i>.<br></div></blockquote><div>Adding new functions =
to the std in the future is not legal for C++ std committee? Interesting...=
<br></div><div>=C2=A0<br><blockquote style=3D"margin: 0px 0px 0px 0.8ex; bo=
rder-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail=
_quote">And as I pointed out, if the standard library adopted another varia=
nt type, then it could still use `visit` with that type.<br></blockquote><d=
iv>&quot;visit&quot; name can be applied not only to variant! It can be obj=
ect with totally different interface.<br></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/30f2590f-2aef-4775-b8df-cabf4a89345e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/30f2590f-2aef-4775-b8df-cabf4a89345e=
%40isocpp.org</a>.<br />

------=_Part_673_1756226566.1470670644427--

------=_Part_672_647338088.1470670644427--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Mon, 8 Aug 2016 09:16:20 -0700 (PDT)
Raw View
------=_Part_1237_1514320452.1470672980662
Content-Type: multipart/alternative;
 boundary="----=_Part_1238_893551216.1470672980662"

------=_Part_1238_893551216.1470672980662
Content-Type: text/plain; charset=UTF-8

On Monday, August 8, 2016 at 11:37:24 AM UTC-4, Victor Dyachenko wrote:
>
> On Monday, August 8, 2016 at 6:28:34 PM UTC+3, Nicol Bolas wrote:
>
And as I pointed out, if the standard library adopted another variant type,
>> then it could still use `visit` with that type.
>>
> "visit" name can be applied not only to variant! It can be object with
> totally different interface.
>

Then that's a problem that this hypothetical other interface can deal with
when, and if, it ever comes up. We shouldn't use a sub-optimal name for the
current interface on the basis of what *may* happen in the future that
might never come.

--
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/248ecd6b-df09-4f1b-b4f5-89459aa26741%40isocpp.org.

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

<div dir=3D"ltr">On Monday, August 8, 2016 at 11:37:24 AM UTC-4, Victor Dya=
chenko wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div>On Monday, A=
ugust 8, 2016 at 6:28:34 PM UTC+3, Nicol Bolas wrote:<br></div></blockquote=
><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bo=
rder-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div></div><=
div><blockquote style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb=
(204,204,204);padding-left:1ex" class=3D"gmail_quote">And as I pointed out,=
 if the standard library adopted another variant type, then it could still =
use `visit` with that type.<br></blockquote><div>&quot;visit&quot; name can=
 be applied not only to variant! It can be object with totally different in=
terface.<br></div></div></div></blockquote><div><br>Then that&#39;s a probl=
em that this hypothetical other interface can deal with when, and if, it ev=
er comes up. We shouldn&#39;t use a sub-optimal name for the current interf=
ace on the basis of what <i>may</i> happen in the future that might never c=
ome.<br></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/248ecd6b-df09-4f1b-b4f5-89459aa26741%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/248ecd6b-df09-4f1b-b4f5-89459aa26741=
%40isocpp.org</a>.<br />

------=_Part_1238_893551216.1470672980662--

------=_Part_1237_1514320452.1470672980662--

.


Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Date: Mon, 8 Aug 2016 18:24:56 -0700 (PDT)
Raw View
------=_Part_4551_170545292.1470705896175
Content-Type: multipart/alternative;
 boundary="----=_Part_4552_2007125106.1470705896176"

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

On Monday, August 8, 2016 at 8:08:41 AM UTC-7, Victor Dyachenko wrote:
>
> That is a highly useful thing to be able to do.
>>
> I know that multi-visitation is useful and didn't write anything against=
=20
> it.
> =20
>
>> If we wanted to expand `visit` to types other than `std::variant`, then=
=20
>> odds are good that we'd build some kind of VariantLike concept which=20
>> `visit` would use. It could therefore take *any* type which the user=20
>> provides, so long as it fits VariantLike.
>>
> The visitor pattern is not tied exclusively to variant! It is applicable=
=20
> to variant type but also can be used without it.
>
> Again. My main point is that function should use generic name only if it=
=20
> can be easily overloaded for another types, like
>
> auto abs(int );
> auto abs(long );
> auto abs(MyNumericType );
>
> So the name can be easily reused for another functions. It's not the case=
=20
> if there is no specific type in the parameters list and we don't have=20
> Concepts-based functions overloading in the language. (enable_if is just=
=20
> an ugly hack). You cannot do this:
>
> template<class Iterator>
> void sort(Iterator begin, Iterator end);
>
> template<class Container, class Comparator>
> void sort(Container &cont, Comparator comp);
>

I think you have a misunderstanding here. You absolutely *can* do the above=
=20
in Concepts-Lite, and Concepts-Lite is implementable as a relatively thin=
=20
layer of sugar over top of plain old SFINAE.  (And SFINAE is just a bunch=
=20
of enable_if hacks. You say potato, I say potato.)

So if I were trying to write the above in C++17, I'd probably write

template<class T, class U>
void sort(const T& t, const U& u) {
    if constexpr (std::is_comparator_v<U> && std::is_container_v<T>) {
        sort_container(t, u);
    } else if constexpr (std::is_iterator_v<T> && std::is_iterator_v<U> &&=
=20
std::is_same_v<T, U>) {
        sort_range(t, u);
    } else {
        static_assert(false);
    }
}

where the "if constexpr" stuff is, again, just a thin wrapper over SFINAE=
=20
hacks.
And if you tried to sort() a pair of Iterators that also happened to=20
implement Container and Comparator (which is possible but unlikely), I'd=20
throw in something to indicate that your program was ill-formed in that=20
case. Obviously, Concepts-Lite makes that easy and (obviously?)=20
if-constexpr really doesn't... but that's okay, the point is that it's=20
still doable.

It may be *ugly* (for now), but the point is that it's *doable*, and that=
=20
library implementors know how to do it. Throw the above spec at Eric=20
Fiselier or whoever, and I bet he won't even blink. :)

That said, I do believe you have located a defect in the wording: I think=
=20
that *N4606 20.7.6 [variant.visit]* means to imply that the signature shall=
=20
not participate in overload resolution unless all vars... are in fact=20
various specializations of std::variant, whereas right now IMHO it doesn't=
=20
say that, and so it's implying that the following program is ill-formed:

struct Fake { };
template<class T> void visit(T&&, const Fake&) {}

int main()
{
    std::variant<int> real;
    Fake fake;
    using std::visit;
    visit([](int){ }, real);  // calls std::visit
    visit([](int){ }, fake);  // SHOULD use ADL, IMHO; but current wording=
=20
implies that this calls std::visit and gives a hard error
}

What do people think?

=E2=80=93Arthur

--=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/da98efd8-c986-4f16-86c1-1011b7f673d7%40isocpp.or=
g.

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

<div dir=3D"ltr">On Monday, August 8, 2016 at 8:08:41 AM UTC-7, Victor Dyac=
henko wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><=
blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border=
-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">That is a highly us=
eful thing to be able to do.<br></div></blockquote><div>I know that multi-v=
isitation is useful and didn&#39;t write anything against it.<br>=C2=A0</di=
v><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bor=
der-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>If we wante=
d to expand `visit` to types other than `std::variant`, then odds are good =
that we&#39;d build some kind of VariantLike concept which `visit` would us=
e. It could therefore take <i>any</i> type which the user provides, so long=
 as it fits VariantLike.</div></div></blockquote><div>The visitor pattern i=
s not tied exclusively to variant! It is applicable to variant type but als=
o can be used without it.<br><br>Again. My main point is that function shou=
ld use generic name only if it can be easily overloaded for another types, =
like<br><br><div style=3D"background-color:rgb(250,250,250);border-color:rg=
b(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><c=
ode><div><span style=3D"color:#008">auto</span><span style=3D"color:#000"> =
abs</span><span style=3D"color:#660">(</span><span style=3D"color:#008">int=
</span><span style=3D"color:#000"> </span><span style=3D"color:#660">);</sp=
an><span style=3D"color:#000"><br></span><span style=3D"color:#008">auto</s=
pan><span style=3D"color:#000"> abs</span><span style=3D"color:#660">(</spa=
n><span style=3D"color:#008">long</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">);</span><span style=3D"color:#000"><br></span><=
span style=3D"color:#008">auto</span><span style=3D"color:#000"> abs</span>=
<span style=3D"color:#660">(</span><span style=3D"color:#606">MyNumericType=
</span><span style=3D"color:#000"> </span><span style=3D"color:#660">);</sp=
an><span style=3D"color:#000"><br></span></div></code></div><br>So the name=
 can be easily reused for another functions. It&#39;s not the case if there=
 is no specific type in the parameters list and we don&#39;t have Concepts-=
based functions overloading in the language. (<span style=3D"font-family:co=
urier new,monospace">enable_if</span> is just an ugly hack). You cannot do =
this:<br><br><div style=3D"background-color:rgb(250,250,250);border-color:r=
gb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><=
code><div><span style=3D"color:#008">template</span><span style=3D"color:#6=
60">&lt;</span><span style=3D"color:#008">class</span><span style=3D"color:=
#000"> </span><span style=3D"color:#606">Iterator</span><span style=3D"colo=
r:#660">&gt;</span><span style=3D"color:#000"><br></span><span style=3D"col=
or:#008">void</span><span style=3D"color:#000"> sort</span><span style=3D"c=
olor:#660">(</span><span style=3D"color:#606">Iterator</span><span style=3D=
"color:#000"> </span><span style=3D"color:#008">begin</span><span style=3D"=
color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color=
:#606">Iterator</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#008">end</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"color:#660">&lt;</span><span style=3D"color:#008">class</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#606">Container</span><span =
style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">class</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">Comparator</span><span style=3D"color:#660">&gt;</span><spa=
n style=3D"color:#000"><br></span><span style=3D"color:#008">void</span><sp=
an style=3D"color:#000"> sort</span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#606">Container</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">&amp;</span><span style=3D"color:#000">cont</span=
><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#606">Comparator</span><span style=3D"color:#000"> comp</s=
pan><span style=3D"color:#660">);</span></div></code></div></div></div></bl=
ockquote><div><br></div><div>I think you have a misunderstanding here. You =
absolutely <i><b>can</b></i> do the above in Concepts-Lite, and Concepts-Li=
te is implementable as a relatively thin layer of sugar over top of plain o=
ld SFINAE. =C2=A0(And SFINAE is just a bunch of enable_if hacks. You say po=
tato, I say potato.)</div><div><br></div><div>So if I were trying to write =
the above in C++17, I&#39;d probably write</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"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">template</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">class</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> T</span><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: #008;" class=3D"styled-by-prettify">class</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> U</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> sort</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">const</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&am=
p;</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 st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> U</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> u</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </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">if<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</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">std</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">is_comparator_v</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">U</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&amp;&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">is_container_v=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">T</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&gt;)</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"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 sort_container=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><s=
pan 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"> u</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: #660=
;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">else</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
if</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">is_iterator_v</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">T</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"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&am=
p;&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> st=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">is_iterator_v</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">U</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&amp;&amp;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">is_same_v</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&lt;</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"> U</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;)</span><sp=
an 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>=C2=A0 =C2=A0 =C2=A0 =C2=A0 sort_=
range</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><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"> u</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">else</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"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">static_assert</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">false</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span></d=
iv></code></div><div><br></div><div>where the &quot;if constexpr&quot; stuf=
f is, again, just a thin wrapper over SFINAE hacks.</div><div>And if you tr=
ied to sort() a pair of Iterators that also happened to implement Container=
 and Comparator (which is possible but unlikely), I&#39;d throw in somethin=
g to indicate that your program was ill-formed in that case. Obviously, Con=
cepts-Lite makes that easy and (obviously?) if-constexpr really doesn&#39;t=
.... but that&#39;s okay, the point is that it&#39;s still doable.<br></div>=
<div><br></div><div>It may be <i>ugly</i>=C2=A0(for now), but the point is =
that it&#39;s <i>doable</i>, and that library implementors know how to do i=
t. Throw the above spec at Eric Fiselier or whoever, and I bet he won&#39;t=
 even blink. :)</div><div><br></div><div>That said, I do believe you have l=
ocated a defect in the wording: I think that <b>N4606 20.7.6 [variant.visit=
]</b> means to imply that the signature shall not participate in overload r=
esolution unless all <font face=3D"courier new, monospace">vars...</font> a=
re in fact various specializations of <font face=3D"courier new, monospace"=
>std::variant</font>, whereas right now IMHO it doesn&#39;t say that, and s=
o it&#39;s implying that the following program is ill-formed:</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 c=
lass=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D=
"styled-by-prettify">Fake</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"co=
lor: #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;" c=
lass=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> visit</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;&amp;,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #606;" class=3D"styled-by-prettify">Fake</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">&amp;)</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"><br><br></span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> main</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 std</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">variant</span><span s=
tyle=3D"color: #080;" class=3D"styled-by-prettify">&lt;int&gt;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> real</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: #606;" class=3D"styled-by-prettify">Fake</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> fake</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cl=
ass=3D"styled-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"styled-by-prettify"> std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">visit</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 visit</span><span style=3D"color: #660;" class=3D"style=
d-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-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">},</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> real</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> =C2=A0</span><span style=3D"color: =
#800;" class=3D"styled-by-prettify">// calls std::visit</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 visit</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">([](</span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">){</span><span style=3D"colo=
r: #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"> fake</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> =C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-pr=
ettify">// SHOULD use ADL, IMHO; but current wording implies that this call=
s std::visit and gives a hard error</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span></div></code></div><div><br></div><div>What do people =
think?</div><div><br></div><div>=E2=80=93Arthur</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/da98efd8-c986-4f16-86c1-1011b7f673d7%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/da98efd8-c986-4f16-86c1-1011b7f673d7=
%40isocpp.org</a>.<br />

------=_Part_4552_2007125106.1470705896176--

------=_Part_4551_170545292.1470705896175--

.


Author: Victor Dyachenko <victor.dyachenko@gmail.com>
Date: Tue, 9 Aug 2016 00:03:46 -0700 (PDT)
Raw View
------=_Part_220_1581695130.1470726227058
Content-Type: multipart/alternative;
 boundary="----=_Part_221_385923742.1470726227064"

------=_Part_221_385923742.1470726227064
Content-Type: text/plain; charset=UTF-8

On Tuesday, August 9, 2016 at 4:24:56 AM UTC+3, Arthur O'Dwyer wrote:
>
> That said, I do believe you have located a defect in the wording: I think
> that *N4606 20.7.6 [variant.visit]* means to imply that the signature
> shall not participate in overload resolution unless all vars... are in
> fact various specializations of std::variant
>
Agree. This addition to the wording wold be good alternative to renaming.


--
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/1fc51c73-81d1-44d4-abda-84b5ceec3497%40isocpp.org.

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

<div dir=3D"ltr">On Tuesday, August 9, 2016 at 4:24:56 AM UTC+3, Arthur O&#=
39;Dwyer 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"ltr=
">That said, I do believe you have located a defect in the wording: I think=
 that <b>N4606 20.7.6 [variant.visit]</b> means to imply that the signature=
 shall not participate in overload resolution unless all <font face=3D"cour=
ier new, monospace">vars...</font> are in fact various specializations of <=
font face=3D"courier new, monospace">std::variant</font><br></div></blockqu=
ote><div>Agree. This addition to the wording wold be good alternative to re=
naming.<br></div><div>=C2=A0</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/1fc51c73-81d1-44d4-abda-84b5ceec3497%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1fc51c73-81d1-44d4-abda-84b5ceec3497=
%40isocpp.org</a>.<br />

------=_Part_221_385923742.1470726227064--

------=_Part_220_1581695130.1470726227058--

.


Author: Victor Dyachenko <victor.dyachenko@gmail.com>
Date: Tue, 9 Aug 2016 00:05:34 -0700 (PDT)
Raw View
------=_Part_2328_1272991505.1470726334709
Content-Type: multipart/alternative;
 boundary="----=_Part_2329_1489909279.1470726334709"

------=_Part_2329_1489909279.1470726334709
Content-Type: text/plain; charset=UTF-8

On Tuesday, August 9, 2016 at 4:24:56 AM UTC+3, Arthur O'Dwyer wrote:
>
> That said, I do believe you have located a defect in the wording: I think
> that *N4606 20.7.6 [variant.visit]* means to imply that the signature
> shall not participate in overload resolution unless all vars... are in
> fact various specializations of std::variant
>
Agree. This addition to the wording would be good alternative to renaming.

--
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/414095ae-9ead-40d8-a1e5-3edfcbb02fe4%40isocpp.org.

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

<div dir=3D"ltr"><div><div style=3D"overflow: auto"><div style=3D"max-heigh=
t: 10000px;"><div dir=3D"ltr">On Tuesday, August 9, 2016 at 4:24:56 AM UTC+=
3, Arthur O&#39;Dwyer wrote:<blockquote class=3D"gmail_quote" style=3D"marg=
in:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div di=
r=3D"ltr">That said, I do believe you have located a defect in the wording:=
 I think that <b>N4606 20.7.6 [variant.visit]</b> means to imply that the s=
ignature shall not participate in overload resolution unless all <font face=
=3D"courier new, monospace">vars...</font> are in fact various specializati=
ons of <font face=3D"courier new, monospace">std::variant</font><br></div><=
/blockquote><div>Agree. This addition to the wording would be good alternat=
ive to renaming.<br></div></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/414095ae-9ead-40d8-a1e5-3edfcbb02fe4%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/414095ae-9ead-40d8-a1e5-3edfcbb02fe4=
%40isocpp.org</a>.<br />

------=_Part_2329_1489909279.1470726334709--

------=_Part_2328_1272991505.1470726334709--

.


Author: Simon Brand <simon@codeplay.com>
Date: Tue, 9 Aug 2016 08:48:47 +0100
Raw View
This is a multi-part message in MIME format.
--------------7152E0506E92A94958A21CF5
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 09/08/16 02:24, Arthur O'Dwyer wrote:
> So if I were trying to write the above in C++17, I'd probably write
>
> |
> template<classT,classU>
> voidsort(constT&t,constU&u){
> ifconstexpr(std::is_comparator_v<U>&&std::is_container_v<T>){
>         sort_container(t,u);
> }elseifconstexpr(std::is_iterator_v<T>&&std::is_iterator_v<U>&&std::is_sa=
me_v<T,U>){
>         sort_range(t,u);
> }else{
> static_assert(false);
> }
> }
> |
>
Is that `static_assert(false)` well-formed by the current `if constexpr`=20
rules? For some reason I assumed that this would follow similar rules to=20
[temp.res]/8, i.e. if no valid specialization exists for the branch,=20
then it is ill-formed.

--=20
Simon Brand
Staff Software Engineer
Codeplay Software Ltd
Level C, Argyle House, 3 Lady Lawson St, Edinburgh, EH3 9DR
Tel: 0131 466 0503
Fax: 0131 557 6600
Website: http://www.codeplay.com
Twitter: https://twitter.com/codeplaysoft

This email and any attachments may contain confidential and /or privileged =
information and is for use by the addressee only. If you are not the intend=
ed recipient, please notify Codeplay Software Ltd immediately and delete th=
e message from your computer. You may not copy or forward it, or use or dis=
close its contents to any other person. Any views or other information in t=
his message which do not relate to our business are not authorized by Codep=
lay software Ltd, nor does this message form part of any contract unless so=
 stated.
As internet communications are capable of data corruption Codeplay Software=
 Ltd does not accept any responsibility for any changes made to this messag=
e after it was sent. Please note that Codeplay Software Ltd does not accept=
 any liability or responsibility for viruses and it is your responsibility =
to scan any attachments.
Company registered in England and Wales, number: 04567874
Registered office: 81 Linkfield Street, Redhill RH1 6BY

--=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/bba87632-31e4-93c9-4158-0bd6066862ec%40codeplay.=
com.

--------------7152E0506E92A94958A21CF5
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html>
  <head>
    <meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">On 09/08/16 02:24, Arthur O'Dwyer
      wrote:<br>
    </div>
    <blockquote
      cite=3D"mid:da98efd8-c986-4f16-86c1-1011b7f673d7@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr">So if I were trying to write the above in C++17,
        I'd probably write
        <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 style=3D"color: #008;"
                class=3D"styled-by-prettify">template</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #008;" class=3D"styled-by-prettify">class</=
span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> T</spa=
n><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: #008;" class=3D"styled-by-prettify">class</=
span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> U</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><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"> sort</=
span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span
                style=3D"color: #008;" class=3D"styled-by-prettify">const</=
span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> T</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</=
span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> t</spa=
n><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: #008;" class=3D"styled-by-prettify">const</=
span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> U</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</=
span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> u</spa=
n><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-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">if</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"> </span><span
                style=3D"color: #008;" class=3D"styled-by-prettify">constex=
pr</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">std</sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">is_comp=
arator_v</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify">U</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&amp;&a=
mp;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> std</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">is_cont=
ainer_v</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><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
                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 =C2=A0 =C2=A0 sort_container</span><span styl=
e=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"> u</spa=
n><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: #660;"
                class=3D"styled-by-prettify">}</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"> </span><span
                style=3D"color: #008;" class=3D"styled-by-prettify">else</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #008;" class=3D"styled-by-prettify">if</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #008;" class=3D"styled-by-prettify">constex=
pr</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">std</sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">is_iter=
ator_v</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify">T</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&amp;&a=
mp;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> std</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">is_iter=
ator_v</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify">U</span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&amp;&a=
mp;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> std</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">is_same=
_v</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><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"> U</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;)</=
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"><br>
                =C2=A0 =C2=A0 =C2=A0 =C2=A0 sort_range</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"> u</spa=
n><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: #660;"
                class=3D"styled-by-prettify">}</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"> </span><span
                style=3D"color: #008;" class=3D"styled-by-prettify">else</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>
                =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #0=
08;"
                class=3D"styled-by-prettify">static_assert</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span
                style=3D"color: #008;" class=3D"styled-by-prettify">false</=
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: #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></div>
          </code></div>
        <br>
      </div>
    </blockquote>
    Is that `static_assert(false)` well-formed by the current `if
    constexpr` rules? For some reason I assumed that this would follow
    similar rules to [temp.res]/8, i.e. if no valid specialization
    exists for the branch, then it is ill-formed. <br>
    <pre class=3D"moz-signature" cols=3D"72">--=20
Simon Brand
Staff Software Engineer
Codeplay Software Ltd
Level C, Argyle House, 3 Lady Lawson St, Edinburgh, EH3 9DR
Tel: 0131 466 0503
Fax: 0131 557 6600
Website: <a class=3D"moz-txt-link-freetext" href=3D"http://www.codeplay.com=
">http://www.codeplay.com</a>
Twitter: <a class=3D"moz-txt-link-freetext" href=3D"https://twitter.com/cod=
eplaysoft">https://twitter.com/codeplaysoft</a>

This email and any attachments may contain confidential and /or privileged =
information and is for use by the addressee only. If you are not the intend=
ed recipient, please notify Codeplay Software Ltd immediately and delete th=
e message from your computer. You may not copy or forward it, or use or dis=
close its contents to any other person. Any views or other information in t=
his message which do not relate to our business are not authorized by Codep=
lay software Ltd, nor does this message form part of any contract unless so=
 stated.
As internet communications are capable of data corruption Codeplay Software=
 Ltd does not accept any responsibility for any changes made to this messag=
e after it was sent. Please note that Codeplay Software Ltd does not accept=
 any liability or responsibility for viruses and it is your responsibility =
to scan any attachments.
Company registered in England and Wales, number: 04567874
Registered office: 81 Linkfield Street, Redhill RH1 6BY </pre>
  </body>
</html>

<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/bba87632-31e4-93c9-4158-0bd6066862ec%=
40codeplay.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.googl=
e.com/a/isocpp.org/d/msgid/std-proposals/bba87632-31e4-93c9-4158-0bd6066862=
ec%40codeplay.com</a>.<br />

--------------7152E0506E92A94958A21CF5--

.


Author: =?UTF-8?Q?Daniel_Kr=C3=BCgler?= <daniel.kruegler@gmail.com>
Date: Tue, 9 Aug 2016 09:50:56 +0200
Raw View
2016-08-09 3:24 GMT+02:00 Arthur O'Dwyer <arthur.j.odwyer@gmail.com>:
> That said, I do believe you have located a defect in the wording: I think
> that N4606 20.7.6 [variant.visit] means to imply that the signature shall
> not participate in overload resolution unless all vars... are in fact
> various specializations of std::variant, whereas right now IMHO it doesn't
> say that, and so it's implying that the following program is ill-formed:
>
> struct Fake { };
> template<class T> void visit(T&&, const Fake&) {}
>
> int main()
> {
>     std::variant<int> real;
>     Fake fake;
>     using std::visit;
>     visit([](int){ }, real);  // calls std::visit
>     visit([](int){ }, fake);  // SHOULD use ADL, IMHO; but current wording
> implies that this calls std::visit and gives a hard error
> }
>
> What do people think?

I disagree that this is a defect in the standard, but I agree that it
would be a reasonable feature request.

The reason why I disagree with it being a defect is, because the false
assumption here is that the standard provides std::visit as ADL
customization point. If you can point to wording in the standard that
provides such a guarantee, then you have indeed found a defect. But
according to my reading there is no such guarantee, so user code
better should better write qualified std::visit as it would call
qualified std::sort.

As pointed out in the second half of my first sentence, it seems not
unreasonable to require that std::visit should add overload resolution
constraints (and to say which precisely), you may even do try this by
submitting a library issue for this, but I recommend to provide a good
reasoning for this change in that issue, because such an issue could
otherwise easily be resolved as NAD.

- Daniel

--
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/CAGNvRgCnfBhGgkt3SdVdhs7rJB%3DUYRSS_HaEnNvGO81uZhxjQQ%40mail.gmail.com.

.


Author: "Arthur O'Dwyer" <arthur.j.odwyer@gmail.com>
Date: Tue, 9 Aug 2016 01:20:57 -0700
Raw View
--001a114f856e5366d005399f366a
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Tue, Aug 9, 2016 at 12:48 AM, Simon Brand <simon@codeplay.com> wrote:

> On 09/08/16 02:24, Arthur O'Dwyer wrote:
>
> So if I were trying to write the above in C++17, I'd probably write
>
> template<class T, class U>
> void sort(const T& t, const U& u) {
>     if constexpr (std::is_comparator_v<U> && std::is_container_v<T>) {
>         sort_container(t, u);
>     } else if constexpr (std::is_iterator_v<T> && std::is_iterator_v<U> &=
&
> std::is_same_v<T, U>) {
>         sort_range(t, u);
>     } else {
>         static_assert(false);
>     }
> }
>
> Is that `static_assert(false)` well-formed by the current `if constexpr`
> rules? For some reason I assumed that this would follow similar rules to
> [temp.res]/8, i.e. if no valid specialization exists for the branch, then
> it is ill-formed.
>

Oops!  My understanding is that you are 100% correct, and I should have
written something like static_assert(sizeof(T)=3D=3D0) instead.  I think I =
even
planned to do that but then forgot to actually *do* it before hitting
"Send". :)

=E2=80=93Arthur

--=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/CADvuK0Ji_%3D9OFrssCEJZ9tcXscLsGSt5q0GWXMmgDA4VF=
n62Mw%40mail.gmail.com.

--001a114f856e5366d005399f366a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Tue, Aug 9, 2016 at 12:48 AM, Simon Brand <span dir=3D"=
ltr">&lt;<a href=3D"mailto:simon@codeplay.com" target=3D"_blank">simon@code=
play.com</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"=
gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;b=
order-left:1px #ccc solid;padding-left:1ex">
 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div>On 09/08/16 02:24, Arthur O&#39;Dwyer
      wrote:<br>
    </div>
    <blockquote type=3D"cite">
      <div dir=3D"ltr">So if I were trying to write the above in C++17,
        I&#39;d probably write
        <div><br>
        </div>
        <div style=3D"background-color:rgb(250,250,250);border:1px solid rg=
b(187,187,187);word-wrap:break-word"><code>
            <div><span style=3D"color:#008">template</span><span style=3D"c=
olor:#660">&lt;</span><span style=3D"color:#008">class</span><span style=3D=
"color:#000"> T</span><span style=3D"color:#660">,</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#008">class</span><span style=3D"colo=
r:#000"> U</span><span style=3D"color:#660">&gt;</span><span style=3D"color=
:#000"><br>
              </span><span style=3D"color:#008">void</span><span style=3D"c=
olor:#000"> sort</span><span style=3D"color:#660">(</span><span style=3D"co=
lor:#008">const</span><span style=3D"color:#000"> T</span><span style=3D"co=
lor:#660">&amp;</span><span style=3D"color:#000"> t</span><span style=3D"co=
lor:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#=
008">const</span><span style=3D"color:#000"> U</span><span style=3D"color:#=
660">&amp;</span><span style=3D"color:#000"> u</span><span style=3D"color:#=
660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
{</span><span style=3D"color:#000"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color:#008">if</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#008">constexpr</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#000">std</span><span style=3D"color:#660">::</span><span =
style=3D"color:#000">is_comparator_v</span><span style=3D"color:#660">&lt;<=
/span><span style=3D"color:#000">U</span><span style=3D"color:#660">&gt;</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#660">&amp;&amp=
;</span><span style=3D"color:#000"> std</span><span style=3D"color:#660">::=
</span><span style=3D"color:#000">is_container_v</span><span style=3D"color=
:#660">&lt;</span><span style=3D"color:#000">T</span><span style=3D"color:#=
660">&gt;)</span><span style=3D"color:#000"> </span><span style=3D"color:#6=
60">{</span><span style=3D"color:#000"><br>
                =C2=A0 =C2=A0 =C2=A0 =C2=A0 sort_container</span><span styl=
e=3D"color:#660">(</span><span style=3D"color:#000">t</span><span style=3D"=
color:#660">,</span><span style=3D"color:#000"> u</span><span style=3D"colo=
r:#660">);</span><span style=3D"color:#000"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color:#660">}</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#008">else</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#008">if</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">constexpr</span><span =
style=3D"color:#000"> </span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">std</span><span style=3D"color:#660">::</span><span style=
=3D"color:#000">is_iterator_v</span><span style=3D"color:#660">&lt;</span><=
span style=3D"color:#000">T</span><span style=3D"color:#660">&gt;</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#660">&amp;&amp;</span=
><span style=3D"color:#000"> std</span><span style=3D"color:#660">::</span>=
<span style=3D"color:#000">is_iterator_v</span><span style=3D"color:#660">&=
lt;</span><span style=3D"color:#000">U</span><span style=3D"color:#660">&gt=
;</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&amp;=
&amp;</span><span style=3D"color:#000"> std</span><span style=3D"color:#660=
">::</span><span style=3D"color:#000">is_same_v</span><span style=3D"color:=
#660">&lt;</span><span style=3D"color:#000">T</span><span style=3D"color:#6=
60">,</span><span style=3D"color:#000"> U</span><span style=3D"color:#660">=
&gt;)</span><span style=3D"color:#000"> </span><span style=3D"color:#660">{=
</span><span style=3D"color:#000"><br>
                =C2=A0 =C2=A0 =C2=A0 =C2=A0 sort_range</span><span style=3D=
"color:#660">(</span><span style=3D"color:#000">t</span><span style=3D"colo=
r:#660">,</span><span style=3D"color:#000"> u</span><span style=3D"color:#6=
60">);</span><span style=3D"color:#000"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color:#660">}</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#008">else</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#660">{</span><span styl=
e=3D"color:#000"><br>
                =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#00=
8">static_assert</span><span style=3D"color:#660">(</span><span style=3D"co=
lor:#008">false</span><span style=3D"color:#660">);</span><span style=3D"co=
lor:#000"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color:#660">}</span><sp=
an style=3D"color:#000"><br>
              </span><span style=3D"color:#660">}</span></div>
          </code></div>
        <br>
      </div>
    </blockquote>
    Is that `static_assert(false)` well-formed by the current `if
    constexpr` rules? For some reason I assumed that this would follow
    similar rules to [temp.res]/8, i.e. if no valid specialization
    exists for the branch, then it is ill-formed. <br></div></blockquote><d=
iv><br></div><div>Oops!=C2=A0 My understanding is that you are 100% correct=
, and I should have written something like <font face=3D"monospace, monospa=
ce">static_assert(sizeof(T)=3D=3D0)</font> instead.=C2=A0 I think I even pl=
anned to do that but then forgot to actually <i>do</i> it before hitting &q=
uot;Send&quot;. :)</div><div><br></div><div>=E2=80=93Arthur</div></div></di=
v></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/CADvuK0Ji_%3D9OFrssCEJZ9tcXscLsGSt5q0=
GWXMmgDA4VFn62Mw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CADvuK0Ji_%3D9O=
FrssCEJZ9tcXscLsGSt5q0GWXMmgDA4VFn62Mw%40mail.gmail.com</a>.<br />

--001a114f856e5366d005399f366a--

.


Author: Richard Smith <richard@metafoo.co.uk>
Date: Tue, 9 Aug 2016 10:54:11 -0700
Raw View
--001a1141091e70dfde0539a73820
Content-Type: text/plain; charset=UTF-8

On Tue, Aug 9, 2016 at 1:20 AM, Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
wrote:

> On Tue, Aug 9, 2016 at 12:48 AM, Simon Brand <simon@codeplay.com> wrote:
>
>> On 09/08/16 02:24, Arthur O'Dwyer wrote:
>>
>> So if I were trying to write the above in C++17, I'd probably write
>>
>> template<class T, class U>
>> void sort(const T& t, const U& u) {
>>     if constexpr (std::is_comparator_v<U> && std::is_container_v<T>) {
>>         sort_container(t, u);
>>     } else if constexpr (std::is_iterator_v<T> && std::is_iterator_v<U>
>> && std::is_same_v<T, U>) {
>>         sort_range(t, u);
>>     } else {
>>         static_assert(false);
>>     }
>> }
>>
>> Is that `static_assert(false)` well-formed by the current `if constexpr`
>> rules? For some reason I assumed that this would follow similar rules to
>> [temp.res]/8, i.e. if no valid specialization exists for the branch, then
>> it is ill-formed.
>>
>
> Oops!  My understanding is that you are 100% correct, and I should have
> written something like static_assert(sizeof(T)==0) instead.  I think I
> even planned to do that but then forgot to actually *do* it before
> hitting "Send". :)
>

Well, that's ill-formed, no diagnostic required, because there can never
exist a type T which has size zero. You can do this:

template<class T, class U>
void sort(const T& t, const U& u) {
    if constexpr (std::is_comparator_v<U> && std::is_container_v<T>) {
        sort_container(t, u);
    } else {
        static_assert(std::is_iterator_v<T> && std::is_same_v<T, U>);
        sort_range(t, u);
    }
}

.... if you can cope with the asymmetry of using 'if constexpr' for one case
and 'static_assert' for the other.

--
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/CAOfiQqmOp93vR8JW62hEL6_wfoB7h2dGeTYktBHueTjNujjEzg%40mail.gmail.com.

--001a1141091e70dfde0539a73820
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
ue, Aug 9, 2016 at 1:20 AM, Arthur O&#39;Dwyer <span dir=3D"ltr">&lt;<a hre=
f=3D"mailto:arthur.j.odwyer@gmail.com" target=3D"_blank">arthur.j.odwyer@gm=
ail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D=
"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,2=
04,204);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr"><span cl=
ass=3D"">On Tue, Aug 9, 2016 at 12:48 AM, Simon Brand <span dir=3D"ltr">&lt=
;<a href=3D"mailto:simon@codeplay.com" target=3D"_blank">simon@codeplay.com=
</a>&gt;</span> wrote:<br></span><div class=3D"gmail_extra"><div class=3D"g=
mail_quote"><span class=3D""><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,2=
04);border-left-style:solid;padding-left:1ex">
 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div>On 09/08/16 02:24, Arthur O&#39;Dwyer
      wrote:<br>
    </div>
    <blockquote type=3D"cite">
      <div dir=3D"ltr">So if I were trying to write the above in C++17,
        I&#39;d probably write
        <div><br>
        </div>
        <div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-wor=
d;background-color:rgb(250,250,250)"><code>
            <div><span style=3D"color:rgb(0,0,136)">template</span><span st=
yle=3D"color:rgb(102,102,0)">&lt;</span><span style=3D"color:rgb(0,0,136)">=
class</span><span style=3D"color:rgb(0,0,0)"> T</span><span style=3D"color:=
rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><span styl=
e=3D"color:rgb(0,0,136)">class</span><span style=3D"color:rgb(0,0,0)"> U</s=
pan><span style=3D"color:rgb(102,102,0)">&gt;</span><span style=3D"color:rg=
b(0,0,0)"><br>
              </span><span style=3D"color:rgb(0,0,136)">void</span><span st=
yle=3D"color:rgb(0,0,0)"> sort</span><span style=3D"color:rgb(102,102,0)">(=
</span><span style=3D"color:rgb(0,0,136)">const</span><span style=3D"color:=
rgb(0,0,0)"> T</span><span style=3D"color:rgb(102,102,0)">&amp;</span><span=
 style=3D"color:rgb(0,0,0)"> t</span><span style=3D"color:rgb(102,102,0)">,=
</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,=
0,136)">const</span><span style=3D"color:rgb(0,0,0)"> U</span><span style=
=3D"color:rgb(102,102,0)">&amp;</span><span style=3D"color:rgb(0,0,0)"> u</=
span><span style=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(=
0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D=
"color:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">if<=
/span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0=
,136)">constexpr</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">std</spa=
n><span style=3D"color:rgb(102,102,0)">::</span><span style=3D"color:rgb(0,=
0,0)">is_comparator_v</span><span style=3D"color:rgb(102,102,0)">&lt;</span=
><span style=3D"color:rgb(0,0,0)">U</span><span style=3D"color:rgb(102,102,=
0)">&gt;</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"colo=
r:rgb(102,102,0)">&amp;&amp;</span><span style=3D"color:rgb(0,0,0)"> std</s=
pan><span style=3D"color:rgb(102,102,0)">::</span><span style=3D"color:rgb(=
0,0,0)">is_container_v</span><span style=3D"color:rgb(102,102,0)">&lt;</spa=
n><span style=3D"color:rgb(0,0,0)">T</span><span style=3D"color:rgb(102,102=
,0)">&gt;)</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"co=
lor:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 =C2=A0 =C2=A0 sort_container</span><span styl=
e=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">t</span=
><span style=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,=
0)"> u</span><span style=3D"color:rgb(102,102,0)">);</span><span style=3D"c=
olor:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">}=
</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,=
0,136)">else</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"=
color:rgb(0,0,136)">if</span><span style=3D"color:rgb(0,0,0)"> </span><span=
 style=3D"color:rgb(0,0,136)">constexpr</span><span style=3D"color:rgb(0,0,=
0)"> </span><span style=3D"color:rgb(102,102,0)">(</span><span style=3D"col=
or:rgb(0,0,0)">std</span><span style=3D"color:rgb(102,102,0)">::</span><spa=
n style=3D"color:rgb(0,0,0)">is_iterator_v</span><span style=3D"color:rgb(1=
02,102,0)">&lt;</span><span style=3D"color:rgb(0,0,0)">T</span><span style=
=3D"color:rgb(102,102,0)">&gt;</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(102,102,0)">&amp;&amp;</span><span style=3D"col=
or:rgb(0,0,0)"> std</span><span style=3D"color:rgb(102,102,0)">::</span><sp=
an style=3D"color:rgb(0,0,0)">is_iterator_v</span><span style=3D"color:rgb(=
102,102,0)">&lt;</span><span style=3D"color:rgb(0,0,0)">U</span><span style=
=3D"color:rgb(102,102,0)">&gt;</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(102,102,0)">&amp;&amp;</span><span style=3D"col=
or:rgb(0,0,0)"> std</span><span style=3D"color:rgb(102,102,0)">::</span><sp=
an style=3D"color:rgb(0,0,0)">is_same_v</span><span style=3D"color:rgb(102,=
102,0)">&lt;</span><span style=3D"color:rgb(0,0,0)">T</span><span style=3D"=
color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> U</span><sp=
an style=3D"color:rgb(102,102,0)">&gt;)</span><span style=3D"color:rgb(0,0,=
0)"> </span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"col=
or:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 =C2=A0 =C2=A0 sort_range</span><span style=3D=
"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">t</span><sp=
an style=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)">=
 u</span><span style=3D"color:rgb(102,102,0)">);</span><span style=3D"color=
:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">}=
</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,=
0,136)">else</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"=
color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb=
(0,0,136)">static_assert</span><span style=3D"color:rgb(102,102,0)">(</span=
><span style=3D"color:rgb(0,0,136)">false</span><span style=3D"color:rgb(10=
2,102,0)">);</span><span style=3D"color:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">}=
</span><span style=3D"color:rgb(0,0,0)"><br>
              </span><span style=3D"color:rgb(102,102,0)">}</span></div>
          </code></div>
        <br>
      </div>
    </blockquote>
    Is that `static_assert(false)` well-formed by the current `if
    constexpr` rules? For some reason I assumed that this would follow
    similar rules to [temp.res]/8, i.e. if no valid specialization
    exists for the branch, then it is ill-formed. <br></div></blockquote><d=
iv><br></div></span><div>Oops!=C2=A0 My understanding is that you are 100% =
correct, and I should have written something like <font face=3D"monospace, =
monospace">static_assert(sizeof(T)=3D=3D0)</font> instead.=C2=A0 I think I =
even planned to do that but then forgot to actually <i>do</i> it before hit=
ting &quot;Send&quot;. :)</div></div></div></div></blockquote><div><br></di=
v><div>Well, that&#39;s ill-formed, no diagnostic required, because there c=
an never exist a type T which has size zero. You can do this:</div><div><br=
></div><div><div>template&lt;class T, class U&gt;</div><div>void sort(const=
 T&amp; t, const U&amp; u) {</div><div>=C2=A0 =C2=A0 if constexpr (std::is_=
comparator_v&lt;U&gt; &amp;&amp; std::is_container_v&lt;T&gt;) {</div><div>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 sort_container(t, u);</div><div>=C2=A0 =C2=A0 }=
 else {</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 static_assert(std::is_iterato=
r_v&lt;T&gt; &amp;&amp; std::is_same_v&lt;T, U&gt;);</div><div>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 sort_range(t, u);</div><div>=C2=A0 =C2=A0 }<br></div><div=
>}</div></div><div><br></div><div>... if you can cope with the asymmetry of=
 using &#39;if constexpr&#39; for one case and &#39;static_assert&#39; for =
the other.</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/CAOfiQqmOp93vR8JW62hEL6_wfoB7h2dGeTYk=
tBHueTjNujjEzg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOfiQqmOp93vR8JW=
62hEL6_wfoB7h2dGeTYktBHueTjNujjEzg%40mail.gmail.com</a>.<br />

--001a1141091e70dfde0539a73820--

.


Author: =?UTF-8?Q?=27Bernd_L=C3=B6rwald=27_via_ISO_C=2B=2B_Standard_=2D_Future_Proposal?=
Date: Tue, 9 Aug 2016 20:04:56 +0200
Raw View
> Well, that's ill-formed, no diagnostic required, because there can never exist a type T which has size zero. You can do this:

I guess you could `static_assert (std::is_same_v<T, void>);? That should never be true for f(T const&) and still is dependent on T (so fine in constexpr if), or am I missing something? That would allow to preserve the symmetry.

On a side note, `std::disallow_instantiation<T, U>();` would be an expressive (way more verbose than any static_assert hack). No idea about implementability right there, and after all, this is concepts-lite all over again.

--
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/1A6C6987-69DF-491C-AD38-28B821642D6D%40googlemail.com.

.


Author: "Arthur O'Dwyer" <arthur.j.odwyer@gmail.com>
Date: Tue, 9 Aug 2016 13:43:17 -0700
Raw View
--94eb2c06bee420f1250539a99593
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Tue, Aug 9, 2016 at 10:54 AM, Richard Smith <richard@metafoo.co.uk>
wrote:

> On Tue, Aug 9, 2016 at 1:20 AM, Arthur O'Dwyer <arthur.j.odwyer@gmail.com=
>
> wrote:
>
>> On Tue, Aug 9, 2016 at 12:48 AM, Simon Brand <simon@codeplay.com> wrote:
>>
>>> On 09/08/16 02:24, Arthur O'Dwyer wrote:
>>>
>>> So if I were trying to write the above in C++17, I'd probably write
>>>
>>> template<class T, class U>
>>> void sort(const T& t, const U& u) {
>>>     if constexpr (std::is_comparator_v<U> && std::is_container_v<T>) {
>>>         sort_container(t, u);
>>>     } else if constexpr (std::is_iterator_v<T> && std::is_iterator_v<U>
>>> && std::is_same_v<T, U>) {
>>>         sort_range(t, u);
>>>     } else {
>>>         static_assert(false);
>>>     }
>>> }
>>>
>>> Is that `static_assert(false)` well-formed by the current `if constexpr=
`
>>> rules? For some reason I assumed that this would follow similar rules t=
o
>>> [temp.res]/8, i.e. if no valid specialization exists for the branch, th=
en
>>> it is ill-formed.
>>>
>>
>> Oops!  My understanding is that you are 100% correct, and I should have
>> written something like static_assert(sizeof(T)=3D=3D0) instead.  I think=
 I
>> even planned to do that but then forgot to actually *do* it before
>> hitting "Send". :)
>>
>
> Well, that's ill-formed, no diagnostic required, because there can never
> exist a type T which has size zero. [...]
>

Yikes!  Is that different from the rules for regular templates?  I thought
that *dependent* expressions were never supposed to be evaluated, even in
static_asserts.

Do you have a suggestion of a way to reliably (conformantly) static_assert
falsity in a template and/or if-constexpr context?
That is, I think I'm asking, is there a level of obscurity at which the
ill-formedness disappears and the compiler is *required* to delay
evaluation until instantiation time, or am I just relying on real-world
compilers' willingness to accept my forever-ill-formed code?

For example, what if I wrote

    template<class T> static constexpr bool false_v =3D false;
    template<class X> void foo() {
        static_assert(false_v<X>);
    }

or even

    template<class T> struct false_t { static constexpr bool value =3D fals=
e;
};
    template<class T> static constexpr bool false_v =3D false_t<T>::value;
    template<class X> void foo() {
        static_assert(false_v<X>);
    }

=E2=80=94 is the compiler still allowed to decide that my code is ill-forme=
d?

Also, if you have any special information about Clang's behavior and
possible-future-behavior in this area, I'd love to hear it. I mean, in
practice, in the absence of any other convenient syntax, I'm just going to
keep writing static_assert(sizeof(T)=3D=3D0) unless some popular implementa=
tion
starts rejecting it.

Also, this is related to my CppCon talk, so I'd like to get it right. ;)

Thanks,
=E2=80=93Arthur

--=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/CADvuK0LovEMPRfXgWbiwsdRodQiyShrkPbMgvK7%2BrVTz9=
ueF0Q%40mail.gmail.com.

--94eb2c06bee420f1250539a99593
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Tue, Aug 9, 2016 at 10:54 AM, Richard Smith <span dir=
=3D"ltr">&lt;<a href=3D"mailto:richard@metafoo.co.uk" target=3D"_blank">ric=
hard@metafoo.co.uk</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div=
 class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0p=
x 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);bo=
rder-left-style:solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmai=
l_extra"><div class=3D"gmail_quote"><span class=3D"">On Tue, Aug 9, 2016 at=
 1:20 AM, Arthur O&#39;Dwyer <span dir=3D"ltr">&lt;<a href=3D"mailto:arthur=
..j.odwyer@gmail.com" target=3D"_blank">arthur.j.odwyer@gmail.com</a>&gt;</s=
pan> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p=
x 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-lef=
t-style:solid;padding-left:1ex"><div dir=3D"ltr"><span>On Tue, Aug 9, 2016 =
at 12:48 AM, Simon Brand <span dir=3D"ltr">&lt;<a href=3D"mailto:simon@code=
play.com" target=3D"_blank">simon@codeplay.com</a>&gt;</span> wrote:<br></s=
pan><div class=3D"gmail_extra"><div class=3D"gmail_quote"><span><blockquote=
 class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:=
1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left=
:1ex">
 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div>On 09/08/16 02:24, Arthur O&#39;Dwyer
      wrote:<br>
    </div>
    <blockquote type=3D"cite">
      <div dir=3D"ltr">So if I were trying to write the above in C++17,
        I&#39;d probably write
        <div><br>
        </div>
        <div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-wor=
d;background-color:rgb(250,250,250)"><code>
            <div><span style=3D"color:rgb(0,0,136)">template</span><span st=
yle=3D"color:rgb(102,102,0)">&lt;</span><span style=3D"color:rgb(0,0,136)">=
class</span><span style=3D"color:rgb(0,0,0)"> T</span><span style=3D"color:=
rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><span styl=
e=3D"color:rgb(0,0,136)">class</span><span style=3D"color:rgb(0,0,0)"> U</s=
pan><span style=3D"color:rgb(102,102,0)">&gt;</span><span style=3D"color:rg=
b(0,0,0)"><br>
              </span><span style=3D"color:rgb(0,0,136)">void</span><span st=
yle=3D"color:rgb(0,0,0)"> sort</span><span style=3D"color:rgb(102,102,0)">(=
</span><span style=3D"color:rgb(0,0,136)">const</span><span style=3D"color:=
rgb(0,0,0)"> T</span><span style=3D"color:rgb(102,102,0)">&amp;</span><span=
 style=3D"color:rgb(0,0,0)"> t</span><span style=3D"color:rgb(102,102,0)">,=
</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,=
0,136)">const</span><span style=3D"color:rgb(0,0,0)"> U</span><span style=
=3D"color:rgb(102,102,0)">&amp;</span><span style=3D"color:rgb(0,0,0)"> u</=
span><span style=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(=
0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D=
"color:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">if<=
/span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0=
,136)">constexpr</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">std</spa=
n><span style=3D"color:rgb(102,102,0)">::</span><span style=3D"color:rgb(0,=
0,0)">is_comparator_v</span><span style=3D"color:rgb(102,102,0)">&lt;</span=
><span style=3D"color:rgb(0,0,0)">U</span><span style=3D"color:rgb(102,102,=
0)">&gt;</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"colo=
r:rgb(102,102,0)">&amp;&amp;</span><span style=3D"color:rgb(0,0,0)"> std</s=
pan><span style=3D"color:rgb(102,102,0)">::</span><span style=3D"color:rgb(=
0,0,0)">is_container_v</span><span style=3D"color:rgb(102,102,0)">&lt;</spa=
n><span style=3D"color:rgb(0,0,0)">T</span><span style=3D"color:rgb(102,102=
,0)">&gt;)</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"co=
lor:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 =C2=A0 =C2=A0 sort_container</span><span styl=
e=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">t</span=
><span style=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,=
0)"> u</span><span style=3D"color:rgb(102,102,0)">);</span><span style=3D"c=
olor:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">}=
</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,=
0,136)">else</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"=
color:rgb(0,0,136)">if</span><span style=3D"color:rgb(0,0,0)"> </span><span=
 style=3D"color:rgb(0,0,136)">constexpr</span><span style=3D"color:rgb(0,0,=
0)"> </span><span style=3D"color:rgb(102,102,0)">(</span><span style=3D"col=
or:rgb(0,0,0)">std</span><span style=3D"color:rgb(102,102,0)">::</span><spa=
n style=3D"color:rgb(0,0,0)">is_iterator_v</span><span style=3D"color:rgb(1=
02,102,0)">&lt;</span><span style=3D"color:rgb(0,0,0)">T</span><span style=
=3D"color:rgb(102,102,0)">&gt;</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(102,102,0)">&amp;&amp;</span><span style=3D"col=
or:rgb(0,0,0)"> std</span><span style=3D"color:rgb(102,102,0)">::</span><sp=
an style=3D"color:rgb(0,0,0)">is_iterator_v</span><span style=3D"color:rgb(=
102,102,0)">&lt;</span><span style=3D"color:rgb(0,0,0)">U</span><span style=
=3D"color:rgb(102,102,0)">&gt;</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(102,102,0)">&amp;&amp;</span><span style=3D"col=
or:rgb(0,0,0)"> std</span><span style=3D"color:rgb(102,102,0)">::</span><sp=
an style=3D"color:rgb(0,0,0)">is_same_v</span><span style=3D"color:rgb(102,=
102,0)">&lt;</span><span style=3D"color:rgb(0,0,0)">T</span><span style=3D"=
color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> U</span><sp=
an style=3D"color:rgb(102,102,0)">&gt;)</span><span style=3D"color:rgb(0,0,=
0)"> </span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"col=
or:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 =C2=A0 =C2=A0 sort_range</span><span style=3D=
"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">t</span><sp=
an style=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)">=
 u</span><span style=3D"color:rgb(102,102,0)">);</span><span style=3D"color=
:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">}=
</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,=
0,136)">else</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"=
color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb=
(0,0,136)">static_assert</span><span style=3D"color:rgb(102,102,0)">(</span=
><span style=3D"color:rgb(0,0,136)">false</span><span style=3D"color:rgb(10=
2,102,0)">);</span><span style=3D"color:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">}=
</span><span style=3D"color:rgb(0,0,0)"><br>
              </span><span style=3D"color:rgb(102,102,0)">}</span></div>
          </code></div>
        <br>
      </div>
    </blockquote>
    Is that `static_assert(false)` well-formed by the current `if
    constexpr` rules? For some reason I assumed that this would follow
    similar rules to [temp.res]/8, i.e. if no valid specialization
    exists for the branch, then it is ill-formed. <br></div></blockquote><d=
iv><br></div></span><div>Oops!=C2=A0 My understanding is that you are 100% =
correct, and I should have written something like <font face=3D"monospace, =
monospace">static_assert(sizeof(T)=3D=3D0)</font> instead.=C2=A0 I think I =
even planned to do that but then forgot to actually <i>do</i> it before hit=
ting &quot;Send&quot;. :)</div></div></div></div></blockquote><div><br></di=
v></span><div>Well, that&#39;s ill-formed, no diagnostic required, because =
there can never exist a type T which has size zero. [...]</div></div></div>=
</div></blockquote><div><br></div><div>Yikes!=C2=A0 Is that different from =
the rules for regular templates?=C2=A0 I thought that <i>dependent</i> expr=
essions were never supposed to be evaluated, even in static_asserts.</div><=
div><br></div><div>Do you have a suggestion of a way to reliably (conforman=
tly) static_assert falsity in a template and/or if-constexpr context?</div>=
<div>That is, I think I&#39;m asking, is there a level of obscurity at whic=
h the ill-formedness disappears and the compiler is <i>required</i> to dela=
y evaluation until instantiation time, or am I just relying on real-world c=
ompilers&#39; willingness to accept my forever-ill-formed code?</div><div><=
br></div><div>For example, what if I wrote</div><div><br></div><div><div>=
=C2=A0 =C2=A0 template&lt;class T&gt; static constexpr bool false_v =3D fal=
se;<br></div><div>=C2=A0 =C2=A0 template&lt;class X&gt; void foo() {</div><=
div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 static_assert(false_v&lt;X&gt;);<br></div><=
/div><div>=C2=A0 =C2=A0 }</div><div><br></div><div>or even</div><div><br></=
div><div>=C2=A0 =C2=A0 template&lt;class T&gt; struct false_t { static cons=
texpr bool value =3D false; };</div><div>=C2=A0 =C2=A0 template&lt;class T&=
gt; static constexpr bool false_v =3D false_t&lt;T&gt;::value;</div><div>=
=C2=A0 =C2=A0 template&lt;class X&gt; void foo() {</div><div>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 static_assert(false_v&lt;X&gt;);<br></div><div>=C2=A0 =C2=A0 =
}</div><div><br></div><div>=E2=80=94 is the compiler still allowed to decid=
e that my code is ill-formed?</div><div><br></div><div>Also, if you have an=
y special information about Clang&#39;s behavior and possible-future-behavi=
or in this area, I&#39;d love to hear it. I mean, in practice, in the absen=
ce of any other convenient syntax, I&#39;m just going to keep writing stati=
c_assert(sizeof(T)=3D=3D0) unless some popular implementation starts reject=
ing it.</div><div><br></div><div>Also, this is related to my CppCon talk, s=
o I&#39;d like to get it right. ;)</div><div><br></div><div>Thanks,</div><d=
iv>=E2=80=93Arthur</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/CADvuK0LovEMPRfXgWbiwsdRodQiyShrkPbMg=
vK7%2BrVTz9ueF0Q%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CADvuK0LovEMPRf=
XgWbiwsdRodQiyShrkPbMgvK7%2BrVTz9ueF0Q%40mail.gmail.com</a>.<br />

--94eb2c06bee420f1250539a99593--

.


Author: "'Matt Calabrese' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Tue, 9 Aug 2016 13:55:06 -0700
Raw View
--94eb2c0402146967420539a9bf68
Content-Type: text/plain; charset=UTF-8

On Tue, Aug 9, 2016 at 1:43 PM, Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
wrote:
>
> Yikes!  Is that different from the rules for regular templates?  I thought
> that *dependent* expressions were never supposed to be evaluated, even in
> static_asserts.
>

That's true for all templates. It's not that the dependent expression is
*evaluated*, it's that for a given template definition, it must be possible
to form a valid instantiation. I've used an "always_false" for this,
similar to your false_v, and I *believe* that is a valid way to do this
because it's possible for "always_false" to have some specialization for
which it is actually true, even though by convention you'd never use a
specialization does.

--
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/CANh8DEm%3D_Z9xtUH4-rO_YrnNF80uE17Xwxz3V46Zn0cAdgYiig%40mail.gmail.com.

--94eb2c0402146967420539a9bf68
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
ue, Aug 9, 2016 at 1:43 PM, Arthur O&#39;Dwyer <span dir=3D"ltr">&lt;<a hre=
f=3D"mailto:arthur.j.odwyer@gmail.com" target=3D"_blank">arthur.j.odwyer@gm=
ail.com</a>&gt;</span> wrote:<blockquote class=3D"gmail_quote" style=3D"mar=
gin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr=
"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div>Yikes!=C2=A0 I=
s that different from the rules for regular templates?=C2=A0 I thought that=
 <i>dependent</i> expressions were never supposed to be evaluated, even in =
static_asserts.</div></div></div></div></blockquote><div><br></div><div>Tha=
t&#39;s true for all templates. It&#39;s not that the dependent expression =
is *evaluated*, it&#39;s that for a given template definition, it must be p=
ossible to form a valid instantiation. I&#39;ve used an &quot;always_false&=
quot; for this, similar to your false_v, and I *believe* that is a valid wa=
y to do this because it&#39;s possible for &quot;always_false&quot; to have=
 some specialization for which it is actually true, even though by conventi=
on you&#39;d never use a specialization does.</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/CANh8DEm%3D_Z9xtUH4-rO_YrnNF80uE17Xwx=
z3V46Zn0cAdgYiig%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANh8DEm%3D_Z9x=
tUH4-rO_YrnNF80uE17Xwxz3V46Zn0cAdgYiig%40mail.gmail.com</a>.<br />

--94eb2c0402146967420539a9bf68--

.


Author: Richard Smith <richard@metafoo.co.uk>
Date: Tue, 9 Aug 2016 16:09:53 -0700
Raw View
--001a1141287e6ebe540539aba1fa
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Tue, Aug 9, 2016 at 1:43 PM, Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
wrote:

> On Tue, Aug 9, 2016 at 10:54 AM, Richard Smith <richard@metafoo.co.uk>
> wrote:
>
>> On Tue, Aug 9, 2016 at 1:20 AM, Arthur O'Dwyer <arthur.j.odwyer@gmail.co=
m
>> > wrote:
>>
>>> On Tue, Aug 9, 2016 at 12:48 AM, Simon Brand <simon@codeplay.com> wrote=
:
>>>
>>>> On 09/08/16 02:24, Arthur O'Dwyer wrote:
>>>>
>>>> So if I were trying to write the above in C++17, I'd probably write
>>>>
>>>> template<class T, class U>
>>>> void sort(const T& t, const U& u) {
>>>>     if constexpr (std::is_comparator_v<U> && std::is_container_v<T>) {
>>>>         sort_container(t, u);
>>>>     } else if constexpr (std::is_iterator_v<T> && std::is_iterator_v<U=
>
>>>> && std::is_same_v<T, U>) {
>>>>         sort_range(t, u);
>>>>     } else {
>>>>         static_assert(false);
>>>>     }
>>>> }
>>>>
>>>> Is that `static_assert(false)` well-formed by the current `if
>>>> constexpr` rules? For some reason I assumed that this would follow sim=
ilar
>>>> rules to [temp.res]/8, i.e. if no valid specialization exists for the
>>>> branch, then it is ill-formed.
>>>>
>>>
>>> Oops!  My understanding is that you are 100% correct, and I should have
>>> written something like static_assert(sizeof(T)=3D=3D0) instead.  I thin=
k I
>>> even planned to do that but then forgot to actually *do* it before
>>> hitting "Send". :)
>>>
>>
>> Well, that's ill-formed, no diagnostic required, because there can never
>> exist a type T which has size zero. [...]
>>
>
> Yikes!  Is that different from the rules for regular templates?  I though=
t
> that *dependent* expressions were never supposed to be evaluated, even in
> static_asserts.
>
> Do you have a suggestion of a way to reliably (conformantly) static_asser=
t
> falsity in a template and/or if-constexpr context?
> That is, I think I'm asking, is there a level of obscurity at which the
> ill-formedness disappears and the compiler is *required* to delay
> evaluation until instantiation time, or am I just relying on real-world
> compilers' willingness to accept my forever-ill-formed code?
>
> For example, what if I wrote
>
>     template<class T> static constexpr bool false_v =3D false;
>     template<class X> void foo() {
>         static_assert(false_v<X>);
>     }
>
> or even
>
>     template<class T> struct false_t { static constexpr bool value =3D
> false; };
>     template<class T> static constexpr bool false_v =3D false_t<T>::value=
;
>     template<class X> void foo() {
>         static_assert(false_v<X>);
>     }
>
> =E2=80=94 is the compiler still allowed to decide that my code is ill-for=
med?
>

In the abstract, it's not completely clear what the standard means when it
talks about there being no valid specializations of a template -- does the
it mean that there could exist no program that uses this template and has a
valid specialization, or only that no valid specialization can be generated
given the other declarations in the current program, or even that the
program does not in fact cause the instantiation of a valid specialization?
In practice, implementations assume the first option, and that appears to
be what users expect as well, so I wouldn't expect that to change any time
soon in any reasonable implementation.

Assuming we do take the "no program could exist that contains this template
and manages to instantiate it" interpretation, the above examples both look
valid to me.

Also, if you have any special information about Clang's behavior and
> possible-future-behavior in this area, I'd love to hear it. I mean, in
> practice, in the absence of any other convenient syntax, I'm just going t=
o
> keep writing static_assert(sizeof(T)=3D=3D0) unless some popular implemen=
tation
> starts rejecting it.
>

You're certainly not the only one doing that :) In principle, it would be
relatively easy to teach Clang to constant-fold the above expression to
false, but (a) this would only harm our users, so we would be pretty
strongly opposed to doing it, and (b) as an extension we do have some types
with size zero, so it wouldn't even be correct.

Also, this is related to my CppCon talk, so I'd like to get it right. ;)
>
> Thanks,
> =E2=80=93Arthur
>
> --
> 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/CADvuK0LovEMPRfXgWbiwsdRodQiyS
> hrkPbMgvK7%2BrVTz9ueF0Q%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CADvuK0LovE=
MPRfXgWbiwsdRodQiyShrkPbMgvK7%2BrVTz9ueF0Q%40mail.gmail.com?utm_medium=3Dem=
ail&utm_source=3Dfooter>
> .
>

--=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/CAOfiQq%3DcHMzbYjS74bh6Yog%2BXZVCevZOwRVYbAGXH-q=
ROyHUxw%40mail.gmail.com.

--001a1141287e6ebe540539aba1fa
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
ue, Aug 9, 2016 at 1:43 PM, Arthur O&#39;Dwyer <span dir=3D"ltr">&lt;<a hre=
f=3D"mailto:arthur.j.odwyer@gmail.com" target=3D"_blank">arthur.j.odwyer@gm=
ail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D=
"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D=
"ltr"><span class=3D"">On Tue, Aug 9, 2016 at 10:54 AM, Richard Smith <span=
 dir=3D"ltr">&lt;<a href=3D"mailto:richard@metafoo.co.uk" target=3D"_blank"=
>richard@metafoo.co.uk</a>&gt;</span> wrote:<br></span><div class=3D"gmail_=
extra"><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(20=
4,204,204);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr"><div =
class=3D"gmail_extra"><div class=3D"gmail_quote"><span class=3D""><span>On =
Tue, Aug 9, 2016 at 1:20 AM, Arthur O&#39;Dwyer <span dir=3D"ltr">&lt;<a hr=
ef=3D"mailto:arthur.j.odwyer@gmail.com" target=3D"_blank">arthur.j.odwyer@g=
mail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(20=
4,204,204);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr"><span=
>On Tue, Aug 9, 2016 at 12:48 AM, Simon Brand <span dir=3D"ltr">&lt;<a href=
=3D"mailto:simon@codeplay.com" target=3D"_blank">simon@codeplay.com</a>&gt;=
</span> wrote:<br></span><div class=3D"gmail_extra"><div class=3D"gmail_quo=
te"><span><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8=
ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-sty=
le:solid;padding-left:1ex">
 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div>On 09/08/16 02:24, Arthur O&#39;Dwyer
      wrote:<br>
    </div>
    <blockquote type=3D"cite">
      <div dir=3D"ltr">So if I were trying to write the above in C++17,
        I&#39;d probably write
        <div><br>
        </div>
        <div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-wor=
d;background-color:rgb(250,250,250)"><code>
            <div><span style=3D"color:rgb(0,0,136)">template</span><span st=
yle=3D"color:rgb(102,102,0)">&lt;</span><span style=3D"color:rgb(0,0,136)">=
class</span><span style=3D"color:rgb(0,0,0)"> T</span><span style=3D"color:=
rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><span styl=
e=3D"color:rgb(0,0,136)">class</span><span style=3D"color:rgb(0,0,0)"> U</s=
pan><span style=3D"color:rgb(102,102,0)">&gt;</span><span style=3D"color:rg=
b(0,0,0)"><br>
              </span><span style=3D"color:rgb(0,0,136)">void</span><span st=
yle=3D"color:rgb(0,0,0)"> sort</span><span style=3D"color:rgb(102,102,0)">(=
</span><span style=3D"color:rgb(0,0,136)">const</span><span style=3D"color:=
rgb(0,0,0)"> T</span><span style=3D"color:rgb(102,102,0)">&amp;</span><span=
 style=3D"color:rgb(0,0,0)"> t</span><span style=3D"color:rgb(102,102,0)">,=
</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,=
0,136)">const</span><span style=3D"color:rgb(0,0,0)"> U</span><span style=
=3D"color:rgb(102,102,0)">&amp;</span><span style=3D"color:rgb(0,0,0)"> u</=
span><span style=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(=
0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D=
"color:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">if<=
/span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0=
,136)">constexpr</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">std</spa=
n><span style=3D"color:rgb(102,102,0)">::</span><span style=3D"color:rgb(0,=
0,0)">is_comparator_v</span><span style=3D"color:rgb(102,102,0)">&lt;</span=
><span style=3D"color:rgb(0,0,0)">U</span><span style=3D"color:rgb(102,102,=
0)">&gt;</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"colo=
r:rgb(102,102,0)">&amp;&amp;</span><span style=3D"color:rgb(0,0,0)"> std</s=
pan><span style=3D"color:rgb(102,102,0)">::</span><span style=3D"color:rgb(=
0,0,0)">is_container_v</span><span style=3D"color:rgb(102,102,0)">&lt;</spa=
n><span style=3D"color:rgb(0,0,0)">T</span><span style=3D"color:rgb(102,102=
,0)">&gt;)</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"co=
lor:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 =C2=A0 =C2=A0 sort_container</span><span styl=
e=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">t</span=
><span style=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,=
0)"> u</span><span style=3D"color:rgb(102,102,0)">);</span><span style=3D"c=
olor:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">}=
</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,=
0,136)">else</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"=
color:rgb(0,0,136)">if</span><span style=3D"color:rgb(0,0,0)"> </span><span=
 style=3D"color:rgb(0,0,136)">constexpr</span><span style=3D"color:rgb(0,0,=
0)"> </span><span style=3D"color:rgb(102,102,0)">(</span><span style=3D"col=
or:rgb(0,0,0)">std</span><span style=3D"color:rgb(102,102,0)">::</span><spa=
n style=3D"color:rgb(0,0,0)">is_iterator_v</span><span style=3D"color:rgb(1=
02,102,0)">&lt;</span><span style=3D"color:rgb(0,0,0)">T</span><span style=
=3D"color:rgb(102,102,0)">&gt;</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(102,102,0)">&amp;&amp;</span><span style=3D"col=
or:rgb(0,0,0)"> std</span><span style=3D"color:rgb(102,102,0)">::</span><sp=
an style=3D"color:rgb(0,0,0)">is_iterator_v</span><span style=3D"color:rgb(=
102,102,0)">&lt;</span><span style=3D"color:rgb(0,0,0)">U</span><span style=
=3D"color:rgb(102,102,0)">&gt;</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(102,102,0)">&amp;&amp;</span><span style=3D"col=
or:rgb(0,0,0)"> std</span><span style=3D"color:rgb(102,102,0)">::</span><sp=
an style=3D"color:rgb(0,0,0)">is_same_v</span><span style=3D"color:rgb(102,=
102,0)">&lt;</span><span style=3D"color:rgb(0,0,0)">T</span><span style=3D"=
color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> U</span><sp=
an style=3D"color:rgb(102,102,0)">&gt;)</span><span style=3D"color:rgb(0,0,=
0)"> </span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"col=
or:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 =C2=A0 =C2=A0 sort_range</span><span style=3D=
"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">t</span><sp=
an style=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)">=
 u</span><span style=3D"color:rgb(102,102,0)">);</span><span style=3D"color=
:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">}=
</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,=
0,136)">else</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"=
color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb=
(0,0,136)">static_assert</span><span style=3D"color:rgb(102,102,0)">(</span=
><span style=3D"color:rgb(0,0,136)">false</span><span style=3D"color:rgb(10=
2,102,0)">);</span><span style=3D"color:rgb(0,0,0)"><br>
                =C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">}=
</span><span style=3D"color:rgb(0,0,0)"><br>
              </span><span style=3D"color:rgb(102,102,0)">}</span></div>
          </code></div>
        <br>
      </div>
    </blockquote>
    Is that `static_assert(false)` well-formed by the current `if
    constexpr` rules? For some reason I assumed that this would follow
    similar rules to [temp.res]/8, i.e. if no valid specialization
    exists for the branch, then it is ill-formed. <br></div></blockquote><d=
iv><br></div></span><div>Oops!=C2=A0 My understanding is that you are 100% =
correct, and I should have written something like <font face=3D"monospace, =
monospace">static_assert(sizeof(T)=3D=3D0)</font> instead.=C2=A0 I think I =
even planned to do that but then forgot to actually <i>do</i> it before hit=
ting &quot;Send&quot;. :)</div></div></div></div></blockquote><div><br></di=
v></span></span><div>Well, that&#39;s ill-formed, no diagnostic required, b=
ecause there can never exist a type T which has size zero. [...]</div></div=
></div></div></blockquote><div><br></div><div>Yikes!=C2=A0 Is that differen=
t from the rules for regular templates?=C2=A0 I thought that <i>dependent</=
i> expressions were never supposed to be evaluated, even in static_asserts.=
</div><div><br></div><div>Do you have a suggestion of a way to reliably (co=
nformantly) static_assert falsity in a template and/or if-constexpr context=
?</div><div>That is, I think I&#39;m asking, is there a level of obscurity =
at which the ill-formedness disappears and the compiler is <i>required</i> =
to delay evaluation until instantiation time, or am I just relying on real-=
world compilers&#39; willingness to accept my forever-ill-formed code?</div=
><div><br></div><div>For example, what if I wrote</div><div><br></div><div>=
<div>=C2=A0 =C2=A0 template&lt;class T&gt; static constexpr bool false_v =
=3D false;<br></div><div>=C2=A0 =C2=A0 template&lt;class X&gt; void foo() {=
</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 static_assert(false_v&lt;X&gt;);<br>=
</div></div><div>=C2=A0 =C2=A0 }</div><div><br></div><div>or even</div><div=
><br></div><div>=C2=A0 =C2=A0 template&lt;class T&gt; struct false_t { stat=
ic constexpr bool value =3D false; };</div><div>=C2=A0 =C2=A0 template&lt;c=
lass T&gt; static constexpr bool false_v =3D false_t&lt;T&gt;::value;</div>=
<div>=C2=A0 =C2=A0 template&lt;class X&gt; void foo() {</div><div>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 static_assert(false_v&lt;X&gt;);<br></div><div>=C2=A0 =
=C2=A0 }</div><div><br></div><div>=E2=80=94 is the compiler still allowed t=
o decide that my code is ill-formed?</div></div></div></div></blockquote><d=
iv><br></div><div>In the abstract, it&#39;s not completely clear what the s=
tandard means when it talks about there being no valid specializations of a=
 template -- does the it mean that there could exist no program that uses t=
his template and has a valid specialization, or only that no valid speciali=
zation can be generated given the other declarations in the current program=
, or even that the program does not in fact cause the instantiation of a va=
lid specialization? In practice, implementations assume the first option, a=
nd that appears to be what users expect as well, so I wouldn&#39;t expect t=
hat to change any time soon in any reasonable implementation.</div><div><br=
></div><div>Assuming we do take the &quot;no program could exist that conta=
ins this template and manages to instantiate it&quot; interpretation, the a=
bove examples both look valid to me.</div><div><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"><div class=3D"gmail_extra"><div class=3D"gma=
il_quote"><div>Also, if you have any special information about Clang&#39;s =
behavior and possible-future-behavior in this area, I&#39;d love to hear it=
.. I mean, in practice, in the absence of any other convenient syntax, I&#39=
;m just going to keep writing static_assert(sizeof(T)=3D=3D0) unless some p=
opular implementation starts rejecting it.</div></div></div></div></blockqu=
ote><div><br></div><div>You&#39;re certainly not the only one doing that :)=
 In principle, it would be relatively easy to teach Clang to constant-fold =
the above expression to false, but (a) this would only harm our users, so w=
e would be pretty strongly opposed to doing it, and (b) as an extension we =
do have some types with size zero, so it wouldn&#39;t even be correct.</div=
><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8e=
x;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=
=3D"gmail_extra"><div class=3D"gmail_quote"><div>Also, this is related to m=
y CppCon talk, so I&#39;d like to get it right. ;)</div><div><br></div><div=
>Thanks,</div><div>=E2=80=93Arthur</div></div></div></div><span class=3D"">

<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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CADvuK0LovEMPRfXgWbiwsdRodQiyShrkPbMg=
vK7%2BrVTz9ueF0Q%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoote=
r" target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/st=
d-<wbr>proposals/<wbr>CADvuK0LovEMPRfXgWbiwsdRodQiyS<wbr>hrkPbMgvK7%2BrVTz9=
ueF0Q%<wbr>40mail.gmail.com</a>.<br>
</blockquote></div><br></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/CAOfiQq%3DcHMzbYjS74bh6Yog%2BXZVCevZO=
wRVYbAGXH-qROyHUxw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOfiQq%3DcHM=
zbYjS74bh6Yog%2BXZVCevZOwRVYbAGXH-qROyHUxw%40mail.gmail.com</a>.<br />

--001a1141287e6ebe540539aba1fa--

.


Author: Victor Dyachenko <victor.dyachenko@gmail.com>
Date: Tue, 9 Aug 2016 22:40:12 -0700 (PDT)
Raw View
------=_Part_345_1090895355.1470807612594
Content-Type: multipart/alternative;
 boundary="----=_Part_346_1401009340.1470807612595"

------=_Part_346_1401009340.1470807612595
Content-Type: text/plain; charset=UTF-8

On Tuesday, August 9, 2016 at 11:43:19 PM UTC+3, Arthur O'Dwyer wrote:
>
>
> Do you have a suggestion of a way to reliably (conformantly) static_assert
> falsity in a template and/or if-constexpr context?
>
> static_assert((T *) 0);
for type template argument or
static_assert(V != V);
For (most?) non-type arguments.

--
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/e1057dd5-80dc-49e8-8d63-389a7d154494%40isocpp.org.

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

<div dir=3D"ltr">On Tuesday, August 9, 2016 at 11:43:19 PM UTC+3, Arthur O&=
#39;Dwyer 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"><span></span><div class=3D"gmail_quote"><br><div>Do you have a suggestio=
n of a way to reliably (conformantly) static_assert falsity in a template a=
nd/or if-constexpr context?</div><br></div></div></blockquote><div><div cla=
ss=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-co=
lor: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap:=
 break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">static_assert</span>=
<span 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"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: #066;" clas=
s=3D"styled-by-prettify">0</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">);</span></div></code></div>for type template argument or <=
br><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"subprett=
yprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">static_as=
sert</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">V </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">!=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> V</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">);</span></div></code></div>For (mos=
t?) non-type arguments.<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&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/e1057dd5-80dc-49e8-8d63-389a7d154494%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/e1057dd5-80dc-49e8-8d63-389a7d154494=
%40isocpp.org</a>.<br />

------=_Part_346_1401009340.1470807612595--

------=_Part_345_1090895355.1470807612594--

.


Author: Richard Smith <richard@metafoo.co.uk>
Date: Wed, 10 Aug 2016 13:31:58 -0700
Raw View
--001a11400ee689f2c60539bd8a86
Content-Type: text/plain; charset=UTF-8

On Tue, Aug 9, 2016 at 10:40 PM, Victor Dyachenko <
victor.dyachenko@gmail.com> wrote:

> On Tuesday, August 9, 2016 at 11:43:19 PM UTC+3, Arthur O'Dwyer wrote:
>>
>>
>> Do you have a suggestion of a way to reliably (conformantly)
>> static_assert falsity in a template and/or if-constexpr context?
>>
>> static_assert((T *) 0);
> for type template argument or
> static_assert(V != V);
> For (most?) non-type arguments.
>

Again, this takes you to ill-formed (no diagnostic required), at least in
the first case, because there are no instantiations where the static_assert
does not fire. (For the second case, I suppose it would depend on whether V
could be NaN.)

--
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/CAOfiQqm5D3Ppy5cjCRFs%2BG%3DOxTt3SfzqxDz8s_40P2AnTeuJzQ%40mail.gmail.com.

--001a11400ee689f2c60539bd8a86
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
ue, Aug 9, 2016 at 10:40 PM, Victor Dyachenko <span dir=3D"ltr">&lt;<a href=
=3D"mailto:victor.dyachenko@gmail.com" target=3D"_blank">victor.dyachenko@g=
mail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"ltr"><span class=3D"">On Tuesday, August 9, 2016 at 11:43:19 PM UTC+3, =
Arthur O&#39;Dwyer 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"ltr"><span></span><div class=3D"gmail_quote"><br><div>Do you have a sug=
gestion of a way to reliably (conformantly) static_assert falsity in a temp=
late and/or if-constexpr context?</div><br></div></div></blockquote></span>=
<div><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,1=
87,187);border-style:solid;border-width:1px;word-wrap:break-word"><code><di=
v><span style=3D"color:#008">static_assert</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:#066">0</spa=
n><span style=3D"color:#660">);</span></div></code></div>for type template =
argument or <br><div style=3D"background-color:rgb(250,250,250);border-colo=
r:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word=
"><code><div><span style=3D"color:#008">static_assert</span><span style=3D"=
color:#660">(</span><span style=3D"color:#000">V </span><span style=3D"colo=
r:#660">!=3D</span><span style=3D"color:#000"> V</span><span style=3D"color=
:#660">);</span></div></code></div>For (most?) non-type arguments.</div></d=
iv></blockquote><div><br></div><div>Again, this takes you to ill-formed (no=
 diagnostic required), at least in the first case, because there are no ins=
tantiations where the static_assert does not fire. (For the second case, I =
suppose it would depend on whether V could be NaN.)=C2=A0</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/CAOfiQqm5D3Ppy5cjCRFs%2BG%3DOxTt3Sfzq=
xDz8s_40P2AnTeuJzQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOfiQqm5D3Pp=
y5cjCRFs%2BG%3DOxTt3SfzqxDz8s_40P2AnTeuJzQ%40mail.gmail.com</a>.<br />

--001a11400ee689f2c60539bd8a86--

.


Author: Edward Catmur <ed@catmur.co.uk>
Date: Wed, 10 Aug 2016 16:13:59 -0700 (PDT)
Raw View
------=_Part_27_1299926109.1470870840066
Content-Type: text/plain; charset=UTF-8

A non-type template parameter can't be NaN; floating point isn't allowed.

I usually write something like static_assert(!std::conditional_t<true, std::false_type, T>::value). Although might that be considered ill formed NDR on the basis that a conforming implementation could hard code std::conditional?

One needs something where a specialization conceivably could exist to make a predicate true, even though actually none do exist.

--
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/c13d7556-db08-46a6-9f95-dee9b7ece888%40isocpp.org.

------=_Part_27_1299926109.1470870840066--

.


Author: "T. C." <rs2740@gmail.com>
Date: Thu, 11 Aug 2016 01:32:15 -0700 (PDT)
Raw View
------=_Part_320_737325011.1470904335582
Content-Type: multipart/alternative;
 boundary="----=_Part_321_382664268.1470904335583"

------=_Part_321_382664268.1470904335583
Content-Type: text/plain; charset=UTF-8



On Wednesday, August 10, 2016 at 7:14:00 PM UTC-4, Edward Catmur wrote:
>
> A non-type template parameter can't be NaN; floating point isn't allowed.


const double& is, though.


> I usually write something like static_assert(!std::conditional_t<true,
> std::false_type, T>::value). Although might that be considered ill formed
> NDR on the basis that a conforming implementation could hard code
> std::conditional?
>

I think so. There's blanket wording banning user specializations of
std::conditional (along with everything else in <type_traits> except
common_type), so a sufficiently clever implementation should be able to
determine that the condition can never be true.


> One needs something where a specialization conceivably could exist to make
> a predicate true, even though actually none do exist.
>
>

--
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/d4acfffe-12f1-42c9-98f6-bf3d1ba44919%40isocpp.org.

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

<div dir=3D"ltr"><br><br>On Wednesday, August 10, 2016 at 7:14:00 PM UTC-4,=
 Edward Catmur wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">A non-typ=
e template parameter can&#39;t be NaN; floating point isn&#39;t allowed.</b=
lockquote><div><br></div><div><div>const double&amp; is, though.</div></div=
><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><p>I usually=
 write something like static_assert(!std::<wbr>conditional_t&lt;true, std::=
false_type, T&gt;::value). Although might that be considered ill formed NDR=
 on the basis that a conforming implementation could hard code std::conditi=
onal?</p></blockquote><div><br>I think so. There&#39;s blanket wording bann=
ing user specializations of std::conditional (along with everything else in=
 &lt;type_traits&gt; except common_type), so a sufficiently clever implemen=
tation should be able to determine that the condition can never be true.</d=
iv><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><p>One nee=
ds something where a specialization conceivably could exist to make a predi=
cate true, even though actually none do exist.</p><p></p></blockquote></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/d4acfffe-12f1-42c9-98f6-bf3d1ba44919%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d4acfffe-12f1-42c9-98f6-bf3d1ba44919=
%40isocpp.org</a>.<br />

------=_Part_321_382664268.1470904335583--

------=_Part_320_737325011.1470904335582--

.