Topic: Adding a remove_cv_reference type trait


Author: R.HL@gmx.net
Date: Sun, 4 Jan 2015 10:33:47 -0800 (PST)
Raw View
------=_Part_3304_25283539.1420396427193
Content-Type: multipart/alternative;
 boundary="----=_Part_3305_1886161514.1420396427193"

------=_Part_3305_1886161514.1420396427193
Content-Type: text/plain; charset=UTF-8

There is a generally useful type trait not yet included in the standard
library, simply removing all references and cv-qualifiers from a type -
i.e. it maps
int const&     to    int
int&&          to    int
and so forth. This trait could be named remove_cv_reference. The
implementation is trivial, e.g.
template <typename T>
struct remove_cv_reference { using type = remove_cv_t<remove_reference_t<T
>>; };

template <typename T>
struct remove_cv_reference_t = typename remove_cv_reference<T>::type;
Is it feasible to include this in <type_traits>?

--

---
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_3305_1886161514.1420396427193
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">There is a generally useful type trait not yet included in=
 the standard library, simply removing all references and cv-qualifiers fro=
m a type - i.e. it maps<div style=3D"border: 1px solid rgb(187, 187, 187); =
word-wrap: break-word; background-color: rgb(250, 250, 250);"><code><span s=
tyle=3D"color: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(0, 0, 0=
);">&nbsp;</span><span style=3D"color: rgb(0, 0, 136);">const</span><span s=
tyle=3D"color: rgb(102, 102, 0);">&amp;</span><span style=3D"color: rgb(0, =
0, 0);">&nbsp;&nbsp; &nbsp; to &nbsp; &nbsp;</span><span style=3D"color: rg=
b(0, 0, 136);">int</span><span style=3D"color: rgb(0, 0, 0);"><br></span><s=
pan style=3D"color: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(10=
2, 102, 0);">&amp;&amp;</span><span style=3D"color: rgb(0, 0, 0);">&nbsp;&n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp;to &nbsp; &nbsp;</span><span style=3D"color=
: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(0, 0, 0);"><br></spa=
n></code></div><div>and so forth. This trait could be named&nbsp;<font face=
=3D"courier new, monospace">remove_cv_reference</font><font face=3D"arial, =
sans-serif">.</font>&nbsp;The implementation is trivial, e.g.</div><div sty=
le=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; backgrou=
nd-color: rgb(250, 250, 250);"><code><span style=3D"color: rgb(0, 0, 136);"=
>template</span><span style=3D"color: rgb(0, 0, 0);">&nbsp;</span><span sty=
le=3D"color: rgb(102, 102, 0);">&lt;</span><span style=3D"color: rgb(0, 0, =
136);">typename</span><span style=3D"color: rgb(0, 0, 0);">&nbsp;T</span><s=
pan style=3D"color: rgb(102, 102, 0);">&gt;</span><span style=3D"color: rgb=
(0, 0, 0);"><br></span><span style=3D"color: rgb(0, 0, 136);">struct</span>=
<span style=3D"color: rgb(0, 0, 0);">&nbsp;remove_cv_reference&nbsp;</span>=
<span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(=
0, 0, 0);">&nbsp;</span><span style=3D"color: rgb(0, 0, 136);">using</span>=
<span style=3D"color: rgb(0, 0, 0);">&nbsp;type&nbsp;</span><span style=3D"=
color: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, 0, 0);">&n=
bsp;remove_cv_t</span><span style=3D"color: rgb(102, 102, 0);">&lt;</span><=
span style=3D"color: rgb(0, 0, 0);">remove_reference_t</span><span style=3D=
"color: rgb(102, 102, 0);"><wbr>&lt;</span><span style=3D"color: rgb(0, 0, =
0);">T</span><span style=3D"color: rgb(102, 102, 0);">&gt;&gt;;</span><span=
 style=3D"color: rgb(0, 0, 0);">&nbsp;</span><span style=3D"color: rgb(102,=
 102, 0);">};</span><span style=3D"color: rgb(0, 0, 0);"><br><br></span><sp=
an style=3D"color: rgb(0, 0, 136);">template</span><span style=3D"color: rg=
b(0, 0, 0);">&nbsp;</span><span style=3D"color: rgb(102, 102, 0);">&lt;</sp=
an><span style=3D"color: rgb(0, 0, 136);">typename</span><span style=3D"col=
or: rgb(0, 0, 0);">&nbsp;T</span><span style=3D"color: rgb(102, 102, 0);">&=
gt;</span><span style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"co=
lor: rgb(0, 0, 136);">struct</span><span style=3D"color: rgb(0, 0, 0);">&nb=
sp;remove_cv_reference_t&nbsp;</span><span style=3D"color: rgb(102, 102, 0)=
;">=3D</span><span style=3D"color: rgb(0, 0, 0);">&nbsp;</span><span style=
=3D"color: rgb(0, 0, 136);">typename</span><span style=3D"color: rgb(0, 0, =
0);">&nbsp;remove_cv_reference</span><span style=3D"color: rgb(102, 102, 0)=
;">&lt;</span><span style=3D"color: rgb(0, 0, 0);">T</span><span style=3D"c=
olor: rgb(102, 102, 0);">&gt;::</span><span style=3D"color: rgb(0, 0, 0);">=
type</span><span style=3D"color: rgb(102, 102, 0);">;</span></code></div><d=
iv>Is it feasible to include this in <font face=3D"courier new, monospace">=
&lt;type_traits&gt;</font>?</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_3305_1886161514.1420396427193--
------=_Part_3304_25283539.1420396427193--

.


Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Sun, 4 Jan 2015 21:27:30 +0100
Raw View
--001a11c36c682acece050bd96753
Content-Type: text/plain; charset=UTF-8

std::decay does this, as well as array-to-pointer and function-to-pointer.

On Sun, Jan 4, 2015 at 7:33 PM, <R.HL@gmx.net> wrote:

> There is a generally useful type trait not yet included in the standard
> library, simply removing all references and cv-qualifiers from a type -
> i.e. it maps
> int const&     to    int
> int&&          to    int
> and so forth. This trait could be named remove_cv_reference. The
> implementation is trivial, e.g.
> template <typename T>
> struct remove_cv_reference { using type = remove_cv_t<remove_reference_t<T
> >>; };
>
> template <typename T>
> struct remove_cv_reference_t = typename remove_cv_reference<T>::type;
> Is it feasible to include this in <type_traits>?
>
> --
>
> ---
> 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/.
>

--

---
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/.

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

<div dir=3D"ltr">std::decay does this, as well as array-to-pointer and func=
tion-to-pointer.</div><div class=3D"gmail_extra"><br><div class=3D"gmail_qu=
ote">On Sun, Jan 4, 2015 at 7:33 PM,  <span dir=3D"ltr">&lt;<a href=3D"mail=
to:R.HL@gmx.net" target=3D"_blank">R.HL@gmx.net</a>&gt;</span> wrote:<br><b=
lockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px =
#ccc solid;padding-left:1ex"><div dir=3D"ltr">There is a generally useful t=
ype trait not yet included in the standard library, simply removing all ref=
erences and cv-qualifiers from a type - i.e. it maps<div style=3D"border:1p=
x solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,=
250)"><code><span style=3D"color:rgb(0,0,136)">int</span><span style=3D"col=
or:rgb(0,0,0)">=C2=A0</span><span style=3D"color:rgb(0,0,136)">const</span>=
<span style=3D"color:rgb(102,102,0)">&amp;</span><span style=3D"color:rgb(0=
,0,0)">=C2=A0=C2=A0 =C2=A0 to =C2=A0 =C2=A0</span><span style=3D"color:rgb(=
0,0,136)">int</span><span style=3D"color:rgb(0,0,0)"><br></span><span style=
=3D"color:rgb(0,0,136)">int</span><span style=3D"color:rgb(102,102,0)">&amp=
;&amp;</span><span style=3D"color:rgb(0,0,0)">=C2=A0=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0to =C2=A0 =C2=A0</span><span style=3D"color:rgb(0,0,136)">int<=
/span><span style=3D"color:rgb(0,0,0)"><br></span></code></div><div>and so =
forth. This trait could be named=C2=A0<font face=3D"courier new, monospace"=
>remove_cv_reference</font><font face=3D"arial, sans-serif">.</font>=C2=A0T=
he implementation is trivial, e.g.</div><div style=3D"border:1px solid rgb(=
187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code>=
<span style=3D"color:rgb(0,0,136)">template</span><span style=3D"color:rgb(=
0,0,0)">=C2=A0</span><span style=3D"color:rgb(102,102,0)">&lt;</span><span =
style=3D"color:rgb(0,0,136)">typename</span><span style=3D"color:rgb(0,0,0)=
">=C2=A0T</span><span style=3D"color:rgb(102,102,0)">&gt;</span><span style=
=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(0,0,136)">struct<=
/span><span style=3D"color:rgb(0,0,0)">=C2=A0remove_cv_reference=C2=A0</spa=
n><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0=
,0)">=C2=A0</span><span style=3D"color:rgb(0,0,136)">using</span><span styl=
e=3D"color:rgb(0,0,0)">=C2=A0type=C2=A0</span><span style=3D"color:rgb(102,=
102,0)">=3D</span><span style=3D"color:rgb(0,0,0)">=C2=A0remove_cv_t</span>=
<span style=3D"color:rgb(102,102,0)">&lt;</span><span style=3D"color:rgb(0,=
0,0)">remove_reference_t</span><span style=3D"color:rgb(102,102,0)"><u></u>=
&lt;</span><span style=3D"color:rgb(0,0,0)">T</span><span style=3D"color:rg=
b(102,102,0)">&gt;&gt;;</span><span style=3D"color:rgb(0,0,0)">=C2=A0</span=
><span style=3D"color:rgb(102,102,0)">};</span><span style=3D"color:rgb(0,0=
,0)"><br><br></span><span style=3D"color:rgb(0,0,136)">template</span><span=
 style=3D"color:rgb(0,0,0)">=C2=A0</span><span style=3D"color:rgb(102,102,0=
)">&lt;</span><span style=3D"color:rgb(0,0,136)">typename</span><span style=
=3D"color:rgb(0,0,0)">=C2=A0T</span><span style=3D"color:rgb(102,102,0)">&g=
t;</span><span style=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:r=
gb(0,0,136)">struct</span><span style=3D"color:rgb(0,0,0)">=C2=A0remove_cv_=
reference_t=C2=A0</span><span style=3D"color:rgb(102,102,0)">=3D</span><spa=
n style=3D"color:rgb(0,0,0)">=C2=A0</span><span style=3D"color:rgb(0,0,136)=
">typename</span><span style=3D"color:rgb(0,0,0)">=C2=A0remove_cv_reference=
</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)">&gt;::</span><spa=
n style=3D"color:rgb(0,0,0)">type</span><span style=3D"color:rgb(102,102,0)=
">;</span></code></div><div>Is it feasible to include this in <font face=3D=
"courier new, monospace">&lt;type_traits&gt;</font>?</div></div><span class=
=3D"HOEnZb"><font color=3D"#888888">

<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" target=3D"_=
blank">std-proposals+unsubscribe@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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br></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 />

--001a11c36c682acece050bd96753--

.


Author: R.HL@gmx.net
Date: Sun, 4 Jan 2015 12:34:12 -0800 (PST)
Raw View
------=_Part_371_500364794.1420403652978
Content-Type: multipart/alternative;
 boundary="----=_Part_372_85131106.1420403652978"

------=_Part_372_85131106.1420403652978
Content-Type: text/plain; charset=UTF-8

I can't quite see why you're mentioning this. These type adjustments are
not performed by this trait because it isn't intended to. If I give const
int[3] as the input I want int[3] as the output, period.

Am Sonntag, 4. Januar 2015 20:27:33 UTC schrieb Andrew Tomazos:
>
> std::decay does this, as well as array-to-pointer and function-to-pointer.
>

--

---
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_372_85131106.1420403652978
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I can't quite see why you're mentioning this. These type a=
djustments are not performed by this trait because it isn't intended to. If=
 I give&nbsp;<font face=3D"courier new, monospace">const int[3] as the inpu=
t&nbsp;</font>I want<font face=3D"courier new, monospace"> int[3]</font> as=
 the output, period.<br><br>Am Sonntag, 4. Januar 2015 20:27:33 UTC schrieb=
 Andrew Tomazos:<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">std::decay does this, as well as array-to-pointer and function-to-pointe=
r.</div>
</blockquote></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_372_85131106.1420403652978--
------=_Part_371_500364794.1420403652978--

.


Author: R.HL@gmx.net
Date: Sun, 4 Jan 2015 12:37:17 -0800 (PST)
Raw View
------=_Part_266_756799364.1420403837407
Content-Type: multipart/alternative;
 boundary="----=_Part_267_2128753214.1420403837407"

------=_Part_267_2128753214.1420403837407
Content-Type: text/plain; charset=UTF-8

These type adjustments are not performed by remove_cv_reference as it
simply isn't intended to. If I give const int[3] as the argument to this
trait  I want int[3] as the output, period.

Am Sonntag, 4. Januar 2015 20:27:33 UTC schrieb Andrew Tomazos:
>
> std::decay does this, as well as array-to-pointer and function-to-pointer.
>

--

---
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_267_2128753214.1420403837407
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">These type adjustments are not performed by <font face=3D"=
courier new, monospace">remove_cv_reference</font> as it simply isn't inten=
ded to. If I give&nbsp;<font face=3D"courier new, monospace">const int[3] <=
/font><font face=3D"arial, sans-serif">as the argument to this trait &nbsp;=
</font>I want<font face=3D"courier new, monospace">&nbsp;int[3]</font>&nbsp=
;as the output, period.<br><br>Am Sonntag, 4. Januar 2015 20:27:33 UTC schr=
ieb Andrew Tomazos:<blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D=
"ltr">std::decay does this, as well as array-to-pointer and function-to-poi=
nter.</div>
</blockquote></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_267_2128753214.1420403837407--
------=_Part_266_756799364.1420403837407--

.


Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Sun, 4 Jan 2015 21:45:44 +0100
Raw View
--047d7b343bae5f3392050bd9a8bf
Content-Type: text/plain; charset=UTF-8

What is your proposed `std::remove_cv_reference` trait useful for?  You can
already spell it `std::remove_cv_t<std::remove_reference_t<T>>`, if you
only need it occasionally. So demonstrate that it is so commonly needed to
warrant adding it, by providing motivating use cases.

On Sun, Jan 4, 2015 at 9:37 PM, <R.HL@gmx.net> wrote:

> These type adjustments are not performed by remove_cv_reference as it
> simply isn't intended to. If I give const int[3] as the argument to this
> trait  I want int[3] as the output, period.
>
> Am Sonntag, 4. Januar 2015 20:27:33 UTC schrieb Andrew Tomazos:
>>
>> std::decay does this, as well as array-to-pointer and function-to-pointer.
>>
>  --
>
> ---
> 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/.
>

--

---
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/.

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

<div dir=3D"ltr">What is your proposed `std::remove_cv_reference` trait use=
ful for?=C2=A0 You can already spell it `std::remove_cv_t&lt;std::remove_re=
ference_t&lt;T&gt;&gt;`, if you only need it occasionally. So demonstrate t=
hat it is so commonly needed to warrant adding it, by providing motivating =
use cases.</div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">O=
n Sun, Jan 4, 2015 at 9:37 PM,  <span dir=3D"ltr">&lt;<a href=3D"mailto:R.H=
L@gmx.net" target=3D"_blank">R.HL@gmx.net</a>&gt;</span> wrote:<br><blockqu=
ote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr">These type adjustments are not perf=
ormed by <font face=3D"courier new, monospace">remove_cv_reference</font> a=
s it simply isn&#39;t intended to. If I give=C2=A0<font face=3D"courier new=
, monospace">const int[3] </font><font face=3D"arial, sans-serif">as the ar=
gument to this trait =C2=A0</font>I want<font face=3D"courier new, monospac=
e">=C2=A0int[3]</font>=C2=A0as the output, period.<span class=3D""><br><br>=
Am Sonntag, 4. Januar 2015 20:27:33 UTC schrieb Andrew Tomazos:</span><bloc=
kquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">std::decay does this, a=
s well as array-to-pointer and function-to-pointer.</div><span class=3D"HOE=
nZb"><font color=3D"#888888">
</font></span></blockquote></div><span class=3D"HOEnZb"><font color=3D"#888=
888">

<p></p>

-- <br></font></span><div class=3D"HOEnZb"><div class=3D"h5">
<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" target=3D"_=
blank">std-proposals+unsubscribe@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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></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 />

--047d7b343bae5f3392050bd9a8bf--

.


Author: R.HL@gmx.net
Date: Sun, 4 Jan 2015 15:15:37 -0800 (PST)
Raw View
------=_Part_350_1423860656.1420413337827
Content-Type: multipart/alternative;
 boundary="----=_Part_351_1415766871.1420413337827"

------=_Part_351_1415766871.1420413337827
Content-Type: text/plain; charset=UTF-8

Unfortunately I don't have many. Recently I came across an application of
SFINAE in conjunction with reference parameters: If you want to restrict
the type set you have to get the underlying type of the reference,
excluding cv-qualifiers.

template <typename T>
std::enable_if_t<std::is_same<std::remove_cv_t<std::remove_reference_t<T>>,
MyType>{}> foo(T&& t)
{/* Some operations */ bar(std::forward<T>(t));}
(Possibly with is_base_of instead of is_same)
Of course expression SFINAE could be applied but would have a different
effect on overload resolution as it would take anything that the parameter
is initialize-able with, whereas this overly choosy function template only
takes MyTypes (or subclasses, if desired).

I then thought of simplifying the above by splitting up the enable_if-part:

template <typename T, typename U>
using enable_if_compatible = std::enable_if_t<std::is_same<std::remove_cv_t<
std::remove_reference_t<T>>, MyType>{}>

I wondered why there is no trait to get the underlying, cv-unqualified type
of a reference. This is how I ended up proposing it in here. I don't know
whether it is often used but it is a lot more idiomatic to write
remove_cv_reference instead of remove_cv<remove_reference<>>, which also
seems to confuse people
<http://stackoverflow.com/questions/17295169/stdremove-reference-or-stdremove-cv-first>
..

--

---
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_351_1415766871.1420413337827
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Unfortunately I don't have many. Recently I came across an=
 application of SFINAE in conjunction with reference parameters: If you wan=
t to restrict the type set you have to get the underlying type of the refer=
ence, excluding cv-qualifiers.<div><br></div><div><div class=3D"prettyprint=
" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; bac=
kground-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><font color=3D"#660066"><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">template</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-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-pr=
ettify"> 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>st=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
<span style=3D"color: #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: #000;" class=3D"styled-by-prettify">std</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">is_same</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">&lt;</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">remove_cv_t</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">std</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">remo=
ve_reference_t</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">&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;&gt;,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">MyType</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&gt;{}&gt;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> foo</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;" cla=
ss=3D"styled-by-prettify">&amp;&amp;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> t</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">{</span><span style=3D"color: #800;" class=3D"styled-by-prettify">/* Som=
e operations */</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> bar</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 st=
yle=3D"color: #000;" class=3D"styled-by-prettify">forward</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"co=
lor: #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;" cl=
ass=3D"styled-by-prettify">t</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">));}</span></font></div></code></div><span style=3D"color=
: rgb(0, 0, 0); background-color: rgb(250, 250, 250);">(Possibly with&nbsp;=
</span><font face=3D"courier new, monospace" style=3D"color: rgb(0, 0, 0); =
background-color: rgb(250, 250, 250);">is_base_of</font><span style=3D"colo=
r: rgb(0, 0, 0); background-color: rgb(250, 250, 250);">&nbsp;instead of&nb=
sp;</span><font face=3D"courier new, monospace" style=3D"color: rgb(0, 0, 0=
); background-color: rgb(250, 250, 250);">is_same</font><span style=3D"colo=
r: rgb(0, 0, 0); background-color: rgb(250, 250, 250);">)</span><br>Of cour=
se expression SFINAE could be applied but would have a different effect on =
overload resolution as it would take anything that the parameter is initial=
ize-able with, whereas this overly choosy function template only takes <fon=
t face=3D"courier new, monospace">MyTypes (or subclasses, if desired)</font=
>.</div><div><br></div><div>I then thought of simplifying the above by spli=
tting up the <font face=3D"courier new, monospace">enable_if</font>-part:</=
div><div><br></div><div><div class=3D"prettyprint" style=3D"border: 1px sol=
id rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 25=
0, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><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">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">typename</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> U</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">using</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> enable_if_compatible=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</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">enable_if_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">std</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">is_same</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">std</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">remove_cv_t</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">&lt;</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">remove_reference_=
t</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">T</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">&gt;&gt;,</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #606;" class=3D"styled-by-prettify">MyType</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">&gt;{}&gt;</span></div></code></div><s=
pan class=3D"styled-by-prettify" style=3D"background-color: rgb(250, 250, 2=
50);"><div><br></div><div><font color=3D"#000000">I wondered why there is n=
o trait to get the underlying, cv-unqualified type of a reference. This is =
how I ended up proposing it in here. I don't know whether it is often used =
but it is a lot more idiomatic to write <font face=3D"courier new, monospac=
e">remove_cv_reference</font> instead of <font face=3D"courier new, monospa=
ce">remove_cv&lt;remove_reference&lt;&gt;&gt;</font>, which also<a href=3D"=
http://stackoverflow.com/questions/17295169/stdremove-reference-or-stdremov=
e-cv-first"> seems to confuse people</a>.</font></div></span></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_351_1415766871.1420413337827--
------=_Part_350_1423860656.1420413337827--

.