Topic: value_type<T>
Author: John McFarlane <mcfarlane.john@gmail.com>
Date: Sat, 10 Dec 2016 18:49:45 -0800 (PST)
Raw View
------=_Part_3229_1187912697.1481424585668
Content-Type: multipart/alternative;
boundary="----=_Part_3230_211422479.1481424585669"
------=_Part_3230_211422479.1481424585669
Content-Type: text/plain; charset=UTF-8
A type trait that, given a container type, yields the element type:
value_type_t<string[10]> // string
value_type<std::vector<const float *>>::type // const float *
value_type_t<std::list<array<char, 5>>> // array<char, 5>
Possible implementation along the lines of
template<class T>
struct value_type;
template<class T, std::size_t N>
struct value_type<T[N]> {
using type = T;
};
template<class T>
struct value_type<std::vector<T>> {
using type = T;
};
template<class T>
struct value_type<std::list<T>> {
using type = T;
};
// and everything else for which there is begin(T)
template<typename T>
using value_type_t = typename value_type<T>::type;
although there may well be a simpler approach which exploits begin, end or
member value_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/d09b018d-e10f-4bc1-b48e-fb194e6646bc%40isocpp.org.
------=_Part_3230_211422479.1481424585669
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">A type trait that, given a container type, yields the elem=
ent type:<br><br><div style=3D"background-color: rgb(250, 250, 250); border=
-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflo=
w-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div=
class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">value_type_t</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">string</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">10</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">]></span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">// string</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>value_type</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">vector</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">const</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">float</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">*>=
;>::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">typ=
e </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// const=
float *</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>value_type_t</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy"><</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">list</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">array</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">char</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: #066;" class=3D"styled-b=
y-prettify">5</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">>>></span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// a=
rray<char, 5></span></div></code></div><br>Possible implementation al=
ong the lines of<br><span style=3D"font-family: courier new,monospace;"><br=
><div style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187,=
187, 187); border-style: solid; border-width: 1px; overflow-wrap: break-wo=
rd;" class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subpre=
ttyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">templat=
e</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">></span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> value_type</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">size_t N</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">></span><span sty=
le=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"colo=
r: #000;" class=3D"styled-by-prettify"> value_type</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify"><</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">[</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">N</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: #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">using<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> type </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">></span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">struct<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> value_type=
</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">vector</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify"><</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">>></span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><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-p=
rettify"> type </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">template</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> T</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><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> value_type</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy"><</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">list</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">>></span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">using</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> type </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span =
style=3D"color: #800;" class=3D"styled-by-prettify">// and everything else =
for which there is begin(T)</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">template</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">typename</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> T</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: #008;" class=3D"styled-by-prettify">using</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> value_type_t </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">typename</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> value_type</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">T</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">>::</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">type</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></div></code></div></span><span style=3D"font-family: c=
ourier new,monospace;"><br><font face=3D"arial,sans-serif">although there m=
ay well be a simpler approach which exploits <span style=3D"font-family: co=
urier new,monospace;">begin</span>, <span style=3D"font-family: courier new=
,monospace;">end</span> or member <span style=3D"font-family: courier new,m=
onospace;">value_type</span>.</font><br></span></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/d09b018d-e10f-4bc1-b48e-fb194e6646bc%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d09b018d-e10f-4bc1-b48e-fb194e6646bc=
%40isocpp.org</a>.<br />
------=_Part_3230_211422479.1481424585669--
------=_Part_3229_1187912697.1481424585668--
.
Author: Derek Ross <antiquarktv@gmail.com>
Date: Sat, 10 Dec 2016 19:31:32 -0800 (PST)
Raw View
------=_Part_3138_2665514.1481427092369
Content-Type: multipart/alternative;
boundary="----=_Part_3139_289172059.1481427092370"
------=_Part_3139_289172059.1481427092370
Content-Type: text/plain; charset=UTF-8
The following seems to work:
template<typename T>
struct value_type
{
using type = decltype(*std::begin(*((T*)(NULL))));
};
int main()
{
cout << typeid(value_type<string[10]>::type).name() << endl;
cout << typeid(value_type<std::vector<const float *>>::type).name() <<
endl;
cout << typeid(value_type<std::list<std::array<char, 5>>>::type).name()
<< endl;
cout << typeid(string).name() << endl;
cout << typeid(const float *).name() << endl;
cout << typeid(std::array<char, 5>).name() << endl;
}
....output...
Ss
PKf
St5arrayIcLm5EE
Ss
PKf
St5arrayIcLm5EE
On Saturday, December 10, 2016 at 8:49:45 PM UTC-6, John McFarlane wrote:
>
> A type trait that, given a container type, yields the element type:
>
> value_type_t<string[10]> // string
> value_type<std::vector<const float *>>::type // const float *
> value_type_t<std::list<array<char, 5>>> // array<char, 5>
>
> Possible implementation along the lines of
>
> template<class T>
> struct value_type;
>
> template<class T, std::size_t N>
> struct value_type<T[N]> {
> using type = T;
> };
>
> template<class T>
> struct value_type<std::vector<T>> {
> using type = T;
> };
>
> template<class T>
> struct value_type<std::list<T>> {
> using type = T;
> };
>
> // and everything else for which there is begin(T)
>
> template<typename T>
> using value_type_t = typename value_type<T>::type;
>
> although there may well be a simpler approach which exploits begin, end
> or member value_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/45df670c-da8b-453c-9a87-b2936493fc75%40isocpp.org.
------=_Part_3139_289172059.1481427092370
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The following seems to work:<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: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">template</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify"><</span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> value_type<br></span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">{</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-prett=
ify">using</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
type </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">decltype</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"col=
or: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">begin</span><span style=3D"color: #660;" cl=
ass=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-b=
y-prettify">*)(</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">NULL</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><sp=
an 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-prettify"> main</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>=C2=A0 =C2=A0cout </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">typeid</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">value_type</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify"><</span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>string</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[</=
span><span style=3D"color: #066;" class=3D"styled-by-prettify">10</span><sp=
an 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-prettify">).</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">name</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify"><<</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> endl</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0cout </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">typeid</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">value_type</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y"><</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">vector</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"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">float</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><span style=3D"color: #000;" class=3D"=
styled-by-prettify">type</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">).</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">name</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify"><<</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> endl</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0<br>=C2=A0 =C2=A0co=
ut </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">typeid</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">value_type</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">list</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify"><</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">std</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">arr=
ay</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">char</span><sp=
an 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=
: #066;" class=3D"styled-by-prettify">5</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">>>>::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">type</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">).</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">name</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><=
<</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> endl<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0<br=
>=C2=A0 =C2=A0cout </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify"><<</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">ty=
peid</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">string</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">).</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">name</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> endl</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>=C2=A0 =C2=A0cout </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">typeid</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"> </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">float</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">*).</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">name</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><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> endl</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>=C2=A0 =C2=A0cout </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><<</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">typeid</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 s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">array</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">char</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: #066;" class=3D"sty=
led-by-prettify">5</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">>).</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">name</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify"><<</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> endl</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">...</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">output</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">...</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br></span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
Ss</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #606;" class=3D"styled-by-prettify">PKf</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #606;" class=3D"styled-by-prettify">St5arrayIcLm5EE</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Ss</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #60=
6;" class=3D"styled-by-prettify">PKf</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span><span style=3D"color: #606;" class=3D"=
styled-by-prettify">St5arrayIcLm5EE</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br></span></div></code></div><br><br><br><br>On Saturda=
y, December 10, 2016 at 8:49:45 PM UTC-6, John McFarlane wrote:<blockquote =
class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1p=
x #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">A type trait that, given =
a container type, yields the element type:<br><br><div style=3D"background-=
color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bor=
der-width:1px"><code><div><span style=3D"color:#000">value_type_t</span><sp=
an style=3D"color:#660"><</span><span style=3D"color:#008">string</span>=
<span style=3D"color:#660">[</span><span style=3D"color:#066">10</span><spa=
n style=3D"color:#660">]></span><span style=3D"color:#000"> </span><span=
style=3D"color:#800">// string</span><span style=3D"color:#000"><br>value_=
type</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">v=
ector</span><span style=3D"color:#660"><</span><span style=3D"color:#008=
">const</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>float</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
*>>::</span><span style=3D"color:#000">type </span><span style=3D"col=
or:#800">// const float *</span><span style=3D"color:#000"><br>value_type_t=
</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">list<=
/span><span style=3D"color:#660"><</span><span style=3D"color:#000">arra=
y</span><span style=3D"color:#660"><</span><span style=3D"color:#008">c<=
wbr>har</span><span style=3D"color:#660">,</span><span style=3D"color:#000"=
> </span><span style=3D"color:#066">5</span><span style=3D"color:#660">>=
>></span><span style=3D"color:#000"> </span><span style=3D"color:#800=
">// array<char, 5></span></div></code></div><br>Possible implementat=
ion along the lines of<br><span style=3D"font-family:courier new,monospace"=
><br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,1=
87,187);border-style:solid;border-width:1px"><code><div><span style=3D"colo=
r:#008">template</span><span style=3D"color:#660"><</span><span style=3D=
"color:#008">class</span><span style=3D"color:#000"> T</span><span style=3D=
"color:#660">></span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">struct</span><span style=3D"color:#000"> value_type</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"><<=
/span><span style=3D"color:#008">class</span><span style=3D"color:#000"> T<=
/span><span style=3D"color:#660">,</span><span style=3D"color:#000"> std</s=
pan><span style=3D"color:#660">::</span><span style=3D"color:#000">size_t N=
</span><span style=3D"color:#660">></span><span style=3D"color:#000"><br=
></span><span style=3D"color:#008">struct</span><span style=3D"color:#000">=
value_type</span><span style=3D"color:#660"><</span><span style=3D"colo=
r:#000">T</span><span style=3D"color:#660">[</span><span style=3D"color:#00=
0">N</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">using</span><span style=3D=
"color:#000"> type </span><span style=3D"color:#660">=3D</span><span style=
=3D"color:#000"> T</span><span style=3D"color:#660">;</span><span style=3D"=
color:#000"><br></span><span style=3D"color:#660">};</span><span style=3D"c=
olor:#000"><br><br></span><span style=3D"color:#008">template</span><span s=
tyle=3D"color:#660"><</span><span style=3D"color:#008">class</span><span=
style=3D"color:#000"> T</span><span style=3D"color:#660">></span><span =
style=3D"color:#000"><br></span><span style=3D"color:#008">struct</span><sp=
an style=3D"color:#000"> value_type</span><span style=3D"color:#660"><</=
span><span style=3D"color:#000">std</span><span style=3D"color:#660">::</sp=
an><span style=3D"color:#000">vector</span><span style=3D"color:#660"><<=
/span><span style=3D"color:#000">T</span><span style=3D"color:#660">>>=
;</span><span style=3D"color:#000"> </span><span style=3D"color:#660">{</sp=
an><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color=
:#008">using</span><span style=3D"color:#000"> type </span><span style=3D"c=
olor:#660">=3D</span><span style=3D"color:#000"> T</span><span style=3D"col=
or:#660">;</span><span style=3D"color:#000"><br></span><span style=3D"color=
:#660">};</span><span style=3D"color:#000"><br><br></span><span style=3D"co=
lor:#008">template</span><span style=3D"color:#660"><</span><span style=
=3D"color:#008">class</span><span style=3D"color:#000"> T</span><span style=
=3D"color:#660">></span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#008">struct</span><span style=3D"color:#000"> value_type</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">list</span><=
span style=3D"color:#660"><</span><span style=3D"color:#000">T</span><sp=
an 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">using</span><span style=3D"color:#000=
"> type </span><span style=3D"color:#660">=3D</span><span style=3D"color:#0=
00"> T</span><span style=3D"color:#660">;</span><span style=3D"color:#000">=
<br></span><span style=3D"color:#660">};</span><span style=3D"color:#000"><=
br><br></span><span style=3D"color:#800">// and everything else for which t=
here is begin(T)</span><span style=3D"color:#000"><br><br></span><span styl=
e=3D"color:#008">template</span><span style=3D"color:#660"><</span><span=
style=3D"color:#008">typename</span><span style=3D"color:#000"> T</span><s=
pan style=3D"color:#660">></span><span style=3D"color:#000"><br></span><=
span style=3D"color:#008">using</span><span style=3D"color:#000"> value_typ=
e_t </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000">=
</span><span style=3D"color:#008">typename</span><span style=3D"color:#000=
"> value_type</span><span style=3D"color:#660"><</span><span style=3D"co=
lor:#000">T</span><span style=3D"color:#660">>::</span><span style=3D"co=
lor:#000">type</span><span style=3D"color:#660">;</span><span style=3D"colo=
r:#000"><br></span></div></code></div></span><span style=3D"font-family:cou=
rier new,monospace"><br><font face=3D"arial,sans-serif">although there may =
well be a simpler approach which exploits <span style=3D"font-family:courie=
r new,monospace">begin</span>, <span style=3D"font-family:courier new,monos=
pace">end</span> or member <span style=3D"font-family:courier new,monospace=
">value_type</span>.</font><br></span></div></blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/45df670c-da8b-453c-9a87-b2936493fc75%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/45df670c-da8b-453c-9a87-b2936493fc75=
%40isocpp.org</a>.<br />
------=_Part_3139_289172059.1481427092370--
------=_Part_3138_2665514.1481427092369--
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Sat, 10 Dec 2016 23:08:05 -0500
Raw View
<html><head></head><body lang=3D"en-US" style=3D"background-color: rgb(255,=
255, 255); line-height: initial;"> =
<div style=3D"width: 100%; fo=
nt-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif=
; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, =
255, 255);">Use declval<T>() instead of casting null. </div> =
=
<div style=3D"width: 100%;=
font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-se=
rif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(25=
5, 255, 255);"><br style=3D"display:initial"></div> =
=
=
<div style=3D"font-size: initial; font-family: Calibri=
, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-align:=
initial; background-color: rgb(255, 255, 255);">Sent from my&nbs=
p;BlackBerry portable Babbage Device</div> =
=
=
<table width=3D"100%" style=3D"background-color:white;border-spac=
ing:0px;"> <tbody><tr><td colspan=3D"2" style=3D"font-size: initial; text-a=
lign: initial; background-color: rgb(255, 255, 255);"> =
<div style=3D"border-style: solid none none; border-top-color: rgb(18=
1, 196, 223); border-top-width: 1pt; padding: 3pt 0in 0in; font-family: Tah=
oma, 'BB Alpha Sans', 'Slate Pro'; font-size: 10pt;"> <div><b>From: </b>De=
rek Ross</div><div><b>Sent: </b>Saturday, December 10, 2016 10:31 PM</div><=
div><b>To: </b>ISO C++ Standard - Future Proposals</div><div><b>Reply To: <=
/b>std-proposals@isocpp.org</div><div><b>Subject: </b>[std-proposals] Re: v=
alue_type<T></div></div></td></tr></tbody></table><div style=3D"borde=
r-style: solid none none; border-top-color: rgb(186, 188, 209); border-top-=
width: 1pt; font-size: initial; text-align: initial; background-color: rgb(=
255, 255, 255);"></div><br><div id=3D"_originalContent" style=3D""><div dir=
=3D"ltr">The following seems to work:<br><br><div class=3D"prettyprint" sty=
le=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187=
); border-style: solid; border-width: 1px; word-wrap: break-word;"><code cl=
ass=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">template</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">typename</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">></span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">str=
uct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> value_=
type<br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">usi=
ng</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> type </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">decltype</span><span style=
=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: #008;" class=
=3D"styled-by-prettify">begin</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(*((</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">*)(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">NUL=
L</span><span style=3D"color: #660;" class=3D"styled-by-prettify">))));</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><sp=
an 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"col=
or: #000;" class=3D"styled-by-prettify"> main</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br> cout </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">typeid</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">value_type</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
"><</span><span style=3D"color: #008;" class=3D"styled-by-prettify">stri=
ng</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span>=
<span style=3D"color: #066;" class=3D"styled-by-prettify">10</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">]>::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">type</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">).</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">name</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify"><<</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> endl</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">  =
; <br> cout </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify"><<</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">typeid</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">val=
ue_type</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 s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">vector</span><span style=
=3D"color: #660;" 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"> </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">float</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">*>>::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">type</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">).</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">name</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify"><<</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> endl</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> <br> cout <=
/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">typeid</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">value_type</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">list</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">array</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">char</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066=
;" class=3D"styled-by-prettify">5</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">>>>::</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">type</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">).</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">name</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> endl</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>&n=
bsp; cout </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify"><<</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">typei=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">string</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">).</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">name</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #00=
0;" 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"> endl</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br> cout </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">typeid</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"> </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">float</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">*).</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">name</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><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> endl</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> cout </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><<</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">typeid</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 s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">array</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">char</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: #066;" class=3D"sty=
led-by-prettify">5</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">>).</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">name</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify"><<</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> endl</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">...</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">output</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">...</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br></span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
Ss</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #606;" class=3D"styled-by-prettify">PKf</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #606;" class=3D"styled-by-prettify">St5arrayIcLm5EE</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Ss</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #60=
6;" class=3D"styled-by-prettify">PKf</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span><span style=3D"color: #606;" class=3D"=
styled-by-prettify">St5arrayIcLm5EE</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br></span></div></code></div><br><br><br><br>On Saturda=
y, December 10, 2016 at 8:49:45 PM UTC-6, John McFarlane wrote:<blockquote =
class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1p=
x #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">A type trait that, given =
a container type, yields the element type:<br><br><div style=3D"background-=
color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bor=
der-width:1px"><code><div><span style=3D"color:#000">value_type_t</span><sp=
an style=3D"color:#660"><</span><span style=3D"color:#008">string</span>=
<span style=3D"color:#660">[</span><span style=3D"color:#066">10</span><spa=
n style=3D"color:#660">]></span><span style=3D"color:#000"> </span><span=
style=3D"color:#800">// string</span><span style=3D"color:#000"><br>value_=
type</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">v=
ector</span><span style=3D"color:#660"><</span><span style=3D"color:#008=
">const</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>float</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
*>>::</span><span style=3D"color:#000">type </span><span style=3D"col=
or:#800">// const float *</span><span style=3D"color:#000"><br>value_type_t=
</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">list<=
/span><span style=3D"color:#660"><</span><span style=3D"color:#000">arra=
y</span><span style=3D"color:#660"><</span><span style=3D"color:#008">c<=
wbr>har</span><span style=3D"color:#660">,</span><span style=3D"color:#000"=
> </span><span style=3D"color:#066">5</span><span style=3D"color:#660">>=
>></span><span style=3D"color:#000"> </span><span style=3D"color:#800=
">// array<char, 5></span></div></code></div><br>Possible implementat=
ion along the lines of<br><span style=3D"font-family:courier new,monospace"=
><br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,1=
87,187);border-style:solid;border-width:1px"><code><div><span style=3D"colo=
r:#008">template</span><span style=3D"color:#660"><</span><span style=3D=
"color:#008">class</span><span style=3D"color:#000"> T</span><span style=3D=
"color:#660">></span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">struct</span><span style=3D"color:#000"> value_type</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"><<=
/span><span style=3D"color:#008">class</span><span style=3D"color:#000"> T<=
/span><span style=3D"color:#660">,</span><span style=3D"color:#000"> std</s=
pan><span style=3D"color:#660">::</span><span style=3D"color:#000">size_t N=
</span><span style=3D"color:#660">></span><span style=3D"color:#000"><br=
></span><span style=3D"color:#008">struct</span><span style=3D"color:#000">=
value_type</span><span style=3D"color:#660"><</span><span style=3D"colo=
r:#000">T</span><span style=3D"color:#660">[</span><span style=3D"color:#00=
0">N</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=
> </span><span style=3D"color:#008">using</span><span style=3D=
"color:#000"> type </span><span style=3D"color:#660">=3D</span><span style=
=3D"color:#000"> T</span><span style=3D"color:#660">;</span><span style=3D"=
color:#000"><br></span><span style=3D"color:#660">};</span><span style=3D"c=
olor:#000"><br><br></span><span style=3D"color:#008">template</span><span s=
tyle=3D"color:#660"><</span><span style=3D"color:#008">class</span><span=
style=3D"color:#000"> T</span><span style=3D"color:#660">></span><span =
style=3D"color:#000"><br></span><span style=3D"color:#008">struct</span><sp=
an style=3D"color:#000"> value_type</span><span style=3D"color:#660"><</=
span><span style=3D"color:#000">std</span><span style=3D"color:#660">::</sp=
an><span style=3D"color:#000">vector</span><span style=3D"color:#660"><<=
/span><span style=3D"color:#000">T</span><span style=3D"color:#660">>>=
;</span><span style=3D"color:#000"> </span><span style=3D"color:#660">{</sp=
an><span style=3D"color:#000"><br> </span><span style=3D"color=
:#008">using</span><span style=3D"color:#000"> type </span><span style=3D"c=
olor:#660">=3D</span><span style=3D"color:#000"> T</span><span style=3D"col=
or:#660">;</span><span style=3D"color:#000"><br></span><span style=3D"color=
:#660">};</span><span style=3D"color:#000"><br><br></span><span style=3D"co=
lor:#008">template</span><span style=3D"color:#660"><</span><span style=
=3D"color:#008">class</span><span style=3D"color:#000"> T</span><span style=
=3D"color:#660">></span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#008">struct</span><span style=3D"color:#000"> value_type</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">list</span><=
span style=3D"color:#660"><</span><span style=3D"color:#000">T</span><sp=
an style=3D"color:#660">>></span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">{</span><span style=3D"color:#000"><br> &nb=
sp; </span><span style=3D"color:#008">using</span><span style=3D"color:#000=
"> type </span><span style=3D"color:#660">=3D</span><span style=3D"color:#0=
00"> T</span><span style=3D"color:#660">;</span><span style=3D"color:#000">=
<br></span><span style=3D"color:#660">};</span><span style=3D"color:#000"><=
br><br></span><span style=3D"color:#800">// and everything else for which t=
here is begin(T)</span><span style=3D"color:#000"><br><br></span><span styl=
e=3D"color:#008">template</span><span style=3D"color:#660"><</span><span=
style=3D"color:#008">typename</span><span style=3D"color:#000"> T</span><s=
pan style=3D"color:#660">></span><span style=3D"color:#000"><br></span><=
span style=3D"color:#008">using</span><span style=3D"color:#000"> value_typ=
e_t </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000">=
</span><span style=3D"color:#008">typename</span><span style=3D"color:#000=
"> value_type</span><span style=3D"color:#660"><</span><span style=3D"co=
lor:#000">T</span><span style=3D"color:#660">>::</span><span style=3D"co=
lor:#000">type</span><span style=3D"color:#660">;</span><span style=3D"colo=
r:#000"><br></span></div></code></div></span><span style=3D"font-family:cou=
rier new,monospace"><br><font face=3D"arial,sans-serif">although there may =
well be a simpler approach which exploits <span style=3D"font-family:courie=
r new,monospace">begin</span>, <span style=3D"font-family:courier new,monos=
pace">end</span> or member <span style=3D"font-family:courier new,monospace=
">value_type</span>.</font><br></span></div></blockquote></div>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/45df670c-da8b-453c-9a87-b2936493fc75%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/45df670c-da8b-453c-9a87-b2936493=
fc75%40isocpp.org</a>.<br>
<br><!--end of _originalContent --></div></body></html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/20161211040805.4878409.14424.21250%40=
gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com=
/a/isocpp.org/d/msgid/std-proposals/20161211040805.4878409.14424.21250%40gm=
ail.com</a>.<br />
.
Author: John McFarlane <mcfarlane.john@gmail.com>
Date: Sat, 10 Dec 2016 21:43:21 -0800 (PST)
Raw View
------=_Part_1287_389257320.1481435001764
Content-Type: multipart/alternative;
boundary="----=_Part_1288_396183451.1481435001765"
------=_Part_1288_396183451.1481435001765
Content-Type: text/plain; charset=UTF-8
On Saturday, December 10, 2016 at 8:08:35 PM UTC-8, Tony V E wrote:
>
> Use declval<T>() instead of casting null.
>
You also need to remove the reference. This might work:
template<class T>
struct value_type {
using type = typename std::remove_reference<decltype(*std::begin(declval
<T&>()))>::type;
};
Regardless, I would prefer not to ever have to type something like this!
I've needed it before and gone hunting online for a concise solution. And
it came up in relation to a proposal on SG14:
https://groups.google.com/a/isocpp.org/d/topic/sg14/Md3D_7vMpgs/discussion
--
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/cf4cd5fa-f49b-48c4-9282-ef70f21bf4a3%40isocpp.org.
------=_Part_1288_396183451.1481435001765
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Saturday, December 10, 2016 at 8:08:35 PM UTC-8, Tony V=
E wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: =
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div style=3D"backgro=
und-color:rgb(255,255,255);line-height:initial" lang=3D"en-US"> =
<=
div style=3D"width:100%;font-size:initial;font-family:Calibri,'Slate Pr=
o',sans-serif,sans-serif;color:rgb(31,73,125);text-align:initial;backgr=
ound-color:rgb(255,255,255)">Use declval<T>() instead of casting null=
.. </div></div></blockquote><div><br>You also need to remove the reference. =
This might work:<br><br><div style=3D"background-color: rgb(250, 250, 250);=
border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; =
overflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettyprin=
t"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">template</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">class</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">><=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> value_type </span><s=
pan 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><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">using</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> type </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #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"> 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_reference</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">decltype</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(*</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>::</span><span style=3D"color: #008;" class=3D"styled-by-prettify">begin</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">declval</span><span s=
tyle=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">type</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">};</span></div></code></div><br>Regardless, I wou=
ld prefer not to ever have to type something like this! I've
needed it before and gone hunting online for a concise solution. And it
came up in relation to a proposal on SG14:=20
<br>https://groups.google.com/a/isocpp.org/d/topic/sg14/Md3D_7vMpgs/discuss=
ion <br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/cf4cd5fa-f49b-48c4-9282-ef70f21bf4a3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/cf4cd5fa-f49b-48c4-9282-ef70f21bf4a3=
%40isocpp.org</a>.<br />
------=_Part_1288_396183451.1481435001765--
------=_Part_1287_389257320.1481435001764--
.
Author: Marc <marc.glisse@gmail.com>
Date: Sun, 11 Dec 2016 03:26:43 -0800 (PST)
Raw View
------=_Part_953_1602934025.1481455603611
Content-Type: multipart/alternative;
boundary="----=_Part_954_597763777.1481455603612"
------=_Part_954_597763777.1481455603612
Content-Type: text/plain; charset=UTF-8
On Sunday, December 11, 2016 at 6:43:22 AM UTC+1, John McFarlane wrote:
>
> On Saturday, December 10, 2016 at 8:08:35 PM UTC-8, Tony V E wrote:
>>
>> Use declval<T>() instead of casting null.
>>
>
> You also need to remove the reference. This might work:
>
> template<class T>
> struct value_type {
> using type = typename std::remove_reference<decltype(*std::begin(
> declval<T&>()))>::type;
> };
>
> Regardless, I would prefer not to ever have to type something like this!
> I've needed it before and gone hunting online for a concise solution. And
> it came up in relation to a proposal on SG14:
> https://groups.google.com/a/isocpp.org/d/topic/sg14/Md3D_7vMpgs/discussion
>
What type do you want it to return for
std::vector<bool>
? I'd rather get bool than the proxy.
Note that Boost calls this range_value.
--
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/99476d2c-f0a0-4853-aa96-24f476a5e0e1%40isocpp.org.
------=_Part_954_597763777.1481455603612
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Sunday, December 11, 2016 at 6:43:22 AM UTC+1, John McF=
arlane wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
On Saturday, December 10, 2016 at 8:08:35 PM UTC-8, Tony V E wrote:<blockqu=
ote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div style=3D"background-color:rgb(255,255,=
255);line-height:initial" lang=3D"en-US"> =
<div style=3D"width:100=
%;font-size:initial;font-family:Calibri,'Slate Pro',sans-serif,sans=
-serif;color:rgb(31,73,125);text-align:initial;background-color:rgb(255,255=
,255)">Use declval<T>() instead of casting null. </div></div></blockq=
uote><div><br>You also need to remove the reference. This might work:<br><b=
r><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,=
187);border-style:solid;border-width:1px"><code><div><span style=3D"color:#=
008">template</span><span style=3D"color:#660"><</span><span style=3D"co=
lor:#008">class</span><span style=3D"color:#000"> T</span><span style=3D"co=
lor:#660">></span><span style=3D"color:#000"><br></span><span style=3D"c=
olor:#008">struct</span><span style=3D"color:#000"> value_type </span><span=
style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =
</span><span style=3D"color:#008">using</span><span style=3D"color:#000"> t=
ype </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000">=
</span><span style=3D"color:#008">typename</span><span style=3D"color:#000=
"> std</span><span style=3D"color:#660">::</span><span style=3D"color:#000"=
>remove_reference</span><span style=3D"color:#660"><</span><span style=
=3D"color:#008">decltype</span><span style=3D"color:#660"><wbr>(*</span><sp=
an style=3D"color:#000">std</span><span style=3D"color:#660">::</span><span=
style=3D"color:#008">begin</span><span style=3D"color:#660">(</span><span =
style=3D"color:#000">declval</span><span style=3D"color:#660"><</span><s=
pan style=3D"color:#000">T</span><span style=3D"color:#660">&>()))&g=
t;:<wbr>:</span><span style=3D"color:#000">type</span><span style=3D"color:=
#660">;</span><span style=3D"color:#000"><br></span><span style=3D"color:#6=
60">};</span></div></code></div><br>Regardless, I would prefer not to ever =
have to type something like this! I've
needed it before and gone hunting online for a concise solution. And it
came up in relation to a proposal on SG14:=20
<br><a href=3D"https://groups.google.com/a/isocpp.org/d/topic/sg14/Md3D_7vM=
pgs/discussion" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=
=3D'https://groups.google.com/a/isocpp.org/d/topic/sg14/Md3D_7vMpgs/dis=
cussion';return true;" onclick=3D"this.href=3D'https://groups.googl=
e.com/a/isocpp.org/d/topic/sg14/Md3D_7vMpgs/discussion';return true;">h=
ttps://groups.google.com/a/<wbr>isocpp.org/d/topic/sg14/Md3D_<wbr>7vMpgs/di=
scussion</a> <br></div></div></blockquote><div><br>What type do you want it=
to return for <div style=3D"background-color: rgb(250, 250, 250); border-c=
olor: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflow-=
wrap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div c=
lass=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">vector</=
span><span style=3D"color: #080;" class=3D"styled-by-prettify"><bool>=
</span></div></code></div>? I'd rather get bool than the proxy.<br> Not=
e that Boost calls this range_value.<br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/99476d2c-f0a0-4853-aa96-24f476a5e0e1%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/99476d2c-f0a0-4853-aa96-24f476a5e0e1=
%40isocpp.org</a>.<br />
------=_Part_954_597763777.1481455603612--
------=_Part_953_1602934025.1481455603611--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Sun, 11 Dec 2016 10:47:10 -0800
Raw View
On s=C3=A1bado, 10 de dezembro de 2016 21:43:21 PST John McFarlane wrote:
> On Saturday, December 10, 2016 at 8:08:35 PM UTC-8, Tony V E wrote:
> > Use declval<T>() instead of casting null.
>=20
> You also need to remove the reference. This might work:
>=20
> template<class T>
> struct value_type {
> using type =3D typename std::remove_reference<decltype(*std::begin(de=
clval
> <T&>()))>::type;
> };
This should be the same as
std::iterator_traits<decltype(begin(declval<T&>()))>::value_type
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--=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/3968158.JimyIADOsO%40tjmaciei-mobl1.
.
Author: John McFarlane <mcfarlane.john@gmail.com>
Date: Sun, 11 Dec 2016 12:11:43 -0800 (PST)
Raw View
------=_Part_4086_694777282.1481487103085
Content-Type: multipart/alternative;
boundary="----=_Part_4087_396846581.1481487103085"
------=_Part_4087_396846581.1481487103085
Content-Type: text/plain; charset=UTF-8
On Sunday, December 11, 2016 at 10:47:15 AM UTC-8, Thiago Macieira wrote:
>
> This should be the same as
>
> std::iterator_traits<decltype(begin(declval<T&>()))>::value_type
>
Looks good, thanks.
--
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/6186e827-a2d3-4305-b0fb-b7839426eb25%40isocpp.org.
------=_Part_4087_396846581.1481487103085
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Sunday, December 11, 2016 at 10:47:15 AM UTC-8, Thiago =
Macieira wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-=
left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">This should be =
the same as
<br>
<br>=C2=A0std::iterator_traits<<wbr>decltype(begin(declval<T&>=
()))<wbr>>::value_type
<br></blockquote><div><br>Looks good, thanks. <br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/6186e827-a2d3-4305-b0fb-b7839426eb25%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/6186e827-a2d3-4305-b0fb-b7839426eb25=
%40isocpp.org</a>.<br />
------=_Part_4087_396846581.1481487103085--
------=_Part_4086_694777282.1481487103085--
.
Author: John McFarlane <mcfarlane.john@gmail.com>
Date: Sun, 11 Dec 2016 12:23:01 -0800 (PST)
Raw View
------=_Part_36_1378044099.1481487781803
Content-Type: multipart/alternative;
boundary="----=_Part_37_1645476530.1481487781804"
------=_Part_37_1645476530.1481487781804
Content-Type: text/plain; charset=UTF-8
On Sunday, December 11, 2016 at 3:26:43 AM UTC-8, Marc wrote:
>
> What type do you want it to return for
> std::vector<bool>
> ? I'd rather get bool than the proxy.
> Note that Boost calls this range_value.
>
I'd opt for `bool` because std::vector<bool>::value_type is bool. As in the
previously-mentioned use case, this type would be a special case regardless
as container storage is not sizeof(Element) * size(Container).
Another question that occurres is name: `value_type` versus `element_type`
versus something else. Neither is used in the standard exclusively to
represent the element of a container. So either `value_type` is ambiguous,
a different name is found, or (my preference) it accepts types which are
not containers, e.g. iterator_traits, integral_constant etc..
--
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/3f66e0d6-98a6-42b9-b6c2-19d97cfb669f%40isocpp.org.
------=_Part_37_1645476530.1481487781804
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Sunday, December 11, 2016 at 3:26:43 AM UTC-8, Marc wro=
te:<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">What type =
do you want it to return for <div><div style=3D"background-color:rgb(250,25=
0,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px"><=
code><div><span style=3D"color:#000">std</span><span style=3D"color:#660">:=
:</span><span style=3D"color:#000">vector</span><span style=3D"color:#080">=
<bool></span></div></code></div>? I'd rather get bool than the pr=
oxy.<br> Note that Boost calls this range_value.<br></div></div></blockquot=
e><div><br>I'd opt for `bool` because std::vector<bool>::value_ty=
pe is bool. As in the previously-mentioned use case, this type would be a s=
pecial case regardless as container storage is not sizeof(Element) * size(C=
ontainer). <br><br>Another question that occurres is name: `value_type` ver=
sus `element_type` versus something else. Neither is used in the standard e=
xclusively to represent the element of a container. So either `value_type` =
is ambiguous, a different name is found, or (my preference) it accepts type=
s which are not containers, e.g. iterator_traits, integral_constant etc..<b=
r></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/3f66e0d6-98a6-42b9-b6c2-19d97cfb669f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/3f66e0d6-98a6-42b9-b6c2-19d97cfb669f=
%40isocpp.org</a>.<br />
------=_Part_37_1645476530.1481487781804--
------=_Part_36_1378044099.1481487781803--
.