Topic: Minor generalization of void_t


Author: Louis Dionne <ldionne.2@gmail.com>
Date: Tue, 7 Oct 2014 07:57:53 -0700 (PDT)
Raw View
------=_Part_15_115468468.1412693873169
Content-Type: text/plain; charset=UTF-8

Hi,

I'd like to float around the idea of a replacement for the `void_t` utility
that was proposed in N3911
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3911.pdf>. Here's
an excerpt from the paper I'm writing:

------------------------------------------------------------------------------

Introduction
=============================

This proposal adds two utilities, `when` and `when_valid`, that can be used
to
partially specialize templates based on a compile-time condition and on the
validity of an expression, respectively.


Motivation and Scope
=============================

N3911 proposes adding an alias template named `void_t`, which can be used
to partially specialize a template based on the validity of an expression.
However, to partially specialize a template based on a compile-time
condition,
one has to use `enable_if` in conjunction with `void_t`. This proposal is a
minor generalization of `void_t` allowing both use cases without resorting
to
`enable_if`.

Some questions regarding the name of `void_t` had also been raised in
N3911; this proposal also aims to resolve those issues.

Specifically, the intended usage of `void_t` is as follows:

template <typename, typename = void>
struct has_type_member : false_type { };

template <typename T>
struct has_type_member<T, void_t<typename T::type>>
    : true_type
{ };


However, if one wants to enable `has_type_member` based on a compile-time
condition, one has to use `enable_if`:

template <typename, typename = void>
struct has_type_member : false_type { };

template <typename T>
struct has_type_member<T, void_t<enable_if_t<SomePredicate<T>::value>>>
    : true_type
{ };


This is more complicated than it needs to be. This paper proposes adding the
following utilities to the `std` namespace:

template <bool>
struct when;

template <typename ...>
using when_valid = when<true>;


With these utilities, one can still partially specialize `has_type_member`
based on the validity of an expression as follows:

template <typename, typename = when<true>>
struct has_type_member : false_type { };

template <typename T>
struct has_type_member<T, when_valid<typename T::type>>
    : true_type
{ };


But it is now easier to partially specialize `has_type_member` based on a
compile-time condition:

template <typename, typename = when<true>>
struct has_type_member : false_type { };

template <typename T>
struct has_type_member<T, when<SomePredicate<T>::value>>
    : true_type
{ };


------------------------------------------------------------------------------

The full paper (which is not much longer really) is available at:

https://gist.github.com/ldionne/22aa85bbe10d51fff585

This is my first time writing anything related to the standard; comments and
improvements of all sorts are very much welcome.

Louis

--

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

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

<div dir=3D"ltr"><div><div>Hi,&nbsp;</div><div><br></div><div>I'd like to f=
loat around the idea of a replacement for the `void_t` utility</div><div>th=
at was proposed in <a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/p=
apers/2014/n3911.pdf">N3911</a>. Here's an excerpt from the paper I'm writi=
ng:</div><div><br></div><div>----------------------------------------------=
--------------------------------</div><div><br></div><div>Introduction</div=
><div>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D</div><div><br></div><div>This proposal adds two utilitie=
s, `when` and `when_valid`, that can be used to</div><div>partially special=
ize templates based on a compile-time condition and on the</div><div>validi=
ty of an expression, respectively.</div><div><br></div><div><br></div><div>=
Motivation and Scope</div><div>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</div><div><br></div><div>N391=
1 proposes adding an alias template named `void_t`, which can be used</div>=
<div>to partially specialize a template based on the validity of an express=
ion.</div><div>However, to partially specialize a template based on a compi=
le-time condition,</div><div>one has to use `enable_if` in conjunction with=
 `void_t`. This proposal is a</div><div>minor generalization of `void_t` al=
lowing both use cases without resorting to</div><div>`enable_if`.</div><div=
><br></div><div>Some questions regarding the name of `void_t` had also been=
 raised in</div><div>N3911; this proposal also aims to resolve those issues=
..</div><div><br></div><div>Specifically, the intended usage of `void_t` is =
as follows:</div><div><br></div><div class=3D"prettyprint" style=3D"backgro=
und-color: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-w=
rap: 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 styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"col=
or: #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">typename</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">v=
oid</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">struct</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> has_type_member </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> false_type </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">typename</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> has_type_member<=
/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 sty=
le=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> void_t</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">typename</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">type</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">&gt;&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>&nbsp; &nbsp; </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> true_type<br></span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><=
/div></code></div><div><br></div><div><br></div><div>However, if one wants =
to enable `has_type_member` based on a compile-time</div><div>condition, on=
e has to use `enable_if`:</div><div><br></div><div class=3D"prettyprint" st=
yle=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"s=
ubprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">te=
mplate</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><spa=
n 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">typename</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">void</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">struct<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> has_type_m=
ember </span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> false_type <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</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"colo=
r: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color:=
 #008;" class=3D"styled-by-prettify">template</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">typename</span><span style=3D"color: #000;" class=3D"st=
yled-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-pretti=
fy"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">st=
ruct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> has_t=
ype_member</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&lt;</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 s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> void_t</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">enable_if_t</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color:=
 #606;" class=3D"styled-by-prettify">SomePredicate</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">T</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">&gt;::</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">value</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&gt;&gt;&gt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> true_type<br></span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">};</span></div></code></div><div><br></div><div><br></div><div>This is m=
ore complicated than it needs to be. This paper proposes adding the</div><d=
iv>following utilities to the `std` namespace:</div><div><br></div><div cla=
ss=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border: 1=
px solid rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"prettyp=
rint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">template</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-pr=
ettify">&lt;bool&gt;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">when</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><br></span><span sty=
le=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">typename</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">...&gt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">using</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> when_valid </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">when</s=
pan><span style=3D"color: #080;" class=3D"styled-by-prettify">&lt;true&gt;<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span></d=
iv></code></div><div><br></div><div><br></div><div>With these utilities, on=
e can still partially specialize `has_type_member`</div><div>based on the v=
alidity of an expression as follows:</div><div><br></div><div class=3D"pret=
typrint" style=3D"background-color: rgb(250, 250, 250); border: 1px solid r=
gb(187, 187, 187); word-wrap: break-word;"><code class=3D"prettyprint"><div=
 class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">template</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&l=
t;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">typename=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">when</span><span style=3D"color: #080;" class=3D"st=
yled-by-prettify">&lt;true&gt;</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-pr=
ettify">struct</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> has_type_member </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> false_type </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><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 s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">template</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">struct</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> has_type_member</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> when_vali=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">type</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">&gt;&gt;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> true_type<br></span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">};</span></div></code></div><div><br></div><div><br></di=
v><div>But it is now easier to partially specialize `has_type_member` based=
 on a</div><div>compile-time condition:</div><div><br></div><div class=3D"p=
rettyprint" style=3D"background-color: rgb(250, 250, 250); border: 1px soli=
d rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"prettyprint"><=
div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-b=
y-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">typen=
ame</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">when</span><span style=3D"color: #080;" class=3D"st=
yled-by-prettify">&lt;true&gt;</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-pr=
ettify">struct</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> has_type_member </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> false_type </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><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: #000;" class=3D"styled-by-prettify"><br></span><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">typename</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styl=
ed-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-pretti=
fy">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 has_type_member</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&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"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">when</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: =
#606;" class=3D"styled-by-prettify">SomePredicate</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #00=
0;" 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">value</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&gt;&gt;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> true_type<br></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></div></code></div><div><br></div><div><br></div><div>--------------=
----------------------------------------------------------------</div><div>=
<br></div><div>The full paper (which is not much longer really) is availabl=
e at:</div><div><br></div><div><span class=3D"Apple-tab-span" style=3D"whit=
e-space:pre"> </span>https://gist.github.com/ldionne/22aa85bbe10d51fff585</=
div><div><br></div><div>This is my first time writing anything related to t=
he standard; comments and</div><div>improvements of all sorts are very much=
 welcome.</div><div><br></div><div>Louis</div></div><div><br></div></div>

<p></p>

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

------=_Part_15_115468468.1412693873169--

.


Author: Casey Carter <cartec69@gmail.com>
Date: Tue, 7 Oct 2014 19:13:12 -0700 (PDT)
Raw View
------=_Part_257_51388410.1412734392601
Content-Type: text/plain; charset=UTF-8

On Tuesday, October 7, 2014 9:57:53 AM UTC-5, Louis Dionne wrote:
>
> However, if one wants to enable `has_type_member` based on a compile-time
> condition, one has to use `enable_if`:
>
> template <typename, typename = void>
> struct has_type_member : false_type { };
>
> template <typename T>
> struct has_type_member<T, void_t<enable_if_t<SomePredicate<T>::value>>>
>     : true_type
> { };
>
>
One does not wrap void_t around enable_if_t, one simply uses enable_if_t
directly:

template <typename, typename = void>
struct has_type_member : false_type { };

template <typename T>
struct has_type_member<T, enable_if_t<SomePredicate<T>::value>>
    : true_type
{ };

Your approach seems to have the effect of simply renaming:

   - void is relabeled when<true>
   - void_t is relabeled when_valid
   - enable_if_t is relabeled when

Except of course that when does not optionally accept a type to which it
resolves like enable_if_t does. Am I missing something?

--

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

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

<div dir=3D"ltr">On Tuesday, October 7, 2014 9:57:53 AM UTC-5, Louis Dionne=
 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"><div><=
div><span style=3D"font-size: 13px;">However, if one wants to enable `has_t=
ype_member` based on a compile-time</span><br></div><div>condition, one has=
 to use `enable_if`:</div><div><br></div><div style=3D"background-color:rgb=
(250,250,250);border:1px solid rgb(187,187,187);word-wrap:break-word"><code=
><div><span style=3D"color:#008">template</span><span style=3D"color:#000">=
 </span><span style=3D"color:#660">&lt;</span><span style=3D"color:#008">ty=
pename</span><span style=3D"color:#660">,</span><span style=3D"color:#000">=
 </span><span style=3D"color:#008">typename</span><span style=3D"color:#000=
"> </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> =
</span><span style=3D"color:#008">void</span><span style=3D"color:#660">&gt=
;</span><span style=3D"color:#000"><br></span><span style=3D"color:#008">st=
ruct</span><span style=3D"color:#000"> has_type_member </span><span style=
=3D"color:#660">:</span><span style=3D"color:#000"> false_type </span><span=
 style=3D"color:#660">{</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#660">};</span><span style=3D"color:#000"><br><br></span><span s=
tyle=3D"color:#008">template</span><span style=3D"color:#000"> </span><span=
 style=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</span>=
<span style=3D"color:#000"> T</span><span style=3D"color:#660">&gt;</span><=
span style=3D"color:#000"><br></span><span style=3D"color:#008">struct</spa=
n><span style=3D"color:#000"> has_type_member</span><span style=3D"color:#6=
60">&lt;</span><span style=3D"color:#000">T</span><span style=3D"color:#660=
">,</span><span style=3D"color:#000"> void_t</span><span style=3D"color:#66=
0">&lt;</span><span style=3D"color:#000">enable_if_t</span><span style=3D"c=
olor:#660">&lt;</span><span style=3D"color:#606">SomePredica<wbr>te</span><=
span style=3D"color:#660">&lt;</span><span style=3D"color:#000">T</span><sp=
an style=3D"color:#660">&gt;::</span><span style=3D"color:#000">value</span=
><span style=3D"color:#660">&gt;&gt;&gt;</span><span style=3D"color:#000"><=
br>&nbsp; &nbsp; </span><span style=3D"color:#660">:</span><span style=3D"c=
olor:#000"> true_type<br></span><span style=3D"color:#660">{</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#660">};</span></div></code=
></div><div><br></div></div></div></blockquote><div><br></div><div>One does=
 not wrap <font face=3D"courier new, monospace">void_t</font> around <font =
face=3D"courier new, monospace">enable_if_t</font>, one simply uses&nbsp;<f=
ont face=3D"courier new, monospace">enable_if_t</font><font face=3D"arial, =
sans-serif"> directly</font>:</div><div><span style=3D"font-family: monospa=
ce; font-size: 12.7272720336914px; color: rgb(0, 0, 136); background-color:=
 rgb(250, 250, 250);"><br></span></div><div><span style=3D"font-family: mon=
ospace; font-size: 12.7272720336914px; color: rgb(0, 0, 136); background-co=
lor: rgb(250, 250, 250);">template</span><span style=3D"font-family: monosp=
ace; font-size: 12.7272720336914px; color: rgb(0, 0, 0); background-color: =
rgb(250, 250, 250);">&nbsp;</span><span style=3D"font-family: monospace; fo=
nt-size: 12.7272720336914px; color: rgb(102, 102, 0); background-color: rgb=
(250, 250, 250);">&lt;</span><span style=3D"font-family: monospace; font-si=
ze: 12.7272720336914px; color: rgb(0, 0, 136); background-color: rgb(250, 2=
50, 250);">typename</span><span style=3D"font-family: monospace; font-size:=
 12.7272720336914px; color: rgb(102, 102, 0); background-color: rgb(250, 25=
0, 250);">,</span><span style=3D"font-family: monospace; font-size: 12.7272=
720336914px; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250);">&n=
bsp;</span><span style=3D"font-family: monospace; font-size: 12.72727203369=
14px; color: rgb(0, 0, 136); background-color: rgb(250, 250, 250);">typenam=
e</span><span style=3D"font-family: monospace; font-size: 12.7272720336914p=
x; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250);">&nbsp;</span=
><span style=3D"font-family: monospace; font-size: 12.7272720336914px; colo=
r: rgb(102, 102, 0); background-color: rgb(250, 250, 250);">=3D</span><span=
 style=3D"font-family: monospace; font-size: 12.7272720336914px; color: rgb=
(0, 0, 0); background-color: rgb(250, 250, 250);">&nbsp;</span><span style=
=3D"font-family: monospace; font-size: 12.7272720336914px; color: rgb(0, 0,=
 136); background-color: rgb(250, 250, 250);">void</span><span style=3D"fon=
t-family: monospace; font-size: 12.7272720336914px; color: rgb(102, 102, 0)=
; background-color: rgb(250, 250, 250);">&gt;</span><span style=3D"font-fam=
ily: monospace; font-size: 12.7272720336914px; color: rgb(0, 0, 0); backgro=
und-color: rgb(250, 250, 250);"><br></span><span style=3D"font-family: mono=
space; font-size: 12.7272720336914px; color: rgb(0, 0, 136); background-col=
or: rgb(250, 250, 250);">struct</span><span style=3D"font-family: monospace=
; font-size: 12.7272720336914px; color: rgb(0, 0, 0); background-color: rgb=
(250, 250, 250);">&nbsp;has_type_member&nbsp;</span><span style=3D"font-fam=
ily: monospace; font-size: 12.7272720336914px; color: rgb(102, 102, 0); bac=
kground-color: rgb(250, 250, 250);">:</span><span style=3D"font-family: mon=
ospace; font-size: 12.7272720336914px; color: rgb(0, 0, 0); background-colo=
r: rgb(250, 250, 250);">&nbsp;false_type&nbsp;</span><span style=3D"font-fa=
mily: monospace; font-size: 12.7272720336914px; color: rgb(102, 102, 0); ba=
ckground-color: rgb(250, 250, 250);">{</span><span style=3D"font-family: mo=
nospace; font-size: 12.7272720336914px; color: rgb(0, 0, 0); background-col=
or: rgb(250, 250, 250);">&nbsp;</span><span style=3D"font-family: monospace=
; font-size: 12.7272720336914px; color: rgb(102, 102, 0); background-color:=
 rgb(250, 250, 250);">};</span><span style=3D"font-family: monospace; font-=
size: 12.7272720336914px; color: rgb(0, 0, 0); background-color: rgb(250, 2=
50, 250);"><br><br></span><span style=3D"font-family: monospace; font-size:=
 12.7272720336914px; color: rgb(0, 0, 136); background-color: rgb(250, 250,=
 250);">template</span><span style=3D"font-family: monospace; font-size: 12=
..7272720336914px; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250)=
;">&nbsp;</span><span style=3D"font-family: monospace; font-size: 12.727272=
0336914px; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);">=
&lt;</span><span style=3D"font-family: monospace; font-size: 12.72727203369=
14px; color: rgb(0, 0, 136); background-color: rgb(250, 250, 250);">typenam=
e</span><span style=3D"font-family: monospace; font-size: 12.7272720336914p=
x; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250);">&nbsp;T</spa=
n><span style=3D"font-family: monospace; font-size: 12.7272720336914px; col=
or: rgb(102, 102, 0); background-color: rgb(250, 250, 250);">&gt;</span><sp=
an style=3D"font-family: monospace; font-size: 12.7272720336914px; color: r=
gb(0, 0, 0); background-color: rgb(250, 250, 250);"><br></span><span style=
=3D"font-family: monospace; font-size: 12.7272720336914px; color: rgb(0, 0,=
 136); background-color: rgb(250, 250, 250);">struct</span><span style=3D"f=
ont-family: monospace; font-size: 12.7272720336914px; color: rgb(0, 0, 0); =
background-color: rgb(250, 250, 250);">&nbsp;has_type_member</span><span st=
yle=3D"font-family: monospace; font-size: 12.7272720336914px; color: rgb(10=
2, 102, 0); background-color: rgb(250, 250, 250);">&lt;</span><span style=
=3D"font-family: monospace; font-size: 12.7272720336914px; color: rgb(0, 0,=
 0); background-color: rgb(250, 250, 250);">T</span><span style=3D"font-fam=
ily: monospace; font-size: 12.7272720336914px; color: rgb(102, 102, 0); bac=
kground-color: rgb(250, 250, 250);">,</span><span style=3D"font-family: mon=
ospace; font-size: 12.7272720336914px; color: rgb(0, 0, 0); background-colo=
r: rgb(250, 250, 250);">&nbsp;</span><span style=3D"font-family: monospace;=
 font-size: 12.7272720336914px; color: rgb(0, 0, 0); background-color: rgb(=
250, 250, 250);">enable_if_t</span><span style=3D"font-family: monospace; f=
ont-size: 12.7272720336914px; color: rgb(102, 102, 0); background-color: rg=
b(250, 250, 250);">&lt;</span><span style=3D"font-family: monospace; font-s=
ize: 12.7272720336914px; color: rgb(102, 0, 102); background-color: rgb(250=
, 250, 250);">SomePredica<wbr>te</span><span style=3D"font-family: monospac=
e; font-size: 12.7272720336914px; color: rgb(102, 102, 0); background-color=
: rgb(250, 250, 250);">&lt;</span><span style=3D"font-family: monospace; fo=
nt-size: 12.7272720336914px; color: rgb(0, 0, 0); background-color: rgb(250=
, 250, 250);">T</span><span style=3D"font-family: monospace; font-size: 12.=
7272720336914px; color: rgb(102, 102, 0); background-color: rgb(250, 250, 2=
50);">&gt;::</span><span style=3D"font-family: monospace; font-size: 12.727=
2720336914px; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250);">v=
alue</span><span style=3D"font-family: monospace; font-size: 12.72727203369=
14px; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);">&gt;&=
gt;</span><span style=3D"font-family: monospace; font-size: 12.727272033691=
4px; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250);"><br>&nbsp;=
 &nbsp;&nbsp;</span><span style=3D"font-family: monospace; font-size: 12.72=
72720336914px; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250=
);">:</span><span style=3D"font-family: monospace; font-size: 12.7272720336=
914px; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250);">&nbsp;tr=
ue_type<br></span><span style=3D"font-family: monospace; font-size: 12.7272=
720336914px; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);=
">{</span><span style=3D"font-family: monospace; font-size: 12.727272033691=
4px; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250);">&nbsp;</sp=
an><span style=3D"font-family: monospace; font-size: 12.7272720336914px; co=
lor: rgb(102, 102, 0); background-color: rgb(250, 250, 250);">};</span><br>=
</div><div><span style=3D"font-family: monospace; font-size: 12.72727203369=
14px; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);"><br><=
/span></div><div>Your approach seems to have the effect of simply renaming:=
</div><div><ul><li><span style=3D"line-height: normal;">void is relabeled w=
hen&lt;true&gt;</span></li><li><span style=3D"line-height: normal;">void_t =
is relabeled when_valid</span></li><li><span style=3D"line-height: normal;"=
>enable_if_t is relabeled when</span></li></ul><div>Except of course that w=
hen does not optionally accept a type to which it resolves like enable_if_t=
 does. Am I missing something?</div></div></div>

<p></p>

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

------=_Part_257_51388410.1412734392601--

.


Author: Louis Dionne <ldionne.2@gmail.com>
Date: Wed, 8 Oct 2014 09:13:34 -0700 (PDT)
Raw View
------=_Part_265_864590919.1412784814477
Content-Type: text/plain; charset=UTF-8

On Tuesday, 7 October 2014 22:13:12 UTC-4, Casey Carter wrote:
>
>
> Your approach seems to have the effect of simply renaming:
>
>    - void is relabeled when<true>
>    - void_t is relabeled when_valid
>    - enable_if_t is relabeled when
>
> Except of course that when does not optionally accept a type to which it
> resolves like enable_if_t does. Am I missing something?
>

Nope, I'm the one who completely missed something. I still prefer the names
when and when_valid, but that does not justify a proposal.

Thanks,
Louis

--

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

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

<div dir=3D"ltr">On Tuesday, 7 October 2014 22:13:12 UTC-4, Casey Carter  w=
rote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8e=
x;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><br><div=
>Your approach seems to have the effect of simply renaming:</div><div><ul><=
li><span style=3D"line-height:normal">void is relabeled when&lt;true&gt;</s=
pan></li><li><span style=3D"line-height:normal">void_t is relabeled when_va=
lid</span></li><li><span style=3D"line-height:normal">enable_if_t is relabe=
led when</span></li></ul><div>Except of course that when does not optionall=
y accept a type to which it resolves like enable_if_t does. Am I missing so=
mething?</div></div></div></blockquote><div><br></div><div>Nope, I'm the on=
e who completely missed something. I still prefer the names when and when_v=
alid, but that does not justify a proposal.</div><div><br></div><div>Thanks=
,</div><div>Louis</div></div>

<p></p>

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

------=_Part_265_864590919.1412784814477--

.


Author: Tony V E <tvaneerd@gmail.com>
Date: Wed, 8 Oct 2014 13:16:52 -0400
Raw View
--001a11c3ca1662ee2f0504ec7ba4
Content-Type: text/plain; charset=UTF-8

On Wed, Oct 8, 2014 at 12:13 PM, Louis Dionne <ldionne.2@gmail.com> wrote:

> On Tuesday, 7 October 2014 22:13:12 UTC-4, Casey Carter wrote:
>>
>>
>> Your approach seems to have the effect of simply renaming:
>>
>>    - void is relabeled when<true>
>>    - void_t is relabeled when_valid
>>    - enable_if_t is relabeled when
>>
>> Except of course that when does not optionally accept a type to which it
>> resolves like enable_if_t does. Am I missing something?
>>
>
> Nope, I'm the one who completely missed something. I still prefer the
> names when and when_valid, but that does not justify a proposal.
>
>
Sure it does.  Names are important.

Some utilities are named by what they do: ie void_t.
Some are named by how they are used: enable_if.
enable_if doesn't (on its own) enable anything; only in its (typical?
only?) use does it enable things.  By what is does, it could be called
type_or_not or something like that.

I think it depends on usage - does void_t have one typical use, or many?

Personally I don't like the name void_t, since the technique is already
subtle enough, and the name not only doesn't help, but could lead to
confusion (based on things like size_t I'd expect something simple like
void_t to be a type, not a template.  Even in this modern era of _t
templates.)

Tony

--

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

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

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Wed, Oct 8, 2014 at 12:13 PM, Louis Dionne <span dir=3D"ltr">&lt;<a =
href=3D"mailto:ldionne.2@gmail.com" target=3D"_blank">ldionne.2@gmail.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"><sp=
an class=3D"">On Tuesday, 7 October 2014 22:13:12 UTC-4, Casey Carter  wrot=
e:<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"><br><div>Your ap=
proach seems to have the effect of simply renaming:</div><div><ul><li><span=
 style=3D"line-height:normal">void is relabeled when&lt;true&gt;</span></li=
><li><span style=3D"line-height:normal">void_t is relabeled when_valid</spa=
n></li><li><span style=3D"line-height:normal">enable_if_t is relabeled when=
</span></li></ul><div>Except of course that when does not optionally accept=
 a type to which it resolves like enable_if_t does. Am I missing something?=
</div></div></div></blockquote><div><br></div></span><div>Nope, I&#39;m the=
 one who completely missed something. I still prefer the names when and whe=
n_valid, but that does not justify a proposal.</div><div><br></div></div></=
blockquote><div><br></div><div>Sure it does.=C2=A0 Names are important.<br>=
</div></div><br></div><div class=3D"gmail_extra">Some utilities are named b=
y what they do: ie void_t.<br></div><div class=3D"gmail_extra">Some are nam=
ed by how they are used: enable_if.<br></div><div class=3D"gmail_extra">ena=
ble_if doesn&#39;t (on its own) enable anything; only in its (typical? only=
?) use does it enable things.=C2=A0 By what is does, it could be called typ=
e_or_not or something like that.<br><br></div><div class=3D"gmail_extra">I =
think it depends on usage - does void_t have one typical use, or many?<br><=
br></div><div class=3D"gmail_extra">Personally I don&#39;t like the name vo=
id_t, since the technique is already subtle enough, and the name not only d=
oesn&#39;t help, but could lead to confusion (based on things like size_t I=
&#39;d expect something simple like void_t to be a type, not a template.=C2=
=A0 Even in this modern era of _t templates.)<br><br></div><div class=3D"gm=
ail_extra">Tony<br><br></div></div>

<p></p>

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

--001a11c3ca1662ee2f0504ec7ba4--

.


Author: TONGARI J <tongari95@gmail.com>
Date: Thu, 9 Oct 2014 02:36:47 -0700 (PDT)
Raw View
------=_Part_554_1142425083.1412847407609
Content-Type: text/plain; charset=UTF-8

2014-10-09 0:13 GMT+08:00 Louis Dionne <ldionne.2@gmail.com>:

> On Tuesday, 7 October 2014 22:13:12 UTC-4, Casey Carter wrote:
>>
>>
>> Your approach seems to have the effect of simply renaming:
>>
>>    - void is relabeled when<true>
>>    - void_t is relabeled when_valid
>>    - enable_if_t is relabeled when
>>
>> Except of course that when does not optionally accept a type to which it
>> resolves like enable_if_t does. Am I missing something?
>>
>
> Nope, I'm the one who completely missed something. I still prefer the
> names when and when_valid, but that does not justify a proposal.
>

I personally prefer enable_if_valid_t to void_t:

template<class Expr, class T = void>
struct enable_if_valid
{
    using type = T;
};

template<class T, class U = void>
using enable_if_valid_t = typename enable_if_valid<T, U>::type;

Not only the name is more meaningful than void_t, enable_if_valid_t is more
general and useful in function templates:

template<class T, enable_if_valid_t<decltype(std::declval<T>().doSomething
()), bool> = true>
void f(T&& t)
{
    ...
}

--

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

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

<div dir=3D"ltr"><span style=3D"font-family: arial; font-size: small;">2014=
-10-09 0:13 GMT+08:00 Louis Dionne&nbsp;</span><span dir=3D"ltr" style=3D"f=
ont-family: arial; font-size: small;">&lt;<a href=3D"mailto:ldionne.2@gmail=
..com" target=3D"_blank" style=3D"color: rgb(17, 85, 204);">ldionne.2@gmail.=
com</a>&gt;</span><span style=3D"font-family: arial; font-size: small;">:</=
span><br style=3D"font-family: arial; font-size: small;"><blockquote class=
=3D"gmail_quote" style=3D"font-family: arial; font-size: small; margin: 0px=
 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 20=
4); border-left-style: solid; padding-left: 1ex;"><div dir=3D"ltr"><span cl=
ass=3D"">On Tuesday, 7 October 2014 22:13:12 UTC-4, Casey Carter wrote:<blo=
ckquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-le=
ft-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: so=
lid; padding-left: 1ex;"><div dir=3D"ltr"><br><div>Your approach seems to h=
ave the effect of simply renaming:</div><div><ul><li><span style=3D"line-he=
ight: normal;">void is relabeled when&lt;true&gt;</span></li><li><span styl=
e=3D"line-height: normal;">void_t is relabeled when_valid</span></li><li><s=
pan style=3D"line-height: normal;">enable_if_t is relabeled when</span></li=
></ul><div>Except of course that when does not optionally accept a type to =
which it resolves like enable_if_t does. Am I missing something?</div></div=
></div></blockquote><div><br></div></span><div>Nope, I'm the one who comple=
tely missed something. I still prefer the names when and when_valid, but th=
at does not justify a proposal.</div></div></blockquote><div style=3D"font-=
family: arial; font-size: small;"><br></div><div style=3D"font-family: aria=
l; font-size: small;">I personally prefer enable_if_valid_t to void_t:</div=
><div style=3D"font-family: arial; font-size: small;"><br></div><div><div c=
lass=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wr=
ap: break-word; background-color: rgb(250, 250, 250);"><code class=3D"prett=
yprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D=
"styled-by-prettify">template</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">E=
xpr</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">class</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> T </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">void</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> enable_if_valid<br></span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">using</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> type </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color:=
 #008;" class=3D"styled-by-prettify">template</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">class</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">cl=
ass</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> U </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">void</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">using</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> enable_if_valid_t </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">typename</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> enable_if_valid</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> U<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;::</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">type</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">;</span></div></code>=
</div><div><font face=3D"arial" size=3D"2"><br></font></div><div><span styl=
e=3D"font-family: arial; font-size: small;">Not only the name is more meani=
ngful than&nbsp;</span><span style=3D"font-family: arial; font-size: small;=
">void_t</span><span style=3D"font-family: arial; font-size: small;">, enab=
le_if_valid_t is more general and useful in function templates:</span></div=
><div><span style=3D"font-family: arial; font-size: small;"><br></span></di=
v><div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, =
187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code c=
lass=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">template</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">class</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> enable_if_valid_t</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">decltype</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">std</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">declval</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 style=3D"color=
: #660;" class=3D"styled-by-prettify">&gt;().</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">doSomething</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">bool</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">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">true</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"co=
lor: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> f</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">&amp;&amp;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> t</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </spa=
n><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><=
/div></div></div>

<p></p>

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

------=_Part_554_1142425083.1412847407609--

.


Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@gmail.com>
Date: Thu, 9 Oct 2014 12:49:56 +0200
Raw View
2014-10-09 11:36 GMT+02:00 TONGARI J <tongari95@gmail.com>:
> I personally prefer enable_if_valid_t to void_t:

If we are just talking about naming preferences I can assure you that
nothing normatively will change, simply because the standard does not
intend to satisfy everyone's naming preferences. If the functionality
exists but just has a different name, this looks not like a promising
request to me. This usually includes trivial transformations of some
existing features.

- 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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.