Topic: any_cast to type with added low-level const -> throws
Author: nicesw123@gmail.com
Date: Thu, 24 Sep 2015 11:03:01 -0700 (PDT)
Raw View
------=_Part_623_878280946.1443117781898
Content-Type: multipart/alternative;
boundary="----=_Part_624_1709236897.1443117781898"
------=_Part_624_1709236897.1443117781898
Content-Type: text/plain; charset=UTF-8
Hello,
std::experimental::any (boost::any) is nice.
What I don't like about the current implementation and proposal
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3804.html>, is
the fact that I cannot any_cast to a type with added low-level const.
Example:
using std::experimental::any;
using std::experimental::any_cast;
char str[] = "a2";
any ay(str);
any_cast<const char*>(ay); // throws, since a const is added!!!
Why should that not be legal??
All it means is a read-only access to the contained type, and that
definitely should be legal.
Compare:
char str2[] = "str2";
static_cast<const char *>(str2); // read-only access (const added)
I've written on the Boost Users mailing list:
http://lists.boost.org/boost-users/2015/09/85097.php
I must say I'm pleased that any is in experimental and is proposed (which
is why I'm writing here): It's a great type for having a container of "any"
type, since it limits the dynamic memory that the container needs per
element (the mem-storage for large contained values residing on the heap).
This in big contranst to variant, which can lead to really fat memory-usage
in a container, if it is used to also be able to hold a fat type; even if
most elements in a container of that variant, might be small. (My optimum
would be a variant that contains needed small types as well as any)
I hope any_cast'ing to a type with added low-level can be
* realized (is it possible to do safely?)
* be regarded as nice additional requirement for the recommendation.
Thanks for comments,
Regards,
n.
--
---
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_624_1709236897.1443117781898
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hello,<br><br><span style=3D"font-family: courier new,mono=
space;">std::experimental::any</span> (<span style=3D"font-family: courier =
new,monospace;"><code>boost::any</code></span>) is nice.<br>What I=20
don't like about the current implementation and <a href=3D"http://www.o=
pen-std.org/jtc1/sc22/wg21/docs/papers/2013/n3804.html">proposal</a>, is th=
e fact=20
that I cannot <span style=3D"font-family: courier new,monospace;">any_cast<=
/span> to a type with added low-level const.<br><br><br>Example:<br><div cl=
ass=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-c=
olor: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap=
: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">using</span><span s=
tyle=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">experimental</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">any</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">using</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">experime=
ntal</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">any_cast</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">char</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> str</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"style=
d-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&=
quot;a2"</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>an=
y ay</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">str</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>any_cast</span><span sty=
le=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">char</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">*>(</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">ay</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// th=
rows, since a const is added!!!</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br></span></div></code></div><br><br>Why should that =
not be legal??<br>All it means is a read-only access to the contained type,=
and that definitely should be legal.<br><br>Compare:<br><div class=3D"pret=
typrint" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(1=
87, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-wor=
d;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">char</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> str2</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">=3D</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettif=
y">"str2"</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">static=
_cast</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 st=
yle=3D"color: #008;" class=3D"styled-by-prettify">char</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">str2</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-pr=
ettify">// read-only access (const added)</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span></div></code></div><br><br>I'=
ve written on the Boost Users mailing list:<br><a href=3D"http://lists.boos=
t.org/boost-users/2015/09/85097.php">http://lists.boost.org/boost-users/201=
5/09/85097.php<span class=3D"sewmmu7y6s80zfh"></span><span class=3D"sewmmu7=
y6s80zfh"></span></a><br><br>I must say I'm pleased that <span style=3D=
"font-family: courier new,monospace;">any</span> is in experimental and is =
proposed (which is why I'm writing here): It's a great type for=20
having a container of "any" type, since it limits the dynamic mem=
ory=20
that the container needs per element (the mem-storage for large=20
contained values residing on the heap). This in big contranst to=20
variant, which can lead to really fat memory-usage in a container, if it
is used to also be able to hold a fat type; even if most elements in a con=
tainer=20
of that variant, might be small. (My optimum would be a variant that contai=
ns needed small types as well as <span style=3D"font-family: courier new,mo=
nospace;">any</span>)<br><br>I hope <span style=3D"font-family: courier new=
,monospace;">any_cast</span>'ing to a type with added low-level can be<=
br>* realized (is it possible to do safely?)<br>* be regarded as nice addit=
ional requirement for the recommendation.<br><br>Thanks for comments,<br>Re=
gards,<br>n.<br><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" 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_624_1709236897.1443117781898--
------=_Part_623_878280946.1443117781898--
.
Author: nicesw123@gmail.com
Date: Thu, 24 Sep 2015 11:54:41 -0700 (PDT)
Raw View
------=_Part_452_56705717.1443120881361
Content-Type: multipart/alternative;
boundary="----=_Part_453_872990698.1443120881362"
------=_Part_453_872990698.1443120881362
Content-Type: text/plain; charset=UTF-8
>
>
> I hope any_cast'ing to a type with added low-level const can be
> * realized (is it possible to do safely?)
>
How can we juggle and compare if one pointer-type is the same as another,
but with low-level added?
Perhaps like this:
#include <iostream>
#include <cassert>
#include <type_traits>
int main()
{
using T1 = const char *;
using T2 = char *;
if (std::is_same< std::remove_pointer<T1>::type,
typename std::add_const<std::remove_pointer<T2>::type>::
type>()) {
std::cout << "adding low-level const to T2 <===same type as===> T1" <<
std::endl;
}
return 0;
}
How can we determine if something is a pointer (or pointer to const) ?
Perhaps like this:
#include <iostream>
#include <cassert>
#include <type_traits>
enum type_enu {non_pointer, pointer, pointer_to_const};
template <typename T>
constexpr type_enu is_of_type(T t)
{
return non_pointer;
}
template <typename T>
constexpr type_enu is_of_type(T *t)
{
return pointer;
}
template <typename T>
constexpr type_enu is_of_type(const T *t)
{
return pointer_to_const;
}
constexpr const char * type_to_string(type_enu enu)
{
return ((enu == non_pointer)
? "non_pointer"
: ((enu == pointer)
? "pointer"
: "pointer_to_const"));
}
#define PRINT_TYPE(T) std::cout << #T " is " <<
type_to_string(is_of_type(T{})) << std::endl
int main()
{
using T0 = char;
using T1 = const char *;
using T2 = char *;
PRINT_TYPE(T0);
PRINT_TYPE(T1);
PRINT_TYPE(T2);
return 0;
}
--
---
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_453_872990698.1443120881362
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr"><br>I hope <span style=3D"font-family:courier new,monospace">any_cast</=
span>'ing to a type with added low-level const can be<br>* realized (is=
it possible to do safely?)<br></div></blockquote><div><br>How can we juggl=
e and compare if one pointer-type is the same as another, but with low-leve=
l added?<br>Perhaps like this:<br><br><div class=3D"prettyprint" style=3D"b=
ackground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); bord=
er-style: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"=
prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #800;" cla=
ss=3D"styled-by-prettify">#include</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"style=
d-by-prettify"><iostream></span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br></span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">#include</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-pretti=
fy"><cassert></span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span><span style=3D"color: #800;" class=3D"styled-by-prettif=
y">#include</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #080;" class=3D"styled-by-prettify"><type=
_traits></span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">i=
nt</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> main</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">using</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> T1 </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"style=
d-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"=
>char</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">*;</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">using</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> T2 </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0 =C2=A0 </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">char</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">*;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">if</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">is_same</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0std</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">remove_pointer</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">T1</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">>::</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">type</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">typename</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: #000;" class=3D"styled-by-prettify">add_co=
nst</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">std</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">remove_pointer</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">T2</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">>::</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">type</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">>::</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">type</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">>())</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>=C2=A0 =C2=A0 std</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>cout </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><=
<</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #080;" class=3D"styled-by-prettify">"adding lo=
w-level const to T2 <=3D=3D=3Dsame type as=3D=3D=3D> T1"</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify"><<</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">endl</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 </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 </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">return</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">0<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> <br></span></div></code></div><br>=
<br>How can we determine if something is a pointer (or pointer to const) ?<=
br>Perhaps like this:<br><br><div class=3D"prettyprint" style=3D"background=
-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style:=
solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #800;" class=3D"sty=
led-by-prettify">#include</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-pret=
tify"><iostream></span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #800;" class=3D"styled-by-pret=
tify">#include</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify"><c=
assert></span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #800;" class=3D"styled-by-prettify">#inclu=
de</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #080;" class=3D"styled-by-prettify"><type_traits&g=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">enum</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> type_enu </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">non_pointer</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> pointer</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> pointer_to_const</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;" c=
lass=3D"styled-by-prettify">template</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">typename</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>></span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> type_enu is=
_of_type</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">T t</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">return</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> non_pointer</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"st=
yled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">template</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: #008;" class=3D"styled-by-prettify">typename</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</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">constexpr</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> type_enu is_of_type</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;" cla=
ss=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-pr=
ettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">return=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> pointer</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color:=
#008;" class=3D"styled-by-prettify">template</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">typename</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">></span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">co=
nstexpr</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> ty=
pe_enu is_of_type</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">co=
nst</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T </sp=
an><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: #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 </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> pointer_to_const</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">co=
nstexpr</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">const</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">char</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">*</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> type_to_string</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">type_enu enu</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>return</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">((</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">enu </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> non_pointer</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>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">?</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #080;" class=3D"styled-by-prettify">"non_pointer"<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
((</span><span style=3D"color: #000;" class=3D"styled-by-prettify">enu </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> pointer</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">?</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&quo=
t;pointer"</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" =
class=3D"styled-by-prettify">"pointer_to_const"</span><span style=
=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: #800;" class=
=3D"styled-by-prettify">#define</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> PRINT_TYPE</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> st=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">cout </span><span=
style=3D"color: #660;" class=3D"styled-by-prettify"><<</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #800;" class=3D"styled-by-prettify">#T " is " << type=
_to_string(is_of_type(T{})) << std::endl</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> main</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">using</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T0=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0 =
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">cha=
r</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 </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">using</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> T1 </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">const</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">char</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 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">usi=
ng</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T2 </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0 =C2=A0=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">char</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">*;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 PRINT_TYPE</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">T0</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>=C2=A0 PRINT_TYPE</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">T1</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>=C2=A0 PRINT_TYPE</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">T2</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>=C2=A0 <br>=C2=A0 </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">return</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pretti=
fy">0</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></div></code=
></div><br> <br><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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_453_872990698.1443120881362--
------=_Part_452_56705717.1443120881361--
.
Author: David Krauss <potswa@gmail.com>
Date: Fri, 25 Sep 2015 06:10:11 +0800
Raw View
--Apple-Mail=_3F2B8FC3-21C5-497D-9B84-3A557412BC05
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9309=E2=80=9325, at 2:03 AM, nicesw123@gmail.com wrote:
>=20
> std::experimental::any (boost::any) is nice.
> What I don't like about the current implementation and proposal <http://w=
ww.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3804.html>, is the fact th=
at I cannot any_cast to a type with added low-level const.
I have written as proposal (bit.ly/reccast <http://bit.ly/reccast>) to repl=
ace any_cast with something allowing the const inside the template argument=
to appertain to the contained type. However, since any is in charge of all=
ocating its object, there=E2=80=99s no way to guarantee that it is =E2=80=
=9Clow-level const.=E2=80=9D The closest you can get is to use a const any.=
Following my proposal in this case, you=E2=80=99d never put const inside t=
he template argument; it would apply the qualifier from const any.
const any a =3D 5; // Likely =E2=80=9Clow-level const=E2=80=9D by small-obj=
ect optimization.
int const & five =3D std::recover< int >( a ); // OK
int & fiveish =3D std::recover< int >( a ); // Error, cannot cast away cons=
t.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_3F2B8FC3-21C5-497D-9B84-3A557412BC05
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9309=
=E2=80=9325, at 2:03 AM, <a href=3D"mailto:nicesw123@gmail.com" class=3D"">=
nicesw123@gmail.com</a> wrote:</div><br class=3D"Apple-interchange-newline"=
><div class=3D""><span style=3D"font-size: 12px; font-style: normal; font-v=
ariant: normal; font-weight: normal; letter-spacing: normal; line-height: n=
ormal; orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-st=
roke-width: 0px; font-family: 'courier new', monospace;" class=3D"">std::ex=
perimental::any</span><span style=3D"font-family: Helvetica; font-size: 12p=
x; font-style: normal; font-variant: normal; font-weight: normal; letter-sp=
acing: normal; line-height: normal; orphans: auto; text-align: start; text-=
indent: 0px; text-transform: none; white-space: normal; widows: auto; word-=
spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline =
!important;" class=3D""><span class=3D"Apple-converted-space"> </span>=
(</span><span style=3D"font-size: 12px; font-style: normal; font-variant: n=
ormal; font-weight: normal; letter-spacing: normal; line-height: normal; or=
phans: auto; text-align: start; text-indent: 0px; text-transform: none; whi=
te-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-widt=
h: 0px; font-family: 'courier new', monospace;" class=3D""><code class=3D""=
>boost::any</code></span><span style=3D"font-family: Helvetica; font-size: =
12px; font-style: normal; font-variant: normal; font-weight: normal; letter=
-spacing: normal; line-height: normal; orphans: auto; text-align: start; te=
xt-indent: 0px; text-transform: none; white-space: normal; widows: auto; wo=
rd-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inli=
ne !important;" class=3D"">) is nice.</span><br style=3D"font-family: Helve=
tica; font-size: 12px; font-style: normal; font-variant: normal; font-weigh=
t: normal; letter-spacing: normal; line-height: normal; orphans: auto; text=
-align: start; text-indent: 0px; text-transform: none; white-space: normal;=
widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D=
""><span style=3D"font-family: Helvetica; font-size: 12px; font-style: norm=
al; font-variant: normal; font-weight: normal; letter-spacing: normal; line=
-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-t=
ransform: none; white-space: normal; widows: auto; word-spacing: 0px; -webk=
it-text-stroke-width: 0px; float: none; display: inline !important;" class=
=3D"">What I don't like about the current implementation and<span class=3D"=
Apple-converted-space"> </span></span><a href=3D"http://www.open-std.o=
rg/jtc1/sc22/wg21/docs/papers/2013/n3804.html" style=3D"font-family: Helvet=
ica; font-size: 12px; font-style: normal; font-variant: normal; font-weight=
: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-=
align: start; text-indent: 0px; text-transform: none; white-space: normal; =
widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D"=
">proposal</a><span style=3D"font-family: Helvetica; font-size: 12px; font-=
style: normal; font-variant: normal; font-weight: normal; letter-spacing: n=
ormal; line-height: normal; orphans: auto; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: auto; word-spacing:=
0px; -webkit-text-stroke-width: 0px; float: none; display: inline !importa=
nt;" class=3D"">, is the fact that I cannot<span class=3D"Apple-converted-s=
pace"> </span></span><span style=3D"font-size: 12px; font-style: norma=
l; font-variant: normal; font-weight: normal; letter-spacing: normal; line-=
height: normal; orphans: auto; text-align: start; text-indent: 0px; text-tr=
ansform: none; white-space: normal; widows: auto; word-spacing: 0px; -webki=
t-text-stroke-width: 0px; font-family: 'courier new', monospace;" class=3D"=
">any_cast</span><span style=3D"font-family: Helvetica; font-size: 12px; fo=
nt-style: normal; font-variant: normal; font-weight: normal; letter-spacing=
: normal; line-height: normal; orphans: auto; text-align: start; text-inden=
t: 0px; text-transform: none; white-space: normal; widows: auto; word-spaci=
ng: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !impo=
rtant;" class=3D""><span class=3D"Apple-converted-space"> </span>to a =
type with added low-level const.</span><br style=3D"font-family: Helvetica;=
font-size: 12px; font-style: normal; font-variant: normal; font-weight: no=
rmal; letter-spacing: normal; line-height: normal; orphans: auto; text-alig=
n: start; text-indent: 0px; text-transform: none; white-space: normal; wido=
ws: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""></=
div></blockquote></div><br class=3D""><div class=3D"">I have written as pro=
posal (<a href=3D"http://bit.ly/reccast" class=3D"">bit.ly/reccast</a>) to =
replace <font face=3D"Courier" class=3D"">any_cast</font> with something al=
lowing the <font face=3D"Courier" class=3D"">const</font> inside the templa=
te argument to appertain to the contained type. However, since <font face=
=3D"Courier" class=3D"">any</font> is in charge of allocating its object, t=
here=E2=80=99s no way to guarantee that it is =E2=80=9Clow-level <font face=
=3D"Courier" class=3D"">const</font>.=E2=80=9D The closest you can get is t=
o use a <font face=3D"Courier" class=3D"">const any</font>. Following my pr=
oposal in this case, you=E2=80=99d never put <font face=3D"Courier" class=
=3D"">const</font> inside the template argument; it would apply the qualifi=
er from <font face=3D"Courier" class=3D"">const any</font>.</div><div class=
=3D""><br class=3D""></div><div class=3D""><font face=3D"Courier" class=3D"=
">const any a =3D 5; // Likely =E2=80=9Clow-level const=E2=80=9D =
by small-object optimization.</font></div><div class=3D""><font face=3D"Cou=
rier" class=3D"">int const & five =3D std::recover< int >( a ); /=
/ OK</font></div><div class=3D""><font face=3D"Courier" class=3D"">int &=
; fiveish =3D std::recover< int >( a ); // Error, cannot cast away co=
nst.</font></div><div class=3D""><br class=3D""></div></body></html>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--Apple-Mail=_3F2B8FC3-21C5-497D-9B84-3A557412BC05--
.
Author: ajneu1@gmail.com
Date: Sat, 26 Sep 2015 13:31:33 -0700 (PDT)
Raw View
------=_Part_868_68605322.1443299493368
Content-Type: multipart/alternative;
boundary="----=_Part_869_1921769300.1443299493371"
------=_Part_869_1921769300.1443299493371
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Friday, September 25, 2015 at 12:10:23 AM UTC+2, David Krauss wrote:
>
>
> On 2015=E2=80=9309=E2=80=9325, at 2:03 AM, nice...@gmail.com <javascript:=
> wrote:
>
> std::experimental::any (boost::any) is nice.
> What I don't like about the current implementation and proposal=20
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3804.html>, is=
=20
> the fact that I cannot any_cast to a type with added low-level const.
>
>
> I have written as proposal (bit.ly/reccast) to replace any_cast with=20
> something allowing the const inside the template argument to appertain to=
=20
> the contained type. However, since any is in charge of allocating its=20
> object, there=E2=80=99s no way to guarantee that it is =E2=80=9Clow-level=
const.=E2=80=9D The=20
> closest you can get is to use a const any. Following my proposal in this=
=20
> case, you=E2=80=99d never put const inside the template argument; it woul=
d apply=20
> the qualifier from const any.
>
> const any a =3D 5; // Likely =E2=80=9Clow-level const=E2=80=9D by small-o=
bject optimization.
> int const & five =3D std::recover< int >( a ); // OK
> int & fiveish =3D std::recover< int >( a ); // Error, cannot cast away co=
nst.
>
>
Hi David,
how do you like the following code-example?
It's a demonstration of any_casting to a type with added low*est*-level=20
const.
(it uses myany_cast, where MyAny is just a derived-class of=20
std::experimental::any)
#include <iostream>
#include <cassert>
#include <type_traits>
#include <typeinfo>
#include <experimental/any>
// remove_lowest_const ... same as in=20
.../2_remove_lowest_level_const/main.cpp
template<typename T, typename Enable =3D void>
struct remove_lowest_const
{
using type =3D typename std::remove_const<T>::type;
};
template<typename T>
struct remove_lowest_const<T, typename std::enable_if<std::is_pointer<T>::v=
alue=20
&&
std::is_const< T>::v=
alue=20
>::type>
{
using type =3D typename std::add_const<
typename std::add_pointer<
typename remove_lowest_const< typename std::remove_pointe=
r
<T>::type >::type >::type >::type;
};
template<typename T>
struct remove_lowest_const<T, typename std::enable_if<std::is_pointer<T>::v=
alue=20
&&
! std::is_const< T>::v=
alue=20
>::type>
{
using type =3D typename std::add_pointer<
typename remove_lowest_const< typename std::remove_pointer=
<
T>::type >::type >::type;
};
using std::experimental::any;
using std::experimental::any_cast;
class MyAny : public any {
public:
MyAny() : any(), curr_type{&typeid(void)}
{}
MyAny(const MyAny& other) : any{other}, curr_type{other.curr_type}
{}
MyAny(MyAny&& other) : any{std::move(other)}, curr_type{other.curr_type}
{}
template <typename ValueType>
MyAny(ValueType&& value) : any(std::forward<ValueType>(value)), curr_type
{&typeid(typename std::decay<ValueType>::type)}
{}
MyAny& operator=3D(const MyAny& rhs) {
static_cast<any&>(*this).operator=3D(rhs);
curr_type =3D rhs.curr_type;
return *this;
}
MyAny& operator=3D(MyAny&& rhs) {
static_cast<any&>(*this).operator=3D(std::move(rhs));
curr_type =3D rhs.curr_type;
return *this;
}
template<typename ValueType>
MyAny& operator=3D(ValueType&& rhs)
{
static_cast<any&>(*this).operator=3D(std::forward<ValueType>(rhs));
curr_type =3D rhs.curr_type;
return *this;
}
private:
const std::type_info *curr_type;
template<typename T> friend T myany_cast(MyAny &ay);
};
template<typename T>
T myany_cast(MyAny &ay)
{
return ((&typeid(T) =3D=3D ay.curr_type)
? any_cast<T>(ay)
: ((&typeid(typename remove_lowest_const<T>::type) =3D=3D ay.curr=
_type
)
? (
#ifndef NDEBUG
(std::cout << "(removing lowest-level const)" << std::endl)=
,
#endif
const_cast<T>(any_cast<typename remove_lowest_const<T>::typ=
e
>(ay)))
: /* fail */ any_cast<T>(ay)));
}
int main()
{
char str[] =3D "asdf";
{
any ay{str};
std::cout << "***try normal any_cast:" << std::endl;
try {
std::cout << any_cast<char const*>(ay) << std::endl;
}
catch(const std::experimental::bad_any_cast &e) {
std::cout << "fails" << std::endl; // will go=
=20
here
}
}
std::cout << "\n" << std::endl;
{
MyAny may{str};
std::cout << "***try myany_cast:" << std::endl;
try {
std::cout << myany_cast<char const*>(may) << std::endl; // will go=
=20
here!!
}
catch(const std::experimental::bad_any_cast &e) {
std::cout << "fails" << std::endl;
}
}
std::cout << "\n" << std::endl;
{
char *x =3D str;
MyAny may{&x};
std::cout << "***try myany_cast:" << std::endl;
try {
std::cout << *myany_cast<char const* *>(may) << std::endl; // will go=
=20
here!!
}
catch(const std::experimental::bad_any_cast &e) {
std::cout << "fails" << std::endl;
}
}
return 0;
}
But this is no silver bullet, though...
It works only for added lowest(!) level const. If we add various low/mid=20
level consts, then it will not work.
Example:
{
char str[] =3D "asdf";
char *x =3D str;
MyAny may{&x};
std::cout << "***try myany_cast:" << std::endl;
try {
std::cout << *myany_cast<char const* const*>(may) << std::endl;
}
catch(const std::experimental::bad_any_cast &e) {
std::cout << "this is no sliver bullet, since if we want to=20
myany_cast to a type with multiple low-level consts, we'd have to compare=
=20
various permutations (!) of const-removal with the actual typeid=20
(curr_type)" << std::endl;
}
}
Ultimately it would be nice to have a efficient method of any_casting to=20
arbitary low-level const'ed type T1 from an any holding type T2,=20
in other words, where same_type_and_t1_possib_recurse_lowlev_const<T1, T2>(=
)=20
holds true.
template<typename T1, typename T2>
constexpr bool same_type_and_t1_possib_recurse_lowlev_const()
/*
T2 SAME as T1 (possibly by adding low-level consts to T2)
*/
{
return ((!(!std::is_const<T1>::value && std::is_const<T2>::value)) &&
( std::is_pointer<T1>::value =3D=3D std::is_pointer<T2>::value) =
&&
( std::is_pointer<T1>::value
? same_type_and_t1_possib_recurse_lowlev_const<typename std::
remove_pointer<T1>::type,
typename std::
remove_pointer<T2>::type>()
: std::is_same<typename std::remove_const<T1>::type,
typename std::remove_const<T2>::type>::value
));
}
But any has type erasure, so we cannot really "get at" the type T2 that an=
=20
any is holding.
It seems we have to work with typeid.
It sure would be cool if typeid had efficient methods of checking if one=20
std::type_info is the same as another std::type_info (except possibly for=
=20
one having added low-level consts).=20
Some expert needs to check that that out, if that is possible!
Regards,
a.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_869_1921769300.1443299493371
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<br><br>On Friday, September 25, 2015 at 12:10:23 AM UTC+2, David Krauss wr=
ote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex=
;border-left: 1px #ccc solid;padding-left: 1ex;"><div style=3D"word-wrap:br=
eak-word"><br><div><blockquote type=3D"cite"><div>On 2015=E2=80=9309=E2=80=
=9325, at 2:03 AM, <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated=
-mailto=3D"DL90kE6OCAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'j=
avascript:';return true;" onclick=3D"this.href=3D'javascript:';=
return true;">nice...@gmail.com</a> wrote:</div><br><div><span style=3D"fon=
t-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter=
-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-tr=
ansform:none;white-space:normal;word-spacing:0px;font-family:'courier n=
ew',monospace">std::experimental::any</span><span style=3D"font-family:=
Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:=
normal;letter-spacing:normal;line-height:normal;text-align:start;text-inden=
t:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;di=
splay:inline!important"><span>=C2=A0</span>(</span><span style=3D"font-size=
:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spaci=
ng:normal;line-height:normal;text-align:start;text-indent:0px;text-transfor=
m:none;white-space:normal;word-spacing:0px;font-family:'courier new'=
;,monospace"><code>boost:<wbr>:any</code></span><span style=3D"font-family:=
Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:=
normal;letter-spacing:normal;line-height:normal;text-align:start;text-inden=
t:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;di=
splay:inline!important">) is nice.</span><br style=3D"font-family:Helvetica=
;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;le=
tter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;tex=
t-transform:none;white-space:normal;word-spacing:0px"><span style=3D"font-f=
amily:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-w=
eight:normal;letter-spacing:normal;line-height:normal;text-align:start;text=
-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:n=
one;display:inline!important">What I don't like about the current imple=
mentation and<span>=C2=A0</span></span><a href=3D"http://www.open-std.org/j=
tc1/sc22/wg21/docs/papers/2013/n3804.html" style=3D"font-family:Helvetica;f=
ont-size:12px;font-style:normal;font-variant:normal;font-weight:normal;lett=
er-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-=
transform:none;white-space:normal;word-spacing:0px" target=3D"_blank" rel=
=3D"nofollow" onmousedown=3D"this.href=3D'http://www.google.com/url?q\7=
5http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2013%=
2Fn3804.html\46sa\75D\46sntz\0751\46usg\75AFQjCNFDCBoMGQCoXel5CsJA4wvg-WmwA=
w';return true;" onclick=3D"this.href=3D'http://www.google.com/url?=
q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F20=
13%2Fn3804.html\46sa\75D\46sntz\0751\46usg\75AFQjCNFDCBoMGQCoXel5CsJA4wvg-W=
mwAw';return true;">proposal</a><span style=3D"font-family:Helvetica;fo=
nt-size:12px;font-style:normal;font-variant:normal;font-weight:normal;lette=
r-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-t=
ransform:none;white-space:normal;word-spacing:0px;float:none;display:inline=
!important">, is the fact that I cannot<span>=C2=A0</span></span><span styl=
e=3D"font-size:12px;font-style:normal;font-variant:normal;font-weight:norma=
l;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px=
;text-transform:none;white-space:normal;word-spacing:0px;font-family:'c=
ourier new',monospace">any_cast</span><span style=3D"font-family:Helvet=
ica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal=
;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;=
text-transform:none;white-space:normal;word-spacing:0px;float:none;display:=
inline!important"><span>=C2=A0</span>to a type with added low-level const.<=
/span><br style=3D"font-family:Helvetica;font-size:12px;font-style:normal;f=
ont-variant:normal;font-weight:normal;letter-spacing:normal;line-height:nor=
mal;text-align:start;text-indent:0px;text-transform:none;white-space:normal=
;word-spacing:0px"></div></blockquote></div><br><div>I have written as prop=
osal (<a href=3D"http://bit.ly/reccast" target=3D"_blank" rel=3D"nofollow" =
onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2F=
bit.ly%2Freccast\46sa\75D\46sntz\0751\46usg\75AFQjCNFUzJKELawsJTiXoCYwJGK5N=
_fDag';return true;" onclick=3D"this.href=3D'http://www.google.com/=
url?q\75http%3A%2F%2Fbit.ly%2Freccast\46sa\75D\46sntz\0751\46usg\75AFQjCNFU=
zJKELawsJTiXoCYwJGK5N_fDag';return true;">bit.ly/reccast</a>) to replac=
e <font face=3D"Courier">any_cast</font> with something allowing the <font =
face=3D"Courier">const</font> inside the template argument to appertain to =
the contained type. However, since <font face=3D"Courier">any</font> is in =
charge of allocating its object, there=E2=80=99s no way to guarantee that i=
t is =E2=80=9Clow-level <font face=3D"Courier">const</font>.=E2=80=9D The c=
losest you can get is to use a <font face=3D"Courier">const any</font>. Fol=
lowing my proposal in this case, you=E2=80=99d never put <font face=3D"Cour=
ier">const</font> inside the template argument; it would apply the qualifie=
r from <font face=3D"Courier">const any</font>.</div><div><br></div><div><f=
ont face=3D"Courier">const any a =3D 5; // Likely=C2=A0=E2=80=9Clow-level=
=C2=A0const=E2=80=9D by small-object optimization.</font></div><div><font f=
ace=3D"Courier">int const & five =3D std::recover< int >( a ); //=
OK</font></div><div><font face=3D"Courier">int & fiveish =3D std::reco=
ver< int >( a ); // Error, cannot cast away const.</font></div><div><=
br></div></div></blockquote><div><br><br>Hi David,<br><br>how do you like t=
he following code-example?<br><br>It's a demonstration of <span style=
=3D"font-family: courier new,monospace;">any_cast</span>ing to a type with =
added low<b>est</b>-level const.<br>(it uses <span style=3D"font-family: co=
urier new,monospace;">myany_cast</span>, where <span style=3D"font-family: =
courier new,monospace;">MyAny</span> is just a derived-class of <span style=
=3D"font-family: courier new,monospace;">std::experimental::any</span>)<br>=
<br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250=
); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px=
; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpret=
typrint"><span style=3D"color: #800;" class=3D"styled-by-prettify">#include=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #080;" class=3D"styled-by-prettify"><iostream></s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #800;" class=3D"styled-by-prettify">#include</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #080;" class=3D"styled-by-prettify"><cassert></span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">#include</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #080;" class=3D"styled-by-prettify"><type_traits></span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #800;" class=3D"styled-by-prettify">#include</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;"=
class=3D"styled-by-prettify"><typeinfo></span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #800;"=
class=3D"styled-by-prettify">#include</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">experimental</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">/</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">any</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br=
><br><br></span><span style=3D"color: #800;" class=3D"styled-by-prettify">/=
/ remove_lowest_const ... same as in ../2_remove_lowest_level_const/main.cp=
p</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</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><spa=
n 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: #008;" =
class=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">Enable</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span>=
<span style=3D"color: #660;" class=3D"styled-by-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><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> remove_lowest_const<br></span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">using</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> type </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">remove_const</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">>=
;::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">type</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color:=
#008;" class=3D"styled-by-prettify">template</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">typename</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"> remove_lowest_const</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an 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"colo=
r: #000;" class=3D"styled-by-prettify">enable_if</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;" clas=
s=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">is_pointer</span><span style=3D"color: #660;" class=3D"sty=
led-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">va=
lue </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&&=
amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 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_const</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> =C2=A0T</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">>::</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">value =C2=A0 =C2=A0</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">>::</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">type</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 </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"> </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">typename</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;" c=
lass=3D"styled-by-prettify">add_const</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0</span><span style=3D"color: #008;" class=3D"styled-by-prettify">type=
name</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">add_pointer</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> remove_lowest_const</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> =C2=A0 =C2=A0</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_pointer</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-prett=
ify">>::</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>type =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">>::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">t=
ype =C2=A0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
>::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">type=
=C2=A0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">>=
;::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">type</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color:=
#008;" class=3D"styled-by-prettify">template</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">typename</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"> remove_lowest_const</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an 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"colo=
r: #000;" class=3D"styled-by-prettify">enable_if</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;" clas=
s=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">is_pointer</span><span style=3D"color: #660;" class=3D"sty=
led-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">va=
lue </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&&=
amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">!</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">is_const</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
<</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=
=A0T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">>::=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">value =C2=
=A0 =C2=A0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
>::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">type=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">></span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">using</span><span style=3D"c=
olor: #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><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"st=
yled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">add_pointer</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0</span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> remove_lowest_const</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 </span><spa=
n 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"colo=
r: #000;" class=3D"styled-by-prettify">remove_pointer</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;" c=
lass=3D"styled-by-prettify">>::</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">type =C2=A0 </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">>::</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">type =C2=A0</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">>::</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">type</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></span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=
<br><br><br><br></span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">using</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">experimental<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">any</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: #0=
08;" class=3D"styled-by-prettify">using</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">experimental</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">any_cast</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">cla=
ss</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #606;" class=3D"styled-by-prettify">MyAny</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">public</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> any </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-pretti=
fy">public</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 </span><span style=3D"color: #606;" class=3D"styled-by-prettify">MyAny<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> any</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(),</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> curr_type</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{&</span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">typeid</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">void</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 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{}<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=
=A0 </span><span style=3D"color: #606;" class=3D"styled-by-prettify">MyAny<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #606;" class=3D"styled-by-prettify">MyAny</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">&</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> other</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
any</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">other</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">},</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> curr_type</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">other</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">curr_type</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">{}</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br><br>=C2=A0 </span><span style=3D"color: #606;" class=3D"styled-=
by-prettify">MyAny</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">M=
yAny</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&&=
amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> other=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> any</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"sty=
led-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">move</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">other<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">)},</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> curr_type</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">other</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">curr_type</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{}</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br>=C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">typename</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Va=
lueType</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 </span><span style=3D"color: #606;" class=3D"styled-by-prettify">MyAny<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><sp=
an style=3D"color: #606;" class=3D"styled-by-prettify">ValueType</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">&&</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> value</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: #660=
;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> any</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">forwar=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</spa=
n><span style=3D"color: #606;" class=3D"styled-by-prettify">ValueType</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">>(</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">value</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">)),</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> curr_type</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">{&</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">typeid</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" clas=
s=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"st=
yled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">decay</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify"><</span><span style=3D"color: #606;" class=3D"styled-by-prettify">V=
alueType</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&g=
t;::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">type</=
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 </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">{}</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 </span><span=
style=3D"color: #606;" class=3D"styled-by-prettify">MyAny</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">operator</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">=3D(</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">const</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-b=
y-prettify">MyAny</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">&</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> rhs</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: #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">static_cast</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">any</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&>(*</span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">this</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">).</span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">operator</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">=3D(</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">rhs</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>=C2=A0 =C2=A0 curr_type </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> rhs</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">curr_type</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"=
>return</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">this</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br><br>=C2=A0 </span><span style=3D"color: =
#606;" class=3D"styled-by-prettify">MyAny</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">operator</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">=3D(</span><span style=3D"color: #606;" class=3D"styled-by-p=
rettify">MyAny</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">&&</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> rhs</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an 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">static_cast</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">any</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&>(*</span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">this</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">).</span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">operator</span><span style=3D"color: #660;" c=
lass=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"sty=
led-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">move</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">rhs</s=
pan><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 cu=
rr_type </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> rhs</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify">curr_type</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">this</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br><br>=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">template</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">typename</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">ValueTy=
pe</span><span style=3D"color: #660;" class=3D"styled-by-prettify">></sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </s=
pan><span style=3D"color: #606;" class=3D"styled-by-prettify">MyAny</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">operator</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">=3D(</span><span style=3D"color: #=
606;" class=3D"styled-by-prettify">ValueType</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">&&</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> rhs</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 </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"s=
tyled-by-prettify">static_cast</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify"><</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify">any</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">&>(*</span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">this</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">).</span><span style=3D"color: #008;" class=3D"styled-by-prettify">operat=
or</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D(</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">std</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">forward</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">ValueType</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">>(</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">rhs</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">));</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>=C2=A0 =C2=A0 curr_type </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> rhs</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">curr_type</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">return</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
*</span><span style=3D"color: #008;" class=3D"styled-by-prettify">this</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </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"co=
lor: #008;" class=3D"styled-by-prettify">private</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 </span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">const</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">type_info </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">curr_type</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 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">templa=
te</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span s=
tyle=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">friend</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> T myany_cast</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #606;" c=
lass=3D"styled-by-prettify">MyAny</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-=
prettify">ay</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">template</span><span s=
tyle=3D"color: #660;" 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"> T</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>T myany_cast</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #606;"=
class=3D"styled-by-prettify">MyAny</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">ay</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">((&</span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">typeid</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cla=
ss=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-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> ay<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">curr_type</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>?</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> any_cas=
t</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</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">>(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">ay</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">((&</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">typeid</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> remove_lowest_const</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;" c=
lass=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"style=
d-by-prettify">type</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> ay</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">curr_type</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0</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><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span sty=
le=3D"color: #800;" class=3D"styled-by-prettify">#ifndef</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> NDEBUG<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">std</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">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: #080;" class=3D"styled-by-prettify">"(remo=
ving lowest-level const)"</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-p=
rettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">endl<=
/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: #800;" class=3D"styled-by-prettify">#endif</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">const_cast</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">>(</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">any_cast</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
"><</span><span style=3D"color: #008;" class=3D"styled-by-prettify">type=
name</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> remov=
e_lowest_const</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy"><</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">>::</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">type</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">>(</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">ay</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">)))</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">/* fail */</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> any_cast</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"colo=
r: #000;" class=3D"styled-by-prettify">ay</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">)));</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> main</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 styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">char</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> str</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">=3D</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-pretti=
fy">"asdf"</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br><br>=C2=A0 </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 any ay</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">str</span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=
=A0 =C2=A0 std</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">cout=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #080;" class=3D"styled-by-prettify">"***try normal =
any_cast:"</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"> std</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><sp=
an 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>=C2=A0 =C2=A0 </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">try</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 std</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">cout </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> any_cast</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">char</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">const</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
*>(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">ay</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><<</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">endl</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: #660;" cla=
ss=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">catch</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-pret=
tify"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">experime=
ntal</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">bad_any_cast <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">&</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">e</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: #660=
;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 std</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">cout </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"st=
yled-by-prettify">"fails"</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"> std</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
endl</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span=
style=3D"color: #800;" class=3D"styled-by-prettify">// will go here</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 std</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">cout </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify"><<</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #08=
0;" class=3D"styled-by-prettify">"\n"</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" cla=
ss=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-b=
y-prettify">endl</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
><br>=C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 </span><span style=3D"color: #606;" class=3D"styled-by-prettify"=
>MyAny</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> may=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">str</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 std</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">cout </span><span style=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: #080=
;" class=3D"styled-by-prettify">"***try myany_cast:"</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"co=
lor: #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">endl</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">try</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 =C2=A0 std</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">cout </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
><<</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
myany_cast</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
<</span><span style=3D"color: #008;" class=3D"styled-by-prettify">char</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">*>(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">may</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #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"st=
yled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">endl</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=
=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// wil=
l go here!!</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">}</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-pr=
ettify">catch</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">const<=
/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">experimental</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">bad_any_cast </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">e</span><span style=3D"color: #66=
0;" class=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 =C2=A0 std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">cout </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify"><<</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">=
"fails"</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&l=
t;<</span><span style=3D"color: #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">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"><br>=C2=A0 =C2=A0 </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br><br>=C2=A0 std</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">cout </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"sty=
led-by-prettify">"\n"</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify"><<</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">endl=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 </sp=
an><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 </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">char</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">x </span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> str</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>=C2=A0 =C2=A0 </span><span style=3D"color: #606;" class=3D"sty=
led-by-prettify">MyAny</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> may</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">{&</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">x</span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =
=C2=A0 std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">cout </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"><<</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #080;" class=3D"styled-by-prettify">"***try myany_cast:=
"</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"><<</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</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"co=
lor: #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"col=
or: #008;" class=3D"styled-by-prettify">try</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"style=
d-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 std</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">cout </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify"><<</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
myany_cast</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
<</span><span style=3D"color: #008;" class=3D"styled-by-prettify">char</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">*>(</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">may</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">=
std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">endl</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=
: #800;" class=3D"styled-by-prettify">// will go here!!</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><sp=
an 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">catch</span><span st=
yle=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"> std</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">experimental</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">bad_any_cast </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">e</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><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">cout </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"><<</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #080;" class=3D"styled-by-prettify">"fails"</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"color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">endl</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: #660;" cla=
ss=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>=C2=A0 </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><br>=C2=A0 </span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">return</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify"=
>0</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></span></div></code></div><b=
r><br><br><br>But this is no silver bullet, though...<br><br>It works only =
for added lowest(!) level const. If we add various low/mid level consts, th=
en it will not work.<br>Example:<br><br><div class=3D"prettyprint" style=3D=
"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); bo=
rder-style: solid; border-width: 1px; word-wrap: break-word;"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #000;"=
class=3D"styled-by-prettify">=C2=A0 </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">char</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> str</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">[]</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #080;" class=3D"styled-by-prettify">"asdf"</s=
pan><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 </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">char</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">x </span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> str</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>=C2=A0 =C2=A0 </span><span style=3D"color: #606;" class=3D"sty=
led-by-prettify">MyAny</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> may</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">{&</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">x</span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =
=C2=A0 std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">cout </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"><<</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #080;" class=3D"styled-by-prettify">"***try myany_cast:=
"</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"><<</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</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"co=
lor: #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"col=
or: #008;" class=3D"styled-by-prettify">try</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"style=
d-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 std</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">cout </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify"><<</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
myany_cast</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
<</span><span style=3D"color: #008;" class=3D"styled-by-prettify">char</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">const</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">*>(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">may</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
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">endl</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">catch</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: #00=
0;" 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">experimental</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">bad_any_cast </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">e</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 st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">cout </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: #080;" class=3D"styled-by-prettify">"this is no sliver bullet,=
since if we want to myany_cast to a type with multiple low-level consts, w=
e'd have to compare various permutations (!) of const-removal with the =
actual typeid (curr_type)"</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify"><<</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">endl=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code></di=
v><br><br><br><br>Ultimately it would be nice to have a efficient method of=
<span style=3D"font-family: courier new,monospace;">any_cast</span>ing to =
arbitary low-level const'ed type <span style=3D"font-family: courier ne=
w,monospace;">T1</span> from an <span style=3D"font-family: courier new,mon=
ospace;">any</span> holding type <span style=3D"font-family: courier new,mo=
nospace;">T2</span>, <br>in other words, where <span style=3D"font-family: =
courier new,monospace;">same_type_and_t1_possib_recurse_lowlev_const<T1,=
T2>()</span> holds true.<br><br><div class=3D"prettyprint" style=3D"bac=
kground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border=
-style: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"pr=
ettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">typename</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> T1</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">typename<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T2</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">></span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">bool</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> same_type_and_t1_possib_recurse_lowlev_con=
st</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: #800;" class=3D"styled-by-prettify">/*<br>=C2=A0 T2 SAME a=
s T1 (possibly by adding low-level consts to T2)<br>=C2=A0*/</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">return</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"s=
tyled-by-prettify">std</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">is_const</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
"><</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T1</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">>::</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">value </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&&</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 std</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">is_const</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">T2</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">>::</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">value</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">))</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">&&</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">is_pointer</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">T1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">value=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">is_pointer</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">T2</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">>::</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify">value</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> =C2=A0</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&&</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #00=
0;" 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">is_pointer</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify"><</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">T1</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">>::</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>value<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">?</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> same_type_and_t1_possib_recurse_lowlev_co=
nst</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">remove_pointer</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">T1</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">>::</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">type</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0</span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">typename</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">remove_pointe=
r</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">T2</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">>::</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">type</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">>()</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify">is_same</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">typename</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;" c=
lass=3D"styled-by-prettify">remove_const</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">T1</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">>::</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">type</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 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0</span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">typename</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">re=
move_const</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
<</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T2</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">>::</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">type</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">>::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">value<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">));</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan></div></code></div><br><br>But <span style=3D"font-family: courier new,=
monospace;">any</span> has type erasure, so we cannot really "get at&q=
uot; the type <span style=3D"font-family: courier new,monospace;">T2</span>=
that an <span style=3D"font-family: courier new,monospace;">any</span> is =
holding.<br><br>It seems we have to work with <span style=3D"font-family: c=
ourier new,monospace;">typeid</span>.<br>It sure would be cool if <span sty=
le=3D"font-family: courier new,monospace;">typeid</span> had efficient meth=
ods of checking if one <span style=3D"font-family: courier new,monospace;">=
std::type_info</span> is the same as another <span style=3D"font-family: co=
urier new,monospace;">std::type_info</span> (except possibly for one having=
added low-level consts). <br><br>Some expert needs to check that that out,=
if that is possible!<br><br>Regards,<br>a.<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" 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_869_1921769300.1443299493371--
------=_Part_868_68605322.1443299493368--
.
Author: ajneu1@gmail.com
Date: Sun, 27 Sep 2015 12:51:56 -0700 (PDT)
Raw View
------=_Part_1386_1691766903.1443383516745
Content-Type: multipart/alternative;
boundary="----=_Part_1387_1810335923.1443383516745"
------=_Part_1387_1810335923.1443383516745
Content-Type: text/plain; charset=UTF-8
On Saturday, September 26, 2015 at 10:31:33 PM UTC+2, ajneu1 wrote:
>
>
>
> It's a demonstration of any_casting to a type with added low*est*-level
> const.
> (it uses myany_cast, where MyAny is just a derived-class of
> std::experimental::any)
>
> #include <iostream>
> #include <cassert>
> #include <type_traits>
> #include <typeinfo>
> #include <experimental/any>
>
> //etc. etc.
>
That code above can be considerably simplified.
See link (to a particular commit): here
<https://github.com/ajneu/templates__low_level_const__any_cast/blob/6deed1cd14ecb140957792a9c19dda3ff0330b7b/3_any_cast_to_added_lowest_level_const/main.cpp>
It seems we have to work with typeid.
> It sure would be cool if typeid had efficient methods of checking if one
> std::type_info is the same as another std::type_info (except possibly for
> one having added low-level consts).
>
>
I've been trying some things in this regard...
Here's what I've come up with:
(particular commit): link
<https://github.com/ajneu/templates__low_level_const__any_cast/blob/7ef0d61ba63a419308d280fead58656f19024946/3_any_cast_to_added_lowest_level_const/main.cpp>
The idea is, expressing "a priori" intent of possible casts (in the
future) to "linked types", i.e. related types
char str[] = "asdf";
char *x = str;
MyAny may;
may.operator=<char * *, // main type
char const* *, // linked type (low-level const)
char const* const* // linked type (low-level const)
>(&x);
(particular commit): link
<https://github.com/ajneu/templates__low_level_const__any_cast/blob/7ef0d61ba63a419308d280fead58656f19024946/3_any_cast_to_added_lowest_level_const/main.cpp>
The moment you put something into an any, you can also say which "*linked*"
(i.e.related) types you want to potentially any_cast to (in the future).
This is very safe, since a static_assert checks right then and there, that
the casts are legal (low-level const added ... possibly is_convertible
<http://en.cppreference.com/w/cpp/types/is_convertible> would also have
been a good choice).
(Note that unsafe_any_cast is very useful here. I think it should
definitely be part of the public interface).
Regards,
ajneu.
--
---
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_1387_1810335923.1443383516745
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<br><br>On Saturday, September 26, 2015 at 10:31:33 PM UTC+2, ajneu1 wrote:=
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><br><div><br>It's a demons=
tration of <span style=3D"font-family:courier new,monospace">any_cast</span=
>ing to a type with added low<b>est</b>-level const.<br>(it uses <span styl=
e=3D"font-family:courier new,monospace">myany_cast</span>, where <span styl=
e=3D"font-family:courier new,monospace">MyAny</span> is just a derived-clas=
s of <span style=3D"font-family:courier new,monospace">std::experimental::a=
ny</span>)<br><br><div style=3D"background-color:rgb(250,250,250);border-co=
lor:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-wo=
rd"><code><div><span style=3D"color:#800">#include</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#080"><iostream></span><span st=
yle=3D"color:#000"><br></span><span style=3D"color:#800">#include</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#080"><cassert><=
/span><span style=3D"color:#000"><br></span><span style=3D"color:#800">#inc=
lude</span><span style=3D"color:#000"> </span><span style=3D"color:#080">&l=
t;type_traits></span><span style=3D"color:#000"><br></span><span style=
=3D"color:#800">#include</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#080"><typeinfo></span><span style=3D"color:#000"><br></s=
pan><span style=3D"color:#800">#include</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#660"><</span><span style=3D"color:#000">expe=
rimental</span><span style=3D"color:#660">/</span><span style=3D"color:#000=
">any</span><span style=3D"color:#660">></span><span style=3D"color:#000=
"><br><br>//etc. etc.<br></span><span style=3D"color:#000"></span></div></c=
ode></div></div></blockquote>=C2=A0<br><br><br>That code above can be consi=
derably simplified.<br>See link (to a particular commit): <a href=3D"https:=
//github.com/ajneu/templates__low_level_const__any_cast/blob/6deed1cd14ecb1=
40957792a9c19dda3ff0330b7b/3_any_cast_to_added_lowest_level_const/main.cpp"=
>here</a> <br><br><br><blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div>It =
seems we have to work with <span style=3D"font-family:courier new,monospace=
">typeid</span>.<br>It sure would be cool if <span style=3D"font-family:cou=
rier new,monospace">typeid</span> had efficient methods of checking if one =
<span style=3D"font-family:courier new,monospace">std::type_info</span> is =
the same as another <span style=3D"font-family:courier new,monospace">std::=
type_info</span> (except possibly for one having added low-level consts). <=
br><br></div></blockquote><div><br>I've been trying some things in this=
regard...<br><br><br>Here's what I've come up with:<br>(particular=
commit): <a href=3D"https://github.com/ajneu/templates__low_level_const__a=
ny_cast/blob/7ef0d61ba63a419308d280fead58656f19024946/3_any_cast_to_added_l=
owest_level_const/main.cpp">link</a><br><br>The idea is, expressing "a=
priori" intent of possible casts (in the future)=C2=A0=C2=A0=C2=A0=C2=
=A0 to "linked types", i.e. related types =C2=A0 =C2=A0 =C2=A0=C2=
=A0 <br><br><table class=3D"highlight tab-size js-file-line-container" data=
-tab-size=3D"8"><tbody><tr><td id=3D"LC176" class=3D"blob-code blob-code-in=
ner js-file-line"> <div class=3D"prettyprint" style=3D"background-color:=
rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid;=
border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><di=
v class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-=
prettify">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 <br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">char</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> str</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">[]</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #080;" class=3D"styled-by-prettify">"asdf"</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">char</span><span style=3D"co=
lor: #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">x </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> str</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span><span style=3D"color: #606;" class=3D"styled-by-prettify">MyAny</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> may</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>may</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">operator</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">=3D<</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">char</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> =C2=A0 =C2=A0 =C2=A0</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> =C2=A0 =C2=A0 =C2=A0</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">*,</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">// main type</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">char</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0 =C2=A0</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">*,</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;"=
class=3D"styled-by-prettify">// linked type (low-level const)</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">char</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">const</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">const</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0</span><span style=3D=
"color: #800;" class=3D"styled-by-prettify">// linked type (low-level const=
)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">>(&</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">x</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br></span></div></code></div><br>(particular commit): <=
a href=3D"https://github.com/ajneu/templates__low_level_const__any_cast/blo=
b/7ef0d61ba63a419308d280fead58656f19024946/3_any_cast_to_added_lowest_level=
_const/main.cpp">link</a><br><br>The moment you put something into an <span=
style=3D"font-family: courier new,monospace;">any</span>, you can also say=
which "<b>linked</b>" (i.e.related) types you want to potentiall=
y <span style=3D"font-family: courier new,monospace;">any_cast</span> to (i=
n the future).<br></td><td id=3D"LC177" class=3D"blob-code blob-code-inner =
js-file-line"><br></td><td id=3D"LC178" class=3D"blob-code blob-code-inner =
js-file-line"><br></td><td id=3D"LC179" class=3D"blob-code blob-code-inner =
js-file-line"><br></td><td id=3D"LC180" class=3D"blob-code blob-code-inner =
js-file-line"><br></td><td id=3D"LC181" class=3D"blob-code blob-code-inner =
js-file-line"><br></td></tr></tbody></table>This is very safe, since a <spa=
n style=3D"font-family: courier new,monospace;">static_assert</span> checks=
right then and there, that the casts are legal (low-level const added ... =
possibly <span style=3D"color: rgb(0, 0, 0);"><a href=3D"http://en.cpprefer=
ence.com/w/cpp/types/is_convertible"><span style=3D"font-family: courier ne=
w,monospace;">is_convertible</span></a></span> would also have been a good =
choice).<br><br>(Note that <span style=3D"font-family: courier new,monospac=
e;">unsafe_any_cast</span> is very useful here. I think it should definitel=
y be part of the public interface).<br><br>Regards,<br>ajneu.<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" 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_1387_1810335923.1443383516745--
------=_Part_1386_1691766903.1443383516745--
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Tue, 29 Sep 2015 11:02:32 -0400
Raw View
--089e011605f4816da60520e41af0
Content-Type: text/plain; charset=UTF-8
On Thu, Sep 24, 2015 at 2:03 PM, <nicesw123@gmail.com> wrote:
> Hello,
>
> std::experimental::any (boost::any) is nice.
> What I don't like about the current implementation and proposal
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3804.html>, is
> the fact that I cannot any_cast to a type with added low-level const.
>
>
> Example:
> using std::experimental::any;
> using std::experimental::any_cast;
> char str[] = "a2";
> any ay(str);
> any_cast<const char*>(ay); // throws, since a const is added!!!
>
>
> Why should that not be legal??
> All it means is a read-only access to the contained type, and that
> definitely should be legal.
>
> Compare:
> char str2[] = "str2";
> static_cast<const char *>(str2); // read-only access (const added)
>
>
> I've written on the Boost Users mailing list:
> http://lists.boost.org/boost-users/2015/09/85097.php
>
> I must say I'm pleased that any is in experimental and is proposed (which
> is why I'm writing here): It's a great type for having a container of "any"
> type, since it limits the dynamic memory that the container needs per
> element (the mem-storage for large contained values residing on the heap).
> This in big contranst to variant, which can lead to really fat memory-usage
> in a container, if it is used to also be able to hold a fat type; even if
> most elements in a container of that variant, might be small. (My optimum
> would be a variant that contains needed small types as well as any)
>
> I hope any_cast'ing to a type with added low-level can be
> * realized (is it possible to do safely?)
> * be regarded as nice additional requirement for the recommendation.
>
> Thanks for comments,
> Regards,
> n.
>
>
I think part of the problem, in general, is that any_cast is NOT a _cast_.
It is a "get" (similar to variant<> and optional<>) and should be called
get.
ie casts are expected to be able to do some transformations, but any_cast
doesn't.
ie
any ne = 5.7;
int five = any_cast<int>(ne); // fails
similarly, it has been suggested that variant's and optional's get() be
called some kind of cast to match any. But
variant<int, float> vif = 5.7;
int five = get<int>(vif); // fails
because get() is not a cast.
I think they should all be called get().
Tony
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--089e011605f4816da60520e41af0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Thu, Sep 24, 2015 at 2:03 PM, <span dir=3D"ltr"><<a href=3D"mail=
to:nicesw123@gmail.com" target=3D"_blank">nicesw123@gmail.com</a>></span=
> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Hello,<br><br><=
span style=3D"font-family:courier new,monospace">std::experimental::any</sp=
an> (<span style=3D"font-family:courier new,monospace"><code>boost::any</co=
de></span>) is nice.<br>What I=20
don't like about the current implementation and <a href=3D"http://www.o=
pen-std.org/jtc1/sc22/wg21/docs/papers/2013/n3804.html" target=3D"_blank">p=
roposal</a>, is the fact=20
that I cannot <span style=3D"font-family:courier new,monospace">any_cast</s=
pan> to a type with added low-level const.<br><br><br>Example:<br><div styl=
e=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border=
-style:solid;border-width:1px;word-wrap:break-word"><code><div><span style=
=3D"color:#008">using</span><span style=3D"color:#000"> std</span><span sty=
le=3D"color:#660">::</span><span style=3D"color:#000">experimental</span><s=
pan style=3D"color:#660">::</span><span style=3D"color:#000">any</span><spa=
n style=3D"color:#660">;</span><span style=3D"color:#000"><br></span><span =
style=3D"color:#008">using</span><span style=3D"color:#000"> std</span><spa=
n style=3D"color:#660">::</span><span style=3D"color:#000">experimental</sp=
an><span style=3D"color:#660">::</span><span style=3D"color:#000">any_cast<=
/span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br></s=
pan><span style=3D"color:#008">char</span><span style=3D"color:#000"> str</=
span><span style=3D"color:#660">[]</span><span style=3D"color:#000"> </span=
><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#080">"a2"</span><span style=3D"color:#660">;<=
/span><span style=3D"color:#000"><br>any ay</span><span style=3D"color:#660=
">(</span><span style=3D"color:#000">str</span><span style=3D"color:#660">)=
;</span><span style=3D"color:#000"><br>any_cast</span><span style=3D"color:=
#660"><</span><span style=3D"color:#008">const</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#008">char</span><span style=3D"color:=
#660">*>(</span><span style=3D"color:#000">ay</span><span style=3D"color=
:#660">);</span><span style=3D"color:#000"> </span><span style=3D"color:#80=
0">// throws, since a const is added!!!</span><span style=3D"color:#000"><b=
r></span></div></code></div><br><br>Why should that not be legal??<br>All i=
t means is a read-only access to the contained type, and that definitely sh=
ould be legal.<br><br>Compare:<br><div style=3D"background-color:rgb(250,25=
0,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px;wo=
rd-wrap:break-word"><code><div><span style=3D"color:#008">char</span><span =
style=3D"color:#000"> str2</span><span style=3D"color:#660">[]</span><span =
style=3D"color:#000"> </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#080">"str2"</span=
><span style=3D"color:#660">;</span><span style=3D"color:#000"><br></span><=
span style=3D"color:#008">static_cast</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">char</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#660">*>(</span><span style=3D"color:#000">str2=
</span><span style=3D"color:#660">);</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#800">// read-only access (const added)</span><span=
style=3D"color:#000"><br></span></div></code></div><br><br>I've writte=
n on the Boost Users mailing list:<br><a href=3D"http://lists.boost.org/boo=
st-users/2015/09/85097.php" target=3D"_blank">http://lists.boost.org/boost-=
users/2015/09/85097.php<span></span><span></span></a><br><br>I must say I&#=
39;m pleased that <span style=3D"font-family:courier new,monospace">any</sp=
an> is in experimental and is proposed (which is why I'm writing here):=
It's a great type for=20
having a container of "any" type, since it limits the dynamic mem=
ory=20
that the container needs per element (the mem-storage for large=20
contained values residing on the heap). This in big contranst to=20
variant, which can lead to really fat memory-usage in a container, if it
is used to also be able to hold a fat type; even if most elements in a con=
tainer=20
of that variant, might be small. (My optimum would be a variant that contai=
ns needed small types as well as <span style=3D"font-family:courier new,mon=
ospace">any</span>)<br><br>I hope <span style=3D"font-family:courier new,mo=
nospace">any_cast</span>'ing to a type with added low-level can be<br>*=
realized (is it possible to do safely?)<br>* be regarded as nice additiona=
l requirement for the recommendation.<br><br>Thanks for comments,<br>Regard=
s,<br>n.<span class=3D"HOEnZb"><font color=3D"#888888"><br><br></font></spa=
n></div></blockquote><div><br><br></div><div>I think part of the problem, i=
n general, is that any_cast is NOT a _cast_.=C2=A0 It is a "get" =
(similar to variant<> and optional<>) and should be called get.=
<br></div><div>ie casts are expected to be able to do some transformations,=
but any_cast doesn't.<br><br></div><div>ie<br><br></div><div>any ne =
=3D 5.7;<br></div><div>int five =3D any_cast<int>(ne);=C2=A0 // fails=
<br><br></div><div>similarly, it has been suggested that variant's and =
optional's get() be called some kind of cast to match any.=C2=A0 But<br=
><br></div><div>variant<int, float> vif =3D 5.7;<br></div><div>int fi=
ve =3D get<int>(vif);=C2=A0=C2=A0 // fails<br><br></div><div>because =
get() is not a cast.<br><br></div><div>I think they should all be called ge=
t().<br><br></div><div>Tony<br><br><br></div><div><br></div></div><br></div=
></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--089e011605f4816da60520e41af0--
.
Author: David Krauss <potswa@gmail.com>
Date: Tue, 29 Sep 2015 23:42:29 +0800
Raw View
--Apple-Mail=_B0E19C3B-3B03-4441-9261-9E3804D50DCE
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9309=E2=80=9329, at 11:02 PM, Tony V E <tvaneerd@gmail.com>=
wrote:
>=20
> ie casts are expected to be able to do some transformations, but any_cast=
doesn't.
Well, any_cast does, but it shouldn=E2=80=99t.
> I think they should all be called get().
get() retrieves one of several coexisting members, but in this case, there =
can be only one =E2=80=9Cright=E2=80=9D answer. I=E2=80=99ve proposed to sp=
ell it recover() in P0042 <http://bit.ly/reccast>. It behaves like get plus=
exceptions.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_B0E19C3B-3B03-4441-9261-9E3804D50DCE
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><div class=3D""><b=
r class=3D""></div><blockquote type=3D"cite" class=3D""><div class=3D"">On =
2015=E2=80=9309=E2=80=9329, at 11:02 PM, Tony V E <<a href=3D"mailto:tva=
neerd@gmail.com" class=3D"">tvaneerd@gmail.com</a>> wrote:</div><br clas=
s=3D"Apple-interchange-newline"><div class=3D""><span class=3D"" style=3D"f=
loat: none; display: inline !important;">ie casts are expected to be able t=
o do some transformations, but any_cast doesn't.</span></div></blockquote><=
div><br class=3D""></div><div>Well, <font face=3D"Courier" class=3D"">any_c=
ast</font> does, but it shouldn=E2=80=99t.</div><div><br class=3D""><blockq=
uote type=3D"cite" class=3D""><div class=3D""><span style=3D"font-family: H=
elvetica; font-size: 12px; font-style: normal; font-variant: normal; font-w=
eight: normal; letter-spacing: normal; line-height: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: nor=
mal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float=
: none; display: inline !important;" class=3D"">I think they should all be =
called get().</span><br style=3D"font-family: Helvetica; font-size: 12px; f=
ont-style: normal; font-variant: normal; font-weight: normal; letter-spacin=
g: normal; line-height: normal; orphans: auto; text-align: start; text-inde=
nt: 0px; text-transform: none; white-space: normal; widows: auto; word-spac=
ing: 0px; -webkit-text-stroke-width: 0px;" class=3D""></div></blockquote></=
div><br class=3D""><div class=3D""><font face=3D"Courier" class=3D"">get()<=
/font> retrieves one of several coexisting members, but in this case, there=
can be only one =E2=80=9Cright=E2=80=9D answer. I=E2=80=99ve proposed to s=
pell it <font face=3D"Courier" class=3D"">recover()</font> in <a href=
=3D"http://bit.ly/reccast" class=3D"">P0042</a>. It behaves like <font face=
=3D"Courier" class=3D"">get</font> plus exceptions.</div><div class=3D""><b=
r class=3D""></div></body></html>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--Apple-Mail=_B0E19C3B-3B03-4441-9261-9E3804D50DCE--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Tue, 29 Sep 2015 18:57:44 +0300
Raw View
On 29 September 2015 at 18:02, Tony V E <tvaneerd@gmail.com> wrote:
> I think part of the problem, in general, is that any_cast is NOT a _cast_.
How so? It attempts a run-time conversion from an any to a target type,
returning an rvalue. What did the designers of boost::any say about that,
was it discussed when any was added to boost just after dinosaurs
went extinct?
> It is a "get" (similar to variant<> and optional<>) and should be called
> get.
Those functions return lvalues.
> ie casts are expected to be able to do some transformations, but any_cast
> doesn't.
It transforms an any to an underlying 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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Tue, 29 Sep 2015 13:44:36 -0400
Raw View
--089e0158c00e12b5760520e65e59
Content-Type: text/plain; charset=UTF-8
On Tue, Sep 29, 2015 at 11:57 AM, Ville Voutilainen <
ville.voutilainen@gmail.com> wrote:
> On 29 September 2015 at 18:02, Tony V E <tvaneerd@gmail.com> wrote:
> > I think part of the problem, in general, is that any_cast is NOT a
> _cast_.
>
> How so? It attempts a run-time conversion from an any to a target type,
> returning an rvalue. What did the designers of boost::any say about that,
> was it discussed when any was added to boost just after dinosaurs
> went extinct?
>
Not sure. I'm almost a dinosaur, but I missed that epoch.
>
> > It is a "get" (similar to variant<> and optional<>) and should be called
> > get.
>
> Those functions return lvalues.
>
I haven't thought about r vs l. Is that what makes a cast a cast?
>
> > ie casts are expected to be able to do some transformations, but any_cast
> > doesn't.
>
> It transforms an any to an underlying type.
>
Only if it already is that type. There is no real transformation.
Sure it "transforms" the any, but it really just _gets_ something out of
the any.
Obviously 'cast' is an overused term with varied meaning, but I think there
is a line that can and should be drawn somewhere, near this area.
I understand that any_cast has a bunch of history, but I'm not sure that
makes it right.
(Of course, you might think there isn't much here making me right.)
Tony
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--
---
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/.
--089e0158c00e12b5760520e65e59
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Tue, Sep 29, 2015 at 11:57 AM, Ville Voutilainen <span dir=3D"ltr">&=
lt;<a href=3D"mailto:ville.voutilainen@gmail.com" target=3D"_blank">ville.v=
outilainen@gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail_qu=
ote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex=
"><span class=3D"">On 29 September 2015 at 18:02, Tony V E <<a href=3D"m=
ailto:tvaneerd@gmail.com">tvaneerd@gmail.com</a>> wrote:<br>
> I think part of the problem, in general, is that any_cast is NOT a _ca=
st_.<br>
<br>
</span>How so? It attempts a run-time conversion from an any to a target ty=
pe,<br>
returning an rvalue. What did the designers of boost::any say about that,<b=
r>
was it discussed when any was added to boost just after dinosaurs<br>
went extinct?<br></blockquote><div><br></div><div>Not sure.=C2=A0 I'm a=
lmost a dinosaur, but I missed that epoch.<br>=C2=A0<br></div><blockquote c=
lass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;=
padding-left:1ex">
<span class=3D""><br>
> It is a "get" (similar to variant<> and optional<&g=
t;) and should be called<br>
> get.<br>
<br>
</span>Those functions return lvalues.<br></blockquote><div><br></div><div>=
I haven't thought about r vs l.=C2=A0 Is that what makes a cast a cast?=
<br>=C2=A0<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0=
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=3D""><br>
> ie casts are expected to be able to do some transformations, but any_c=
ast<br>
> doesn't.<br>
<br>
</span>It transforms an any to an underlying type.<br></blockquote><div><br=
></div><div>Only if it already is that type.=C2=A0 There is no real transfo=
rmation.<br></div><div>Sure it "transforms" the any, but it reall=
y just _gets_ something out of the any.<br><br></div><div>Obviously 'ca=
st' is an overused term with varied meaning, but I think there is a lin=
e that can and should be drawn somewhere, near this area.<br><br></div><div=
>I understand that any_cast has a bunch of history, but I'm not sure th=
at makes it right.<br></div><div>(Of course, you might think there isn'=
t much here making me right.)<br><br></div><div>Tony<br><br>=C2=A0<br></div=
><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1=
px #ccc solid;padding-left:1ex">
<div class=3D"HOEnZb"><div class=3D"h5"><br>
--<br>
<br>
---<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%2Bunsubscribe@isocpp.org">std-propo=
sals+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/" rel=3D"noreferrer" target=3D"_blank">http://groups.google.c=
om/a/isocpp.org/group/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--089e0158c00e12b5760520e65e59--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Tue, 29 Sep 2015 19:54:19 +0200
Raw View
Le 29/09/15 17:02, Tony V E a =C3=A9crit :
> I think part of the problem, in general, is that any_cast is NOT a _cast_=
..
> It is a "get" (similar to variant<> and optional<>) and should be called
> get.
> ie casts are expected to be able to do some transformations, but any_cast
> doesn't.
>
> ie
>
> any ne =3D 5.7;
> int five =3D any_cast<int>(ne); // fails
>
> similarly, it has been suggested that variant's and optional's get() be
> called some kind of cast to match any. But
>
> variant<int, float> vif =3D 5.7;
> int five =3D get<int>(vif); // fails
>
> because get() is not a cast.
>
> I think they should all be called get().
>
>
While both get access to an stored value, one can throw (sum types)=20
because the type stored doesn't match and the other not (product types).
Vicente
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Tue, 29 Sep 2015 13:55:58 -0400
Raw View
--089e0158c00ec202dd0520e686e8
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Tue, Sep 29, 2015 at 1:54 PM, Vicente J. Botet Escriba <
vicente.botet@wanadoo.fr> wrote:
> Le 29/09/15 17:02, Tony V E a =C3=A9crit :
>
>> I think part of the problem, in general, is that any_cast is NOT a _cast=
_.
>> It is a "get" (similar to variant<> and optional<>) and should be called
>> get.
>> ie casts are expected to be able to do some transformations, but any_cas=
t
>> doesn't.
>>
>> ie
>>
>> any ne =3D 5.7;
>> int five =3D any_cast<int>(ne); // fails
>>
>> similarly, it has been suggested that variant's and optional's get() be
>> called some kind of cast to match any. But
>>
>> variant<int, float> vif =3D 5.7;
>> int five =3D get<int>(vif); // fails
>>
>> because get() is not a cast.
>>
>> I think they should all be called get().
>>
>>
>> While both get access to an stored value, one can throw (sum types)
> because the type stored doesn't match and the other not (product types).
I'm confused. Which doesn't throw?
>
>
> Vicente
>
>
> --
>
> --- 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/.
>
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--089e0158c00ec202dd0520e686e8
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Tue, Sep 29, 2015 at 1:54 PM, Vicente J. Botet Escriba <span dir=3D"=
ltr"><<a href=3D"mailto:vicente.botet@wanadoo.fr" target=3D"_blank">vice=
nte.botet@wanadoo.fr</a>></span> wrote:<br><blockquote class=3D"gmail_qu=
ote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex=
">Le 29/09/15 17:02, Tony V E a =C3=A9crit :<span class=3D""><br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
I think part of the problem, in general, is that any_cast is NOT a _cast_.<=
br>
It is a "get" (similar to variant<> and optional<>) a=
nd should be called<br>
get.<br>
ie casts are expected to be able to do some transformations, but any_cast<b=
r>
doesn't.<br>
<br>
ie<br>
<br>
any ne =3D 5.7;<br>
int five =3D any_cast<int>(ne);=C2=A0 // fails<br>
<br>
similarly, it has been suggested that variant's and optional's get(=
) be<br>
called some kind of cast to match any.=C2=A0 But<br>
<br>
variant<int, float> vif =3D 5.7;<br>
int five =3D get<int>(vif);=C2=A0 =C2=A0// fails<br>
<br>
because get() is not a cast.<br>
<br>
I think they should all be called get().<br>
<br>
<br>
</blockquote></span>
While both get access to an stored value, one can throw (sum types) because=
the type stored doesn't match and the other not (product types).</bloc=
kquote><div><br></div><div>I'm confused. Which doesn't throw?<br>=
=C2=A0<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8e=
x;border-left:1px #ccc solid;padding-left:1ex"><span class=3D"HOEnZb"><font=
color=3D"#888888"><br>
<br>
Vicente</font></span><div class=3D"HOEnZb"><div class=3D"h5"><br>
<br>
-- <br>
<br>
--- You received this message because you are subscribed to the Google Grou=
ps "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%2Bunsubscribe@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/" rel=3D"noreferrer" target=3D"_blank">http://groups.google.c=
om/a/isocpp.org/group/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--089e0158c00ec202dd0520e686e8--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Tue, 29 Sep 2015 22:44:43 +0200
Raw View
Le 29/09/15 19:55, Tony V E a =C3=A9crit :
> On Tue, Sep 29, 2015 at 1:54 PM, Vicente J. Botet Escriba <
> vicente.botet@wanadoo.fr> wrote:
>
>> Le 29/09/15 17:02, Tony V E a =C3=A9crit :
>>
>>> I think part of the problem, in general, is that any_cast is NOT a _cas=
t_.
>>> It is a "get" (similar to variant<> and optional<>) and should be calle=
d
>>> get.
>>> ie casts are expected to be able to do some transformations, but any_ca=
st
>>> doesn't.
>>>
>>> ie
>>>
>>> any ne =3D 5.7;
>>> int five =3D any_cast<int>(ne); // fails
>>>
>>> similarly, it has been suggested that variant's and optional's get() be
>>> called some kind of cast to match any. But
>>>
>>> variant<int, float> vif =3D 5.7;
>>> int five =3D get<int>(vif); // fails
>>>
>>> because get() is not a cast.
>>>
>>> I think they should all be called get().
>>>
>>>
>>> While both get access to an stored value, one can throw (sum types)
>> because the type stored doesn't match and the other not (product types).
>
> I'm confused. Which doesn't throw?
get<T>(tuple<Ts...>) doesn't throws.
get<T>(variant<Ts...>) can throw if T is not the stored type.
Is this enough to don't name the two function the same?
Vicente
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Tue, 29 Sep 2015 17:11:47 -0400
Raw View
--089e0141a718058aad0520e943ce
Content-Type: text/plain; charset=UTF-8
On Tue, Sep 29, 2015 at 1:44 PM, Tony V E <tvaneerd@gmail.com> wrote:
>
>
> On Tue, Sep 29, 2015 at 11:57 AM, Ville Voutilainen <
> ville.voutilainen@gmail.com> wrote:
>
>> On 29 September 2015 at 18:02, Tony V E <tvaneerd@gmail.com> wrote:
>> > I think part of the problem, in general, is that any_cast is NOT a
>> _cast_.
>>
>> How so? It attempts a run-time conversion from an any to a target type,
>> returning an rvalue. What did the designers of boost::any say about that,
>> was it discussed when any was added to boost just after dinosaurs
>> went extinct?
>>
>
> Not sure. I'm almost a dinosaur, but I missed that epoch.
>
It looks like any_cast was there from the beginning. It is part of the
article from which boost::any was based:
http://www.two-sdg.demon.co.uk/curbralan/papers/ValuedConversions.pdf
Not sure if anyone questioned it in the review. Hard to search for 'any'
in boost emails :-(
Tony
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--089e0141a718058aad0520e943ce
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Tue, Sep 29, 2015 at 1:44 PM, Tony V E <span dir=3D"ltr"><<a href=
=3D"mailto:tvaneerd@gmail.com" target=3D"_blank">tvaneerd@gmail.com</a>>=
</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px=
0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div di=
r=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quote"><sp=
an class=3D"">On Tue, Sep 29, 2015 at 11:57 AM, Ville Voutilainen <span dir=
=3D"ltr"><<a href=3D"mailto:ville.voutilainen@gmail.com" target=3D"_blan=
k">ville.voutilainen@gmail.com</a>></span> wrote:<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex"><span>On 29 September 2015 at 18:02, Tony =
V E <<a href=3D"mailto:tvaneerd@gmail.com" target=3D"_blank">tvaneerd@gm=
ail.com</a>> wrote:<br>
> I think part of the problem, in general, is that any_cast is NOT a _ca=
st_.<br>
<br>
</span>How so? It attempts a run-time conversion from an any to a target ty=
pe,<br>
returning an rvalue. What did the designers of boost::any say about that,<b=
r>
was it discussed when any was added to boost just after dinosaurs<br>
went extinct?<br></blockquote><div><br></div></span><div>Not sure.=C2=A0 I&=
#39;m almost a dinosaur, but I missed that epoch.<br></div></div></div></di=
v></blockquote><div><br></div><div>It looks like any_cast was there from th=
e beginning.=C2=A0 It is part of the article from which boost::any was base=
d: <a href=3D"http://www.two-sdg.demon.co.uk/curbralan/papers/ValuedConvers=
ions.pdf">http://www.two-sdg.demon.co.uk/curbralan/papers/ValuedConversions=
..pdf</a><br><br></div><div>Not sure if anyone questioned it in the review.=
=C2=A0 Hard to search for 'any' in boost emails :-(<br><br></div><d=
iv>Tony<br></div></div></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--089e0141a718058aad0520e943ce--
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Tue, 29 Sep 2015 17:19:35 -0400
Raw View
--001a113fb8c0f393690520e95e3d
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Tue, Sep 29, 2015 at 4:44 PM, Vicente J. Botet Escriba <
vicente.botet@wanadoo.fr> wrote:
> Le 29/09/15 19:55, Tony V E a =C3=A9crit :
>
>> On Tue, Sep 29, 2015 at 1:54 PM, Vicente J. Botet Escriba <
>> vicente.botet@wanadoo.fr> wrote:
>>
>> Le 29/09/15 17:02, Tony V E a =C3=A9crit :
>>>
>>> I think part of the problem, in general, is that any_cast is NOT a
>>>> _cast_.
>>>> It is a "get" (similar to variant<> and optional<>) and should be call=
ed
>>>> get.
>>>> ie casts are expected to be able to do some transformations, but
>>>> any_cast
>>>> doesn't.
>>>>
>>>> ie
>>>>
>>>> any ne =3D 5.7;
>>>> int five =3D any_cast<int>(ne); // fails
>>>>
>>>> similarly, it has been suggested that variant's and optional's get() b=
e
>>>> called some kind of cast to match any. But
>>>>
>>>> variant<int, float> vif =3D 5.7;
>>>> int five =3D get<int>(vif); // fails
>>>>
>>>> because get() is not a cast.
>>>>
>>>> I think they should all be called get().
>>>>
>>>>
>>>> While both get access to an stored value, one can throw (sum types)
>>>>
>>> because the type stored doesn't match and the other not (product types)=
..
>>>
>>
>> I'm confused. Which doesn't throw?
>>
> get<T>(tuple<Ts...>) doesn't throws.
> get<T>(variant<Ts...>) can throw if T is not the stored type.
>
>
Ah, got it.
> Is this enough to don't name the two function the same?
Hmmm, good question. In particular, not just throws vs not throwing, but
one will fail to compile when used incorrectly, the other is at run-time.
One is get() the other is try_get().
tuple-get models the variant-get contract, in that it "returns or throws"
because it never throws, but not vice-versa.
P.S. is get<string>(variant<int,float>) suppose to compile and always
throw, or not compile?
>
> Vicente
>
> --
>
> --- 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/.
>
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--001a113fb8c0f393690520e95e3d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Tue, Sep 29, 2015 at 4:44 PM, Vicente J. Botet Escriba <span dir=3D"=
ltr"><<a href=3D"mailto:vicente.botet@wanadoo.fr" target=3D"_blank">vice=
nte.botet@wanadoo.fr</a>></span> wrote:<br><blockquote class=3D"gmail_qu=
ote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,20=
4);padding-left:1ex">Le 29/09/15 19:55, Tony V E a =C3=A9crit :<span class=
=3D""><br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">
On Tue, Sep 29, 2015 at 1:54 PM, Vicente J. Botet Escriba <<br>
<a href=3D"mailto:vicente.botet@wanadoo.fr" target=3D"_blank">vicente.botet=
@wanadoo.fr</a>> wrote:<br>
<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">
Le 29/09/15 17:02, Tony V E a =C3=A9crit :<br>
<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">
I think part of the problem, in general, is that any_cast is NOT a _cast_.<=
br>
It is a "get" (similar to variant<> and optional<>) a=
nd should be called<br>
get.<br>
ie casts are expected to be able to do some transformations, but any_cast<b=
r>
doesn't.<br>
<br>
ie<br>
<br>
any ne =3D 5.7;<br>
int five =3D any_cast<int>(ne);=C2=A0 // fails<br>
<br>
similarly, it has been suggested that variant's and optional's get(=
) be<br>
called some kind of cast to match any.=C2=A0 But<br>
<br>
variant<int, float> vif =3D 5.7;<br>
int five =3D get<int>(vif);=C2=A0 =C2=A0// fails<br>
<br>
because get() is not a cast.<br>
<br>
I think they should all be called get().<br>
<br>
<br>
While both get access to an stored value, one can throw (sum types)<br>
</blockquote>
because the type stored doesn't match and the other not (product types)=
..<br>
</blockquote>
<br>
I'm confused. Which doesn't throw?<br>
</blockquote></span>
get<T>(tuple<Ts...>) doesn't throws.<br>
get<T>(variant<Ts...>) can throw if T is not the stored type.<b=
r>
<br></blockquote><div><br></div><div>Ah, got it.<br>=C2=A0<br></div><blockq=
uote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1p=
x solid rgb(204,204,204);padding-left:1ex">
Is this enough to don't name the two function the same?</blockquote><di=
v><br></div><div>Hmmm,=C2=A0 good question.=C2=A0 In particular, not just t=
hrows vs not throwing, but one will fail to compile when used incorrectly, =
the other is at run-time.<br>One is get() the other is try_get().<br></div>=
<div><br></div><div>tuple-get models the variant-get contract, in that it &=
quot;returns or throws" because it never throws, but not vice-versa.<b=
r></div><div><br>P.S. is get<string>(variant<int,float>) suppos=
e to compile and always throw, or not compile?<br><br></div><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid =
rgb(204,204,204);padding-left:1ex"><div class=3D""><div class=3D"h5"><br>
<br>
Vicente<br>
<br>
-- <br>
<br>
--- You received this message because you are subscribed to the Google Grou=
ps "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%2Bunsubscribe@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/" rel=3D"noreferrer" target=3D"_blank">http://groups.google.c=
om/a/isocpp.org/group/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--001a113fb8c0f393690520e95e3d--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Tue, 29 Sep 2015 14:54:02 -0700 (PDT)
Raw View
------=_Part_670_751381058.1443563643127
Content-Type: multipart/alternative;
boundary="----=_Part_671_106148369.1443563643127"
------=_Part_671_106148369.1443563643127
Content-Type: text/plain; charset=UTF-8
On Tuesday, September 29, 2015 at 5:19:40 PM UTC-4, Tony V E wrote:
>
> P.S. is get<string>(variant<int,float>) suppose to compile and always
> throw, or not compile?
>
N4542 says that it shouldn't.
-> The type T occurs exactly once in Types... . Otherwise, the program
is ill-formed.
--
---
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_671_106148369.1443563643127
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Tuesday, September 29, 2015 at 5:19:40 PM UTC-4, 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 dir=3D"ltr"><div=
><div class=3D"gmail_quote"><div>P.S. is get<string>(variant<int,f=
loat><wbr>) suppose to compile and always throw, or not compile?<br></di=
v></div></div></div></blockquote><div><br>N4542 says that it shouldn't.=
<br><br>-> The type T occurs exactly once in Types... . Otherwise, the p=
rogram<br>is ill-formed.</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" 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_671_106148369.1443563643127--
------=_Part_670_751381058.1443563643127--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Wed, 30 Sep 2015 00:33:52 +0200
Raw View
Le 29/09/15 23:19, Tony V E a =C3=A9crit :
> On Tue, Sep 29, 2015 at 4:44 PM, Vicente J. Botet Escriba <
> vicente.botet@wanadoo.fr> wrote:
>
>> Le 29/09/15 19:55, Tony V E a =C3=A9crit :
>>
>>> On Tue, Sep 29, 2015 at 1:54 PM, Vicente J. Botet Escriba <
>>> vicente.botet@wanadoo.fr> wrote:
>>>
>>> Le 29/09/15 17:02, Tony V E a =C3=A9crit :
>>>> I think part of the problem, in general, is that any_cast is NOT a
>>>>> _cast_.
>>>>> It is a "get" (similar to variant<> and optional<>) and should be cal=
led
>>>>> get.
>>>>> ie casts are expected to be able to do some transformations, but
>>>>> any_cast
>>>>> doesn't.
>>>>>
>>>>> ie
>>>>>
>>>>> any ne =3D 5.7;
>>>>> int five =3D any_cast<int>(ne); // fails
>>>>>
>>>>> similarly, it has been suggested that variant's and optional's get() =
be
>>>>> called some kind of cast to match any. But
>>>>>
>>>>> variant<int, float> vif =3D 5.7;
>>>>> int five =3D get<int>(vif); // fails
>>>>>
>>>>> because get() is not a cast.
>>>>>
>>>>> I think they should all be called get().
>>>>>
>>>>>
>>>>> While both get access to an stored value, one can throw (sum types)
>>>>>
>>>> because the type stored doesn't match and the other not (product types=
).
>>>>
>>> I'm confused. Which doesn't throw?
>>>
>> get<T>(tuple<Ts...>) doesn't throws.
>> get<T>(variant<Ts...>) can throw if T is not the stored type.
>>
>>
> Ah, got it.
>
>
>> Is this enough to don't name the two function the same?
>
> Hmmm, good question. In particular, not just throws vs not throwing, bu=
t
> one will fail to compile when used incorrectly, the other is at run-time.
> One is get() the other is try_get().
Not really try_get. I would expect as a result a way to check if the=20
type was stored in addition to get the reference to this storage. So=20
try_get would instead retrieve something like optional<T&>. David Krauss=20
has a proposal including recover<T> and try_recover<T>.
>
> tuple-get models the variant-get contract, in that it "returns or throws"
> because it never throws, but not vice-versa.
Right.
Vicente
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Wed, 30 Sep 2015 00:46:16 +0200
Raw View
Le 24/09/15 20:03, nicesw123@gmail.com a =C3=A9crit :
> Hello,
>
> std::experimental::any (boost::any) is nice.
> What I don't like about the current implementation and proposal
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3804.html>, is
> the fact that I cannot any_cast to a type with added low-level const.
>
>
> Example:
> using std::experimental::any;
> using std::experimental::any_cast;
> char str[] =3D "a2";
> any ay(str);
> any_cast<const char*>(ay); // throws, since a const is added!!!
But
const char* p =3D any_cast<char*>(ay);
works as expected.
I believe that this is correct also
auto const * p =3D any_cast<char*>(ay);
Could you give an example where any_cast<const char*>(ay) will be really ne=
eded?
=20
>
> Why should that not be legal??
> All it means is a read-only access to the contained type, and that
> definitely should be legal.
>
> Compare:
> char str2[] =3D "str2";
> static_cast<const char *>(str2); // read-only access (const added)
Are you proposing to add read-only access to any type wrapping other=20
types? e.g get<T const> on tuples? variant?
Vicente
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 30 Sep 2015 05:00:43 +0300
Raw View
On 29 September 2015 at 20:44, Tony V E <tvaneerd@gmail.com> wrote:
>> > It is a "get" (similar to variant<> and optional<>) and should be called
>> > get.
>> Those functions return lvalues.
> I haven't thought about r vs l. Is that what makes a cast a cast?
I don't know what makes a cast a cast to you, but that's certainly one aspect
according to which any_cast is a cast, and an aspect according to which
it's not a get.
>> > ie casts are expected to be able to do some transformations, but
>> > any_cast
>> > doesn't.
>>
>> It transforms an any to an underlying type.
> Only if it already is that type. There is no real transformation.
I wonder what you consider a "real transformation".
> Sure it "transforms" the any, but it really just _gets_ something out of the
> any.
That seems to be talking from an implementation point of view rather
than a semantic point of view.
--
---
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/.
.
Author: ajneu1@gmail.com
Date: Wed, 30 Sep 2015 14:26:35 -0700 (PDT)
Raw View
------=_Part_7710_138264671.1443648395464
Content-Type: multipart/alternative;
boundary="----=_Part_7711_231981603.1443648395465"
------=_Part_7711_231981603.1443648395465
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Wednesday, September 30, 2015 at 12:46:18 AM UTC+2, Vicente J. Botet=20
Escriba wrote:
>
> Le 24/09/15 20:03, nice...@gmail.com <javascript:> a =C3=A9crit :=20
> > Example:=20
> > using std::experimental::any;=20
> > using std::experimental::any_cast;=20
> > char str[] =3D "a2";=20
> > any ay(str);=20
> > any_cast<const char*>(ay); // throws, since a const is added!!!=20
> But=20
>
> const char* p =3D any_cast<char*>(ay);=20
>
> works as expected.=20
>
>
> I believe that this is correct also=20
> auto const * p =3D any_cast<char*>(ay);=20
>
>
> Could you give an example where any_cast<const char*>(ay) will be really=
=20
> needed?=20
> =20
It would be nice to have, for a derived class
class AnyStreamer : public any
that provides operator<< for AnyStreamer and always extracts the type as=
=20
const for printing.
I've got an implementation here=20
<https://github.com/ajneu/any_out/tree/master/3_anystreamer>, where I have=
=20
some statically allocated class variables (e.g. streamer_char_p) for=20
printing e.g. const char* const by using =20
os << any_cast<T>(ay) (where T =3D const char* const)
but I cannot (currently) reuse this class for an any holding a *non*-const =
=20
char
=20
>
>
> Are you proposing to add read-only access to any type wrapping other=20
> types?
>
>
Yes exactly!!! We should always be able to get it as read-only!!=20
(possibly... if so decided... on some wrapper-types might have to=20
mention the linked const read-only type we might want cast to; right at=
=20
the moment we insert the element into the type (e.g. into the any - see=20
here=20
<https://github.com/ajneu/templates__low_level_const__any_cast/blob/7ef0d61=
ba63a419308d280fead58656f19024946/3_any_cast_to_added_lowest_level_const/ma=
in.cpp#L179>)=20
)
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_7711_231981603.1443648395465
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Wednesday, September 30, 2015 at 12:46:18 AM UT=
C+2, Vicente J. Botet Escriba wrote:<blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;">Le 24/09/15 20:03, <a href=3D"javascript:" target=3D"_blank" gdf-obfu=
scated-mailto=3D"rnqcOSsZCgAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D=
'javascript:';return true;" onclick=3D"this.href=3D'javascript:=
';return true;">nice...@gmail.com</a> a =C3=A9crit :
<br>> Example:
<br>> using std::experimental::any;
<br>> using std::experimental::any_cast;
<br>> char str[] =3D "a2";
<br>> any ay(str);
<br>> any_cast<const char*>(ay); // throws, since a const is added=
!!!
<br>But
<br>
<br>const char* p =3D any_cast<char*>(ay);
<br>
<br>works as expected.
<br>
<br>
<br>I believe that this is correct also
<br>auto const * p =3D any_cast<char*>(ay);
<br>
<br></blockquote><div></div><blockquote class=3D"gmail_quote" style=3D"marg=
in: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<br>Could you give an example where any_cast<const char*>(ay) will be=
really needed?
<br>=C2=A0</blockquote><div><br>It would be nice to have, for a derived cla=
ss<br><div style=3D"margin-left: 40px;"><span style=3D"font-family: courier=
new,monospace;">class AnyStreamer : public any</span><br></div>that provid=
es operator<< for <span style=3D"font-family: courier new,monospace;"=
>AnyStreamer</span>=C2=A0 and always extracts the type as const for printin=
g.<br><br>I've got an implementation <a href=3D"https://github.com/ajne=
u/any_out/tree/master/3_anystreamer">here</a>, where I have some statically=
allocated class variables (e.g. <span style=3D"font-family: courier new,mo=
nospace;">streamer_char_p</span>) for printing e.g. <span style=3D"font-fam=
ily: courier new,monospace;">const char* const</span> by using=C2=A0=C2=A0 =
<span style=3D"font-family: courier new,monospace;"><br>os <<=C2=A0 a=
ny_cast<T>(ay)</span>=C2=A0=C2=A0=C2=A0 (where T =3D <span style=3D"f=
ont-family: courier new,monospace;">const char* const)<br></span><br>but I =
cannot (currently) reuse this class for an any holding a <b>non</b>-const=
=C2=A0 <span style=3D"font-family: courier new,monospace;">char</span><br>=
=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">=20
<br>
<br>Are you proposing to add read-only access to any type wrapping other=20
<br>types?<br>
<br></blockquote><div><br>Yes exactly!!! We should always be able to get it=
as read-only!! (possibly...=C2=A0 if so decided... =C2=A0 on some wrapper-=
types might have to mention the linked=C2=A0=C2=A0 const read-only type we =
might want cast to; right at the moment we insert the element into the type=
(e.g. into the <span style=3D"font-family: courier new,monospace;">any</sp=
an>=C2=A0 - see <a href=3D"https://github.com/ajneu/templates__low_level_co=
nst__any_cast/blob/7ef0d61ba63a419308d280fead58656f19024946/3_any_cast_to_a=
dded_lowest_level_const/main.cpp#L179">here</a>) )<br><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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_7711_231981603.1443648395465--
------=_Part_7710_138264671.1443648395464--
.
Author: ajneu1@gmail.com
Date: Wed, 30 Sep 2015 14:39:13 -0700 (PDT)
Raw View
------=_Part_686_132325416.1443649153654
Content-Type: multipart/alternative;
boundary="----=_Part_687_185837319.1443649153654"
------=_Part_687_185837319.1443649153654
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Wednesday, September 30, 2015 at 11:26:35 PM UTC+2, ajn...@gmail.com=20
wrote:
>
> On Wednesday, September 30, 2015 at 12:46:18 AM UTC+2, Vicente J. Botet=
=20
> Escriba wrote:
>>
>> Are you proposing to add read-only access to any type wrapping other=20
>> types?
>>
>>
> Yes exactly!!! We should always be able to get it as read-only!!=20
> (possibly... if so decided... on some wrapper-types might have to=20
> mention the linked const read-only type we might want cast to; right at=
=20
> the moment we insert the element into the type (e.g. into the any - see=
=20
> here=20
> <https://www.google.com/url?q=3Dhttps%3A%2F%2Fgithub.com%2Fajneu%2Ftempla=
tes__low_level_const__any_cast%2Fblob%2F7ef0d61ba63a419308d280fead58656f190=
24946%2F3_any_cast_to_added_lowest_level_const%2Fmain.cpp%23L179&sa=3DD&snt=
z=3D1&usg=3DAFQjCNEORJIQhr7721J61Tj02Ygjk-6SwA>)=20
> )
>
>
Also: the any type definitely must have a function in its public interface,=
=20
that allows unsafe casts. Example boost::unsafe_any_cast (as used e.g here=
=20
<https://github.com/ajneu/templates__low_level_const__any_cast/blob/7ef0d61=
ba63a419308d280fead58656f19024946/3_any_cast_to_added_lowest_level_const/ma=
in.cpp#L136>
).
You should not deprive the user the possibility of casting to types about=
=20
which the wrapper does not yet know anything about.
(Of course better is to register the potential types one would like to cast=
=20
to, at the moment on inserts an element into the container example=20
<https://www.google.com/url?q=3Dhttps%3A%2F%2Fgithub.com%2Fajneu%2Ftemplate=
s__low_level_const__any_cast%2Fblob%2F7ef0d61ba63a419308d280fead58656f19024=
946%2F3_any_cast_to_added_lowest_level_const%2Fmain.cpp%23L179&sa=3DD&sntz=
=3D1&usg=3DAFQjCNEORJIQhr7721J61Tj02Ygjk-6SwA>,=20
so that the compiler can statically check that the cast is legal example=20
<https://github.com/ajneu/templates__low_level_const__any_cast/blob/7ef0d61=
ba63a419308d280fead58656f19024946/3_any_cast_to_added_lowest_level_const/ma=
in.cpp#L70>
)
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_687_185837319.1443649153654
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<br><br>On Wednesday, September 30, 2015 at 11:26:35 PM UTC+2, ajn...@gmail=
..com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left=
: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">On=
Wednesday, September 30, 2015 at 12:46:18 AM UTC+2, Vicente J. Botet Escri=
ba wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.=
8ex;border-left:1px #ccc solid;padding-left:1ex">=20
Are you proposing to add read-only access to any type wrapping other=20
<br>types?<br>
<br></blockquote><div><br>Yes exactly!!! We should always be able to get it=
as read-only!! (possibly...=C2=A0 if so decided... =C2=A0 on some wrapper-=
types might have to mention the linked=C2=A0=C2=A0 const read-only type we =
might want cast to; right at the moment we insert the element into the type=
(e.g. into the <span style=3D"font-family:courier new,monospace">any</span=
>=C2=A0 - see <a href=3D"https://www.google.com/url?q=3Dhttps%3A%2F%2Fgithu=
b.com%2Fajneu%2Ftemplates__low_level_const__any_cast%2Fblob%2F7ef0d61ba63a4=
19308d280fead58656f19024946%2F3_any_cast_to_added_lowest_level_const%2Fmain=
..cpp%23L179&sa=3DD&sntz=3D1&usg=3DAFQjCNEORJIQhr7721J61Tj02Ygjk=
-6SwA" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'h=
ttps://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fajneu%2Ftemplates_=
_low_level_const__any_cast%2Fblob%2F7ef0d61ba63a419308d280fead58656f1902494=
6%2F3_any_cast_to_added_lowest_level_const%2Fmain.cpp%23L179\46sa\75D\46snt=
z\0751\46usg\75AFQjCNEORJIQhr7721J61Tj02Ygjk-6SwA';return true;" onclic=
k=3D"this.href=3D'https://www.google.com/url?q\75https%3A%2F%2Fgithub.c=
om%2Fajneu%2Ftemplates__low_level_const__any_cast%2Fblob%2F7ef0d61ba63a4193=
08d280fead58656f19024946%2F3_any_cast_to_added_lowest_level_const%2Fmain.cp=
p%23L179\46sa\75D\46sntz\0751\46usg\75AFQjCNEORJIQhr7721J61Tj02Ygjk-6SwA=
9;;return true;">here</a>) )<br><br></div></div></blockquote><div><br>Also:=
the any type definitely must have a function in its public interface, that=
allows unsafe casts. Example <span style=3D"font-family: courier new,monos=
pace;">boost::unsafe_any_cast<span style=3D"font-family: arial,sans-serif;"=
> (as used e.g <a href=3D"https://github.com/ajneu/templates__low_level_con=
st__any_cast/blob/7ef0d61ba63a419308d280fead58656f19024946/3_any_cast_to_ad=
ded_lowest_level_const/main.cpp#L136">here</a>)</span>.<br><span style=3D"f=
ont-family: arial,sans-serif;">You should not deprive the user the possibil=
ity of casting to types about which the wrapper does not yet know anything =
about.<br>(Of course better is to register the potential types one would li=
ke to cast to, at the moment on inserts an element into the container </spa=
n></span><span style=3D"font-family: courier new,monospace;"><span style=3D=
"font-family: arial,sans-serif;"><a href=3D"https://www.google.com/url?q=3D=
https%3A%2F%2Fgithub.com%2Fajneu%2Ftemplates__low_level_const__any_cast%2Fb=
lob%2F7ef0d61ba63a419308d280fead58656f19024946%2F3_any_cast_to_added_lowest=
_level_const%2Fmain.cpp%23L179&sa=3DD&sntz=3D1&usg=3DAFQjCNEORJ=
IQhr7721J61Tj02Ygjk-6SwA" target=3D"_blank" rel=3D"nofollow">example</a>, s=
o that the compiler can statically check that the cast is legal <a href=3D"=
https://github.com/ajneu/templates__low_level_const__any_cast/blob/7ef0d61b=
a63a419308d280fead58656f19024946/3_any_cast_to_added_lowest_level_const/mai=
n.cpp#L70">example</a>)<br><br></span></span></div>
<p></p>
-- <br />
<br />
--- <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 />
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_687_185837319.1443649153654--
------=_Part_686_132325416.1443649153654--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Thu, 1 Oct 2015 00:09:53 +0200
Raw View
This is a multi-part message in MIME format.
--------------080803030309050408040802
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Le 30/09/15 23:26, ajneu1@gmail.com a =C3=A9crit :
>
> On Wednesday, September 30, 2015 at 12:46:18 AM UTC+2, Vicente J. Botet
> Escriba wrote:
>> Le 24/09/15 20:03, nice...@gmail.com <javascript:> a =C3=A9crit :
>>> Example:
>>> using std::experimental::any;
>>> using std::experimental::any_cast;
>>> char str[] =3D "a2";
>>> any ay(str);
>>> any_cast<const char*>(ay); // throws, since a const is added!!!
>> But
>>
>> const char* p =3D any_cast<char*>(ay);
>>
>> works as expected.
>>
>>
>> I believe that this is correct also
>> auto const * p =3D any_cast<char*>(ay);
>>
>>
>> Could you give an example where any_cast<const char*>(ay) will be really
>> needed?
>> =20
>
> It would be nice to have, for a derived class
> class AnyStreamer : public any
> that provides operator<< for AnyStreamer and always extracts the type as
> const for printing.
>
> I've got an implementation here
> <https://github.com/ajneu/any_out/tree/master/3_anystreamer>, where I hav=
e
> some statically allocated class variables (e.g. streamer_char_p) for
> printing e.g. const char* const by using
> os << any_cast<T>(ay) (where T =3D const char* const)
>
> but I cannot (currently) reuse this class for an any holding a *non*-cons=
t
> char
> =20
Why do you need
struct static_streamer {
static streamer_impl<const char * const> streamer_char_p;
static streamer_impl<const std::string&> streamer_string;
static streamer_impl<const int> streamer_int;
};
and not
struct static_streamer {
static streamer_impl<const char *> streamer_char_p;
static streamer_impl<std::string> streamer_string;
static streamer_impl<int> streamer_int;
};
?
Vicente
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--------------080803030309050408040802
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
</head>
<body bgcolor=3D"#FFFFFF" text=3D"#000000">
<div class=3D"moz-cite-prefix">Le 30/09/15 23:26, <a class=3D"moz-txt-l=
ink-abbreviated" href=3D"mailto:ajneu1@gmail.com">ajneu1@gmail.com</a> a
=C3=A9crit=C2=A0:<br>
</div>
<blockquote
cite=3D"mid:79ab20be-1d26-4a22-a8b2-9147f8cd31ba@isocpp.org"
type=3D"cite">
<pre wrap=3D"">
On Wednesday, September 30, 2015 at 12:46:18 AM UTC+2, Vicente J. Botet=20
Escriba wrote:
</pre>
<blockquote type=3D"cite">
<pre wrap=3D"">
Le 24/09/15 20:03, <a class=3D"moz-txt-link-abbreviated" href=3D"mailto:nic=
e...@gmail.com">nice...@gmail.com</a> <javascript:> a =C3=A9crit :=20
</pre>
<blockquote type=3D"cite">
<pre wrap=3D"">Example:=20
using std::experimental::any;=20
using std::experimental::any_cast;=20
char str[] =3D "a2";=20
any ay(str);=20
any_cast<const char*>(ay); // throws, since a const is added!!!=20
</pre>
</blockquote>
<pre wrap=3D"">But=20
const char* p =3D any_cast<char*>(ay);=20
works as expected.=20
I believe that this is correct also=20
auto const * p =3D any_cast<char*>(ay);=20
Could you give an example where any_cast<const char*>(ay) will be rea=
lly=20
needed?=20
=20
</pre>
</blockquote>
<pre wrap=3D"">
It would be nice to have, for a derived class
class AnyStreamer : public any
that provides operator<< for AnyStreamer and always extracts the typ=
e as=20
const for printing.
I've got an implementation here=20
<a class=3D"moz-txt-link-rfc2396E" href=3D"https://github.com/ajneu/any_out=
/tree/master/3_anystreamer"><https://github.com/ajneu/any_out/tree/maste=
r/3_anystreamer></a>, where I have=20
some statically allocated class variables (e.g. streamer_char_p) for=20
printing e.g. const char* const by using =20
os << any_cast<T>(ay) (where T =3D const char* const)
but I cannot (currently) reuse this class for an any holding a *non*-const =
=20
char
</pre>
</blockquote>
Why do you need<br>
<br>
<meta http-equiv=3D"content-type" content=3D"text/html; charset=3Dutf-8=
">
struct static_streamer {<br>
=C2=A0 static streamer_impl<const char * const>=C2=A0 streamer_ch=
ar_p;<br>
=C2=A0 static streamer_impl<const std::string&>=C2=A0
streamer_string;<br>
=C2=A0 static streamer_impl<const int>=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 streamer_int;<br>
};<br>
<br>
and not<br>
<br>
struct static_streamer {<br>
=C2=A0 static streamer_impl<const char *>=C2=A0 streamer_char_p;<=
br>
=C2=A0 static streamer_impl<std::string>=C2=A0 streamer_string;<b=
r>
=C2=A0 static streamer_impl<int>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 streamer_int;<br>
};<br>
<br>
?<br>
<br>
Vicente<br>
</body>
</html>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--------------080803030309050408040802--
.
Author: David Krauss <potswa@gmail.com>
Date: Thu, 1 Oct 2015 07:01:59 +0800
Raw View
--Apple-Mail=_AFAB1E20-5C0C-43C3-BDF6-7E4DB8F5BAF7
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9310=E2=80=9301, at 5:26 AM, ajneu1@gmail.com wrote:
>=20
> It would be nice to have, for a derived class
> class AnyStreamer : public any
> that provides operator<< for AnyStreamer and always extracts the type as=
const for printing.
My current proposal propagates const automatically. So, given const any &a,=
then recover<std::string>(a) would return const string&. If you want non-c=
onst, then you=E2=80=99ll need to add a const_cast.
> but I cannot (currently) reuse this class for an any holding a non-const =
char
You should already be able to use const_cast. Note that any doesn=E2=80=99t=
conceptually hold a const or non-const. It always holds non-const and then=
it can be const. C++ doesn=E2=80=99t allow objects to ask whether they=E2=
=80=99re truly const or just being accessed by a const&.
> On 2015=E2=80=9310=E2=80=9301, at 5:39 AM, ajneu1@gmail.com wrote:
>=20
> Also: the any type definitely must have a function in its public interfac=
e, that allows unsafe casts. Example boost::unsafe_any_cast(as used e.g her=
e <https://github.com/ajneu/templates__low_level_const__any_cast/blob/7ef0d=
61ba63a419308d280fead58656f19024946/3_any_cast_to_added_lowest_level_const/=
main.cpp#L136>).
> You should not deprive the user the possibility of casting to types about=
which the wrapper does not yet know anything about.
> (Of course better is to register the potential types one would like to ca=
st to, at the moment on inserts an element into the container example <http=
s://www.google.com/url?q=3Dhttps%3A%2F%2Fgithub.com%2Fajneu%2Ftemplates__lo=
w_level_const__any_cast%2Fblob%2F7ef0d61ba63a419308d280fead58656f19024946%2=
F3_any_cast_to_added_lowest_level_const%2Fmain.cpp%23L179&sa=3DD&sntz=3D1&u=
sg=3DAFQjCNEORJIQhr7721J61Tj02Ygjk-6SwA>, so that the compiler can statical=
ly check that the cast is legal example <https://github.com/ajneu/templates=
__low_level_const__any_cast/blob/7ef0d61ba63a419308d280fead58656f19024946/3=
_any_cast_to_added_lowest_level_const/main.cpp#L70>)
I proposed something like this too, a member complete_object_address(). Ple=
ase read <http://bit.ly/reccast>.
Sorry that I=E2=80=99m not taking the time to review your code, but this is=
n=E2=80=99t a forum for code review, it=E2=80=99s a forum for discussion of=
proposals.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_AFAB1E20-5C0C-43C3-BDF6-7E4DB8F5BAF7
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9310=
=E2=80=9301, at 5:26 AM, <a href=3D"mailto:ajneu1@gmail.com" class=3D"">ajn=
eu1@gmail.com</a> wrote:</div><br class=3D"Apple-interchange-newline"><div =
class=3D""><div dir=3D"ltr" class=3D"">It would be nice to have, for a deri=
ved class<br class=3D""><div class=3D""><div style=3D"margin-left: 40px;" c=
lass=3D""><span style=3D"font-family: courier new,monospace;" class=3D"">cl=
ass AnyStreamer : public any</span><br class=3D""></div>that provides opera=
tor<< for <span style=3D"font-family: courier new,monospace;" class=
=3D"">AnyStreamer</span> and always extracts the type as const for pr=
inting.<br class=3D""></div></div></div></blockquote><div><br class=3D""></=
div><div>My current proposal propagates const automatically. So, given <fon=
t face=3D"Courier" class=3D"">const any &a</font>, then <font face=3D"C=
ourier" class=3D"">recover<std::string>(a)</font> would return <font =
face=3D"Courier" class=3D"">const string&</font>. If you want non-const=
, then you=E2=80=99ll need to add a <font face=3D"Courier" class=3D"">const=
_cast</font>.</div><br class=3D""><blockquote type=3D"cite" class=3D""><div=
class=3D""><div dir=3D"ltr" class=3D""><div class=3D"">but I cannot (curre=
ntly) reuse this class for an any holding a <b class=3D"">non</b>-const&nbs=
p; <span class=3D"" style=3D"font-family: 'courier new', monospace;">char</=
span><br class=3D""></div></div></div></blockquote><br class=3D""></div><di=
v>You should already be able to use <font face=3D"Courier" class=3D"">const=
_cast</font>. Note that <span style=3D"font-family: Courier;" class=3D=
"">any</span> doesn=E2=80=99t conceptually hold a const or non-const. =
It always holds non-const and then it can <i class=3D"">be</i> const. =
C++ doesn=E2=80=99t allow objects to ask whether they=E2=80=99re truly cons=
t or just being accessed by a <font face=3D"Courier" class=3D"">const&<=
/font>.</div><div><br class=3D""></div><br class=3D""><div class=3D""><bloc=
kquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9310=E2=80=93=
01, at 5:39 AM, <a href=3D"mailto:ajneu1@gmail.com" class=3D"">ajneu1@gmail=
..com</a> wrote:</div><br class=3D"Apple-interchange-newline"><div class=3D"=
"><span class=3D"" style=3D"float: none; display: inline !important;">Also:=
the any type definitely must have a function in its public interface, that=
allows unsafe casts. Example </span><span class=3D"" style=3D"font-fa=
mily: 'courier new', monospace;">boost::unsafe_any_cast<span class=3D"" sty=
le=3D"font-family: arial, sans-serif;">(as used e.g <a href=3D"https:/=
/github.com/ajneu/templates__low_level_const__any_cast/blob/7ef0d61ba63a419=
308d280fead58656f19024946/3_any_cast_to_added_lowest_level_const/main.cpp#L=
136" class=3D"">here</a>)</span>.<br class=3D""><span class=3D"" style=3D"f=
ont-family: arial, sans-serif;">You should not deprive the user the possibi=
lity of casting to types about which the wrapper does not yet know anything=
about.<br class=3D"">(Of course better is to register the potential types =
one would like to cast to, at the moment on inserts an element into the con=
tainer </span></span><span class=3D"" style=3D"font-family: 'courier n=
ew', monospace;"><span class=3D"" style=3D"font-family: arial, sans-serif;"=
><a href=3D"https://www.google.com/url?q=3Dhttps%3A%2F%2Fgithub.com%2Fajneu=
%2Ftemplates__low_level_const__any_cast%2Fblob%2F7ef0d61ba63a419308d280fead=
58656f19024946%2F3_any_cast_to_added_lowest_level_const%2Fmain.cpp%23L179&a=
mp;sa=3DD&sntz=3D1&usg=3DAFQjCNEORJIQhr7721J61Tj02Ygjk-6SwA" target=
=3D"_blank" rel=3D"nofollow" class=3D"">example</a>, so that the compiler c=
an statically check that the cast is legal <a href=3D"https://github.c=
om/ajneu/templates__low_level_const__any_cast/blob/7ef0d61ba63a419308d280fe=
ad58656f19024946/3_any_cast_to_added_lowest_level_const/main.cpp#L70" class=
=3D"">example</a>)</span></span></div></blockquote></div><div class=3D""><d=
iv class=3D""><span class=3D"" style=3D"font-family: 'courier new', monospa=
ce;"><span class=3D"" style=3D"font-family: arial, sans-serif;"><br class=
=3D""></span></span></div></div><div class=3D""><span class=3D""><span clas=
s=3D"" style=3D"font-family: arial, sans-serif;">I proposed something like =
this too, a member </span><span class=3D""><font face=3D"Courier" class=3D"=
">complete_object_address()</font></span><span class=3D"" style=3D"font-fam=
ily: arial, sans-serif;">. <a href=3D"http://bit.ly/reccast" class=3D"=
">Please read</a>.</span></span></div><div class=3D""><span class=3D"" styl=
e=3D"font-family: 'courier new', monospace;"><span class=3D"" style=3D"font=
-family: arial, sans-serif;"><br class=3D""></span></span></div><div class=
=3D""><span class=3D"" style=3D"font-family: 'courier new', monospace;"><sp=
an class=3D"" style=3D"font-family: arial, sans-serif;">Sorry that I=E2=80=
=99m not taking the time to review your code, but this isn=E2=80=99t a foru=
m for code review, it=E2=80=99s a forum for </span></span><span style=
=3D"font-family: arial, sans-serif;" class=3D"">discussion of </span><=
span style=3D"font-family: arial, sans-serif;" class=3D"">proposals.</span>=
</div><div class=3D""><span class=3D"" style=3D"font-family: 'courier new',=
monospace;"><span class=3D"" style=3D"font-family: arial, sans-serif;"><br=
class=3D""></span></span></div></body></html>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--Apple-Mail=_AFAB1E20-5C0C-43C3-BDF6-7E4DB8F5BAF7--
.
Author: David Krauss <potswa@gmail.com>
Date: Thu, 1 Oct 2015 07:23:52 +0800
Raw View
--Apple-Mail=_BDA2E7ED-1A0A-48CB-9166-9D2B704E5B3E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
Sorry, I never really addressed the first post=E2=80=A6 the second post was=
distracting.
> On 2015=E2=80=9309=E2=80=9325, at 2:03 AM, nicesw123@gmail.com wrote:
>=20
> Example:
> using std::experimental::any;
> using std::experimental::any_cast;
> char str[] =3D "a2";
> any ay(str);
> any_cast<const char*>(ay); // throws, since a const is added!!!
>=20
>=20
> Why should that not be legal??
It doesn=E2=80=99t work because typeid(char*) !=3D typeid(const char*). Thi=
s is in contrast to typeid(char&) =3D=3D typeid(const char&).
> All it means is a read-only access to the contained type, and that defini=
tely should be legal.
If it were a cast, you=E2=80=99d have a point. There are also other things =
any_cast can=E2=80=99t do, such as derived-to-base conversion, because it=
=E2=80=99s not really a cast at all. Hence I have proposed to rename it.
That said, my proposal does leave room for a class like any to allow you to=
retrieve (recover) a const char* when it=E2=80=99s given a char*. Each cla=
ss makes its own rules and you should be able to add this (under my proposa=
l) by deriving from experimental::any and adjusting verify_type. However, I=
don=E2=80=99t think this direction is likely to be taken by the standard, =
because it=E2=80=99s (nearly) impossible to support adding inner, nth-level=
const qualifications in the general case.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_BDA2E7ED-1A0A-48CB-9166-9D2B704E5B3E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D"">Sorry, I never rea=
lly addressed the first post=E2=80=A6 the second post was distracting.<div =
class=3D""><br class=3D""><div><blockquote type=3D"cite" class=3D""><div cl=
ass=3D"">On 2015=E2=80=9309=E2=80=9325, at 2:03 AM, <a href=3D"mailto:nices=
w123@gmail.com" class=3D"">nicesw123@gmail.com</a> wrote:</div><br class=3D=
"Apple-interchange-newline"><div class=3D""><span style=3D"font-family: Hel=
vetica; font-size: 12px; font-style: normal; font-variant: normal; font-wei=
ght: normal; letter-spacing: normal; line-height: normal; orphans: auto; te=
xt-align: start; text-indent: 0px; text-transform: none; white-space: norma=
l; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: =
none; display: inline !important;" class=3D"">Example:</span><br style=3D"f=
ont-family: Helvetica; font-size: 12px; font-style: normal; font-variant: n=
ormal; font-weight: normal; letter-spacing: normal; line-height: normal; or=
phans: auto; text-align: start; text-indent: 0px; text-transform: none; whi=
te-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-widt=
h: 0px;" class=3D""><div class=3D"prettyprint" style=3D"font-family: Helvet=
ica; font-size: 12px; font-style: normal; font-variant: normal; font-weight=
: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-=
align: start; text-indent: 0px; text-transform: none; white-space: normal; =
widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background=
-color: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-wrap=
: break-word;"><code class=3D"prettyprint"><span class=3D"styled-by-prettif=
y" style=3D"color: rgb(0, 0, 136);">using</span><span class=3D"Apple-conver=
ted-space"> </span>std<span class=3D"styled-by-prettify" style=3D"colo=
r: rgb(102, 102, 0);">::</span>experimental<span class=3D"styled-by-prettif=
y" style=3D"color: rgb(102, 102, 0);">::</span>any<span class=3D"styled-by-=
prettify" style=3D"color: rgb(102, 102, 0);">;</span><br class=3D""><span c=
lass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">using</span><s=
pan class=3D"Apple-converted-space"> </span>std<span class=3D"styled-b=
y-prettify" style=3D"color: rgb(102, 102, 0);">::</span>experimental<span c=
lass=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">::</span>any=
_cast<span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">=
;</span><br class=3D""><span class=3D"styled-by-prettify" style=3D"color: r=
gb(0, 0, 136);">char</span><span class=3D"Apple-converted-space"> </sp=
an>str<span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);"=
>[]</span> <span class=3D"styled-by-prettify" style=3D"color: rgb(102,=
102, 0);">=3D</span> <span class=3D"styled-by-prettify" style=3D"colo=
r: rgb(0, 136, 0);">"a2"</span><span class=3D"styled-by-prettify" style=3D"=
color: rgb(102, 102, 0);">;</span><br class=3D"">any ay<span class=3D"style=
d-by-prettify" style=3D"color: rgb(102, 102, 0);">(</span>str<span class=3D=
"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">);</span><br class=
=3D"">any_cast<span class=3D"styled-by-prettify" style=3D"color: rgb(102, 1=
02, 0);"><</span><span class=3D"styled-by-prettify" style=3D"color: rgb(=
0, 0, 136);">const</span> <span class=3D"styled-by-prettify" style=3D"=
color: rgb(0, 0, 136);">char</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(102, 102, 0);">*>(</span>ay<span class=3D"styled-by-prett=
ify" style=3D"color: rgb(102, 102, 0);">);</span> <span class=3D"style=
d-by-prettify" style=3D"color: rgb(136, 0, 0);">// throws, since a const is=
added!!!</span><br class=3D""></code></div><br style=3D"font-family: Helve=
tica; font-size: 12px; font-style: normal; font-variant: normal; font-weigh=
t: normal; letter-spacing: normal; line-height: normal; orphans: auto; text=
-align: start; text-indent: 0px; text-transform: none; white-space: normal;=
widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D=
""><br style=3D"font-family: Helvetica; font-size: 12px; font-style: normal=
; font-variant: normal; font-weight: normal; letter-spacing: normal; line-h=
eight: normal; orphans: auto; text-align: start; text-indent: 0px; text-tra=
nsform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit=
-text-stroke-width: 0px;" class=3D""><span style=3D"font-family: Helvetica;=
font-size: 12px; font-style: normal; font-variant: normal; font-weight: no=
rmal; letter-spacing: normal; line-height: normal; orphans: auto; text-alig=
n: start; text-indent: 0px; text-transform: none; white-space: normal; wido=
ws: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; d=
isplay: inline !important;" class=3D"">Why should that not be legal??</span=
><br style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; =
font-variant: normal; font-weight: normal; letter-spacing: normal; line-hei=
ght: normal; orphans: auto; text-align: start; text-indent: 0px; text-trans=
form: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-t=
ext-stroke-width: 0px;" class=3D""></div></blockquote><div><br class=3D""><=
/div><div>It doesn=E2=80=99t work because <font face=3D"Courier" class=3D""=
>typeid(char*) !=3D typeid(const char*)</font>. This is in contrast to <fon=
t face=3D"Courier" class=3D"">typeid(char&) =3D=3D typeid(const char&am=
p;)</font>.</div><br class=3D""><blockquote type=3D"cite" class=3D""><div c=
lass=3D""><span style=3D"font-family: Helvetica; font-size: 12px; font-styl=
e: normal; font-variant: normal; font-weight: normal; letter-spacing: norma=
l; line-height: normal; orphans: auto; text-align: start; text-indent: 0px;=
text-transform: none; white-space: normal; widows: auto; word-spacing: 0px=
; -webkit-text-stroke-width: 0px; float: none; display: inline !important;"=
class=3D"">All it means is a read-only access to the contained type, and t=
hat definitely should be legal.</span><br style=3D"font-family: Helvetica; =
font-size: 12px; font-style: normal; font-variant: normal; font-weight: nor=
mal; letter-spacing: normal; line-height: normal; orphans: auto; text-align=
: start; text-indent: 0px; text-transform: none; white-space: normal; widow=
s: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""></d=
iv></blockquote></div><br class=3D""></div><div class=3D"">If it were a cas=
t, you=E2=80=99d have a point. There are also other things <font face=3D"Co=
urier" class=3D"">any_cast</font> can=E2=80=99t do, such as derived-to-base=
conversion, because it=E2=80=99s not really a cast at all. Hence I have pr=
oposed to rename it.</div><div class=3D""><br class=3D""></div><div class=
=3D"">That said, my proposal does leave room for a class like <span st=
yle=3D"font-family: Courier;" class=3D"">any</span> to allow you to re=
trieve (recover) a <font face=3D"Courier" class=3D"">const char*</font> whe=
n it=E2=80=99s given a <font face=3D"Courier" class=3D"">char*</font>. Each=
class makes its own rules and you should be able to add this (under my pro=
posal) by deriving from <font face=3D"Courier" class=3D"">experimental::any=
</font> and adjusting <font face=3D"Courier" class=3D"">verify_type</f=
ont>. However, I don=E2=80=99t think this direction is likely to be taken b=
y the standard, because it=E2=80=99s (nearly) impossible to support adding =
inner, nth-level const qualifications in the general case.</div><div class=
=3D""><br class=3D""></div></body></html>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--Apple-Mail=_BDA2E7ED-1A0A-48CB-9166-9D2B704E5B3E--
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Thu, 1 Oct 2015 15:25:57 -0400
Raw View
--047d7b3a84c640cd3e0521100482
Content-Type: text/plain; charset=UTF-8
On Tue, Sep 29, 2015 at 10:00 PM, Ville Voutilainen <
ville.voutilainen@gmail.com> wrote:
> On 29 September 2015 at 20:44, Tony V E <tvaneerd@gmail.com> wrote:
> >> > It is a "get" (similar to variant<> and optional<>) and should be
> called
> >> > get.
> >> Those functions return lvalues.
> > I haven't thought about r vs l. Is that what makes a cast a cast?
>
> I don't know what makes a cast a cast to you, but that's certainly one
> aspect
> according to which any_cast is a cast, and an aspect according to which
> it's not a get.
>
> >> > ie casts are expected to be able to do some transformations, but
> >> > any_cast
> >> > doesn't.
> >>
> >> It transforms an any to an underlying type.
> > Only if it already is that type. There is no real transformation.
>
> I wonder what you consider a "real transformation".
>
> > Sure it "transforms" the any, but it really just _gets_ something out of
> the
> > any.
>
> That seems to be talking from an implementation point of view rather
> than a semantic point of view.
>
>
Do you consider variant and optional get() casts then?
Tony
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--047d7b3a84c640cd3e0521100482
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Tue, Sep 29, 2015 at 10:00 PM, Ville Voutilainen <span dir=3D"ltr">&=
lt;<a href=3D"mailto:ville.voutilainen@gmail.com" target=3D"_blank">ville.v=
outilainen@gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail_qu=
ote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex=
"><span class=3D"">On 29 September 2015 at 20:44, Tony V E <<a href=3D"m=
ailto:tvaneerd@gmail.com">tvaneerd@gmail.com</a>> wrote:<br>
>> > It is a "get" (similar to variant<> and optio=
nal<>) and should be called<br>
>> > get.<br>
>> Those functions return lvalues.<br>
> I haven't thought about r vs l.=C2=A0 Is that what makes a cast a =
cast?<br>
<br>
</span>I don't know what makes a cast a cast to you, but that's cer=
tainly one aspect<br>
according to which any_cast is a cast, and an aspect according to which<br>
it's not a get.<br>
<span class=3D""><br>
>> > ie casts are expected to be able to do some transformations, =
but<br>
>> > any_cast<br>
>> > doesn't.<br>
>><br>
>> It transforms an any to an underlying type.<br>
> Only if it already is that type.=C2=A0 There is no real transformation=
..<br>
<br>
</span>I wonder what you consider a "real transformation".<br>
<span class=3D""><br>
> Sure it "transforms" the any, but it really just _gets_ some=
thing out of the<br>
> any.<br>
<br>
</span>That seems to be talking from an implementation point of view rather=
<br>
than a semantic point of view.<br>
<div class=3D"HOEnZb"><div class=3D"h5"><br></div></div></blockquote><div><=
br><br></div><div>Do you consider variant and optional get() casts then?<br=
></div></div>Tony<br><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--047d7b3a84c640cd3e0521100482--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Thu, 1 Oct 2015 22:33:47 +0300
Raw View
On 1 October 2015 at 22:25, Tony V E <tvaneerd@gmail.com> wrote:
>> > Sure it "transforms" the any, but it really just _gets_ something out of
>> > the
>> > any.
>> That seems to be talking from an implementation point of view rather
>> than a semantic point of view.
> Do you consider variant and optional get() casts then?
From the lvalue/rvalue point of view, not really, but they are conversions.
Do you consider dynamic_pointer_cast not to be a cast, since it's somewhat
related to any_cast? It also just "gets something out" of a shared_ptr.
I don't think we should rename any_cast. We might entertain the idea of adding
generic programming facilities that can do such value extraction for different
types.
--
---
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/.
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Thu, 1 Oct 2015 17:07:16 -0400
Raw View
--001a11c3ea4295823f0521116e23
Content-Type: text/plain; charset=UTF-8
On Thu, Oct 1, 2015 at 3:33 PM, Ville Voutilainen <
ville.voutilainen@gmail.com> wrote:
> On 1 October 2015 at 22:25, Tony V E <tvaneerd@gmail.com> wrote:
> >> > Sure it "transforms" the any, but it really just _gets_ something out
> of
> >> > the
> >> > any.
> >> That seems to be talking from an implementation point of view rather
> >> than a semantic point of view.
> > Do you consider variant and optional get() casts then?
>
> From the lvalue/rvalue point of view, not really, but they are conversions.
>
> Do you consider dynamic_pointer_cast not to be a cast, since it's somewhat
> related to any_cast? It also just "gets something out" of a shared_ptr.
>
> I don't think we should rename any_cast. We might entertain the idea of
> adding
> generic programming facilities that can do such value extraction for
> different
> types.
>
>
Vincente has a proposal (P0032) for unifying some operations over variant,
optional, any, etc.
That's why I'm wondering if get() and cast are different or not, and
whether there should be one name (and which) or two.
Also David's std::recover (P0042).
--
>
> ---
> 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/.
--001a11c3ea4295823f0521116e23
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Thu, Oct 1, 2015 at 3:33 PM, Ville Voutilainen <span dir=3D"ltr"><=
;<a href=3D"mailto:ville.voutilainen@gmail.com" target=3D"_blank">ville.vou=
tilainen@gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail_quot=
e" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">=
<span class=3D"">On 1 October 2015 at 22:25, Tony V E <<a href=3D"mailto=
:tvaneerd@gmail.com">tvaneerd@gmail.com</a>> wrote:<br>
>> > Sure it "transforms" the any, but it really just _g=
ets_ something out of<br>
>> > the<br>
>> > any.<br>
>> That seems to be talking from an implementation point of view rath=
er<br>
>> than a semantic point of view.<br>
> Do you consider variant and optional get() casts then?<br>
<br>
</span>From the lvalue/rvalue point of view, not really, but they are conve=
rsions.<br>
<br>
Do you consider dynamic_pointer_cast not to be a cast, since it's somew=
hat<br>
related to any_cast? It also just "gets something out" of a share=
d_ptr.<br>
<br>
I don't think we should rename any_cast. We might entertain the idea of=
adding<br>
generic programming facilities that can do such value extraction for differ=
ent<br>
types.<br>
<div class=3D"HOEnZb"><div class=3D"h5"><br></div></div></blockquote><div><=
br></div><div>Vincente has a proposal (P0032) for unifying some operations =
over variant, optional, any, etc.<br></div><div>That's why I'm wond=
ering if get() and cast are different or not, and whether there should be o=
ne name (and which) or two.<br></div><div>Also David's std::recover (P0=
042).<br><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 =
..8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=3D"HOEnZb"><di=
v class=3D"h5">
--<br>
<br>
---<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%2Bunsubscribe@isocpp.org">std-propo=
sals+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/" rel=3D"noreferrer" target=3D"_blank">http://groups.google.c=
om/a/isocpp.org/group/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--001a11c3ea4295823f0521116e23--
.
Author: David Krauss <potswa@gmail.com>
Date: Fri, 2 Oct 2015 07:39:39 +0800
Raw View
--Apple-Mail=_D501615F-F4FF-49C1-9827-594834ACB327
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9310=E2=80=9302, at 5:07 AM, Tony V E <tvaneerd@gmail.com> =
wrote:
>=20
>=20
>=20
> On Thu, Oct 1, 2015 at 3:33 PM, Ville Voutilainen <ville.voutilainen@gmai=
l.com <mailto:ville.voutilainen@gmail.com>> wrote:
>=20
> I don't think we should rename any_cast.
To be sure, nobody is suggesting to literally rename any_cast. P0042 mentio=
ns preserving it perpetually in namespace fundamentals_v1 for backward comp=
atibility.
> We might entertain the idea of adding
> generic programming facilities that can do such value extraction for diff=
erent
> types.
>=20
>=20
> Vincente has a proposal (P0032) for unifying some operations over variant=
, optional, any, etc.
> That's why I'm wondering if get() and cast are different or not, and whet=
her there should be one name (and which) or two.
> Also David's std::recover (P0042).
Vicente=E2=80=99s P0032 references P0042 and it=E2=80=99s more-or-less an e=
xtension of P0042. (The numbers aren=E2=80=99t strictly chronological as pa=
pers aren=E2=80=99t written in sequence.)
Any such proposal would be taken to supersede any_cast and the notion of ca=
sting in general. If you really like unsafety, there=E2=80=99s using std::e=
xperimental::fundamentals_v1::any_cast;.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_D501615F-F4FF-49C1-9827-594834ACB327
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9310=
=E2=80=9302, at 5:07 AM, Tony V E <<a href=3D"mailto:tvaneerd@gmail.com"=
class=3D"">tvaneerd@gmail.com</a>> wrote:</div><br class=3D"Apple-inter=
change-newline"><div class=3D""><div dir=3D"ltr" style=3D"font-family: Helv=
etica; font-size: 12px; font-style: normal; font-variant: normal; font-weig=
ht: normal; letter-spacing: normal; line-height: normal; orphans: auto; tex=
t-align: start; text-indent: 0px; text-transform: none; white-space: normal=
; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=
=3D""><div class=3D"gmail_extra"><br class=3D"Apple-interchange-newline"><b=
r class=3D""><div class=3D"gmail_quote">On Thu, Oct 1, 2015 at 3:33 PM, Vil=
le Voutilainen<span class=3D"Apple-converted-space"> </span><span dir=
=3D"ltr" class=3D""><<a href=3D"mailto:ville.voutilainen@gmail.com" targ=
et=3D"_blank" class=3D"">ville.voutilainen@gmail.com</a>></span><span cl=
ass=3D"Apple-converted-space"> </span>wrote:<br class=3D""><blockquote=
class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-left-widt=
h: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; pa=
dding-left: 1ex;"><br class=3D"">I don't think we should rename any_cast. <=
/blockquote></div></div></div></div></blockquote><div><br class=3D""></div>=
<div>To be sure, nobody is suggesting to literally rename <font face=3D"Cou=
rier" class=3D"">any_cast</font>. P0042 mentions preserving it perpetually =
in namespace <span style=3D"font-family: Courier;" class=3D"">fundamen=
tals_v1</span> for backward compatibility.</div><br class=3D""><blockq=
uote type=3D"cite" class=3D""><div class=3D""><div dir=3D"ltr" style=3D"fon=
t-family: Helvetica; font-size: 12px; font-style: normal; font-variant: nor=
mal; font-weight: normal; letter-spacing: normal; line-height: normal; orph=
ans: auto; text-align: start; text-indent: 0px; text-transform: none; white=
-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width:=
0px;" class=3D""><div class=3D"gmail_extra"><div class=3D"gmail_quote"><bl=
ockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-l=
eft-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: s=
olid; padding-left: 1ex;">We might entertain the idea of adding<br class=3D=
"">generic programming facilities that can do such value extraction for dif=
ferent<br class=3D"">types.<br class=3D""><div class=3D"HOEnZb"><div class=
=3D"h5"><br class=3D""></div></div></blockquote><div class=3D""><br class=
=3D""></div><div class=3D"">Vincente has a proposal (P0032) for unifying so=
me operations over variant, optional, any, etc.<br class=3D""></div><div cl=
ass=3D"">That's why I'm wondering if get() and cast are different or not, a=
nd whether there should be one name (and which) or two.<br class=3D""></div=
><div class=3D"">Also David's std::recover (P0042).<br class=3D""></div></d=
iv></div></div></div></blockquote></div><br class=3D""><div class=3D"">Vice=
nte=E2=80=99s P0032 references P0042 and it=E2=80=99s more-or-less an exten=
sion of P0042. (The numbers aren=E2=80=99t strictly chronological as papers=
aren=E2=80=99t written in sequence.)</div><div class=3D""><br class=3D""><=
/div><div class=3D"">Any such proposal would be taken to supersede <font fa=
ce=3D"Courier" class=3D"">any_cast</font> and the notion of casting in=
general. If you really like unsafety, there=E2=80=99s <font face=3D"C=
ourier" class=3D"">using std::experimental::fundamentals_v1::any_cast;</fon=
t>.</div><div class=3D""><br class=3D""></div></body></html>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--Apple-Mail=_D501615F-F4FF-49C1-9827-594834ACB327--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Fri, 2 Oct 2015 05:07:13 +0300
Raw View
On 2 October 2015 at 02:39, David Krauss <potswa@gmail.com> wrote:
> On Thu, Oct 1, 2015 at 3:33 PM, Ville Voutilainen
> <ville.voutilainen@gmail.com> wrote:
>> I don't think we should rename any_cast.
> To be sure, nobody is suggesting to literally rename any_cast. P0042
You should be more careful when making such bold statements in the presence
of Tony. :)
> mentions preserving it perpetually in namespace fundamentals_v1 for backward
> compatibility.
Not that it's any of the business of the proposed std::recover whether any_cast
exists and where, but I don't see that paper "mentioning preserving any_cast
perpetually" anywhere.
--
---
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/.
.
Author: David Krauss <potswa@gmail.com>
Date: Fri, 2 Oct 2015 10:32:49 +0800
Raw View
--Apple-Mail=_3426B217-EEC9-4997-8446-61DDBDBF7C20
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9310=E2=80=9302, at 10:07 AM, Ville Voutilainen <ville.vout=
ilainen@gmail.com> wrote:
>=20
> On 2 October 2015 at 02:39, David Krauss <potswa@gmail.com> wrote:
>> On Thu, Oct 1, 2015 at 3:33 PM, Ville Voutilainen
>> <ville.voutilainen@gmail.com> wrote:
>>> I don't think we should rename any_cast.
>> To be sure, nobody is suggesting to literally rename any_cast. P0042
>=20
> You should be more careful when making such bold statements in the presen=
ce
> of Tony. :)
I think it=E2=80=99s understood that he has the prerogative to do so. Indee=
d in making such a statement I=E2=80=99m clarifying that the initiative rem=
ains to be taken. Maybe you mean that=E2=80=99s why I should be careful? :)
>> mentions preserving it perpetually in namespace fundamentals_v1 for back=
ward
>> compatibility.
>=20
> Not that it's any of the business of the proposed std::recover whether an=
y_cast
> exists and where, but I don't see that paper "mentioning preserving any_c=
ast
> perpetually" anywhere.
See =C2=A76 =C2=B62. Actually I made a stronger suggestion of keeping it in=
namespace experimental. Perhaps that=E2=80=99s overreaching. Legacy suppor=
t would seem to be the business of any proposal to replace a standardized f=
acility.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_3426B217-EEC9-4997-8446-61DDBDBF7C20
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9310=
=E2=80=9302, at 10:07 AM, Ville Voutilainen <<a href=3D"mailto:ville.vou=
tilainen@gmail.com" class=3D"">ville.voutilainen@gmail.com</a>> wrote:</=
div><br class=3D"Apple-interchange-newline"><div class=3D"">On 2 October 20=
15 at 02:39, David Krauss <<a href=3D"mailto:potswa@gmail.com" class=3D"=
">potswa@gmail.com</a>> wrote:<br class=3D""><blockquote type=3D"cite" c=
lass=3D"">On Thu, Oct 1, 2015 at 3:33 PM, Ville Voutilainen<br class=3D"">&=
lt;<a href=3D"mailto:ville.voutilainen@gmail.com" class=3D"">ville.voutilai=
nen@gmail.com</a>> wrote:<br class=3D""><blockquote type=3D"cite" class=
=3D"">I don't think we should rename any_cast.<br class=3D""></blockquote>T=
o be sure, nobody is suggesting to literally rename any_cast. P0042<br clas=
s=3D""></blockquote><br class=3D"">You should be more careful when making s=
uch bold statements in the presence<br class=3D"">of Tony. :)<br class=3D""=
></div></blockquote><div><br class=3D""></div><div>I think it=E2=80=99s und=
erstood that he has the prerogative to do so. Indeed in making such a state=
ment I=E2=80=99m clarifying that the initiative remains to be taken. Maybe =
you mean that=E2=80=99s why I should be careful? :)</div><br class=3D""><bl=
ockquote type=3D"cite" class=3D""><div class=3D""><blockquote type=3D"cite"=
class=3D"">mentions preserving it perpetually in namespace fundamentals_v1=
for backward<br class=3D"">compatibility.<br class=3D""></blockquote><br c=
lass=3D"">Not that it's any of the business of the proposed std::recover wh=
ether any_cast<br class=3D"">exists and where, but I don't see that paper "=
mentioning preserving any_cast<br class=3D"">perpetually" anywhere.<br clas=
s=3D""></div></blockquote></div><br class=3D""><div class=3D"">See =C2=A76 =
=C2=B62. Actually I made a stronger suggestion of keeping it in <font face=
=3D"Courier" class=3D"">namespace experimental</font>. Perhaps that=E2=80=
=99s overreaching. Legacy support would seem to be the business of any prop=
osal to replace a standardized facility.</div><div class=3D""><br class=3D"=
"></div></body></html>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--Apple-Mail=_3426B217-EEC9-4997-8446-61DDBDBF7C20--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Fri, 2 Oct 2015 05:56:44 +0300
Raw View
On 2 October 2015 at 05:32, David Krauss <potswa@gmail.com> wrote:
> Not that it's any of the business of the proposed std::recover whether
> any_cast
> exists and where, but I don't see that paper "mentioning preserving any_c=
ast
> perpetually" anywhere.
>
>
> See =C2=A76 =C2=B62. Actually I made a stronger suggestion of keeping it =
in namespace
> experimental. Perhaps that=E2=80=99s overreaching. Legacy support would s=
eem to be
> the business of any proposal to replace a standardized facility.
Ah, I didn't realize this proposal intends to replace facilities
rather than generalize
them. Choosing that goal doesn't necessarily increase the chances of surviv=
al
of this proposal, but we'll see.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: David Krauss <potswa@gmail.com>
Date: Fri, 2 Oct 2015 11:07:14 +0800
Raw View
--Apple-Mail=_653E9E46-0138-4D56-BBF5-5B3983DA788A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9310=E2=80=9302, at 10:56 AM, Ville Voutilainen <ville.vout=
ilainen@gmail.com> wrote:
>=20
> On 2 October 2015 at 05:32, David Krauss <potswa@gmail.com> wrote:
>>=20
>> See =C2=A76 =C2=B62. Actually I made a stronger suggestion of keeping it=
in namespace
>> experimental. Perhaps that=E2=80=99s overreaching. Legacy support would =
seem to be
>> the business of any proposal to replace a standardized facility.
>=20
> Ah, I didn't realize this proposal intends to replace facilities
> rather than generalize
> them. Choosing that goal doesn't necessarily increase the chances of surv=
ival
> of this proposal, but we'll see.
It=E2=80=99s ambiguous, hence meriting only a vague mention at the end. Rea=
lly I just want my proposal to survive either way, and I want any_cast to d=
ie because of its own faults regardless of my proposal.
I wouldn=E2=80=99t want to neglect the possibility of killing any_cast.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_653E9E46-0138-4D56-BBF5-5B3983DA788A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9310=
=E2=80=9302, at 10:56 AM, Ville Voutilainen <<a href=3D"mailto:ville.vou=
tilainen@gmail.com" class=3D"">ville.voutilainen@gmail.com</a>> wrote:</=
div><br class=3D"Apple-interchange-newline"><div class=3D"">On 2 October 20=
15 at 05:32, David Krauss <<a href=3D"mailto:potswa@gmail.com" class=3D"=
">potswa@gmail.com</a>> wrote:<br class=3D""><blockquote type=3D"cite" c=
lass=3D""><br class=3D"">See =C2=A76 =C2=B62. Actually I made a stronger su=
ggestion of keeping it in namespace<br class=3D"">experimental. Perhaps tha=
t=E2=80=99s overreaching. Legacy support would seem to be<br class=3D"">the=
business of any proposal to replace a standardized facility.<br class=3D""=
></blockquote><br class=3D"">Ah, I didn't realize this proposal intends to =
replace facilities<br class=3D"">rather than generalize<br class=3D"">them.=
Choosing that goal doesn't necessarily increase the chances of survival<br=
class=3D"">of this proposal, but we'll see.<br class=3D""></div></blockquo=
te></div><br class=3D""><div class=3D"">It=E2=80=99s ambiguous, hence merit=
ing only a vague mention at the end. Really I just want my proposal to surv=
ive either way, and I want <span style=3D"font-family: Courier;" class=
=3D"">any_cast</span> to die because of its own faults regardless of m=
y proposal.</div><div class=3D""><br class=3D""></div><div class=3D"">I wou=
ldn=E2=80=99t want to neglect the <i class=3D"">possibility</i> of killing =
<font face=3D"Courier" class=3D"">any_cast</font>.</div></body></html>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--Apple-Mail=_653E9E46-0138-4D56-BBF5-5B3983DA788A--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Fri, 2 Oct 2015 07:37:58 +0200
Raw View
Le 01/10/15 23:07, Tony V E a =C3=A9crit :
> On Thu, Oct 1, 2015 at 3:33 PM, Ville Voutilainen <
> ville.voutilainen@gmail.com> wrote:
>
>> On 1 October 2015 at 22:25, Tony V E <tvaneerd@gmail.com> wrote:
>>>>> Sure it "transforms" the any, but it really just _gets_ something out
>> of
>>>>> the
>>>>> any.
>>>> That seems to be talking from an implementation point of view rather
>>>> than a semantic point of view.
>>> Do you consider variant and optional get() casts then?
>> From the lvalue/rvalue point of view, not really, but they are conversi=
ons.
>>
>> Do you consider dynamic_pointer_cast not to be a cast, since it's somewh=
at
>> related to any_cast? It also just "gets something out" of a shared_ptr.
>>
>> I don't think we should rename any_cast. We might entertain the idea of
>> adding
>> generic programming facilities that can do such value extraction for
>> different
>> types.
>>
>>
> Vincente has a proposal (P0032) for unifying some operations over variant=
,
> optional, any, etc.
> That's why I'm wondering if get() and cast are different or not, and
> whether there should be one name (and which) or two.
> Also David's std::recover (P0042).
>
>
Originally I was for proposing to replace any_cast by sum_cast, but my=20
sum_cast was not a cast, but an accessor. Having=20
select<T>/try_recover<T> behave in some way like optional<T&> give me=20
the idea that the common access interface I'm locking for is exactly the=20
one provided by optional, but instead of having them as member functions=20
we have non-member function. This is the "raison d'=C3=AAtre" of holds<T>,=
=20
reference_of<T>, address_of<T>, value_of<T>.
After P0042 reading I believe David is right and even if we have an=20
homogeneous interface to access the stored value, we could also left=20
any_cast. The experience in the experimental namespace would say us if=20
any_cast if useful enough once we have the alternative access interface.=20
Sorry if the text in P0032 lets think the contrary.
Vicente
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Fri, 2 Oct 2015 08:00:36 +0200
Raw View
Le 02/10/15 01:39, David Krauss a =C3=A9crit :
>> On 2015=E2=80=9310=E2=80=9302, at 5:07 AM, Tony V E <tvaneerd@gmail.com>=
wrote:
>>
>>
>>
>> On Thu, Oct 1, 2015 at 3:33 PM, Ville Voutilainen <ville.voutilainen@gma=
il.com <mailto:ville.voutilainen@gmail.com>> wrote:
>>
>> I don't think we should rename any_cast.
> To be sure, nobody is suggesting to literally rename any_cast. P0042 ment=
ions preserving it perpetually in namespace fundamentals_v1 for backward co=
mpatibility.
>> We might entertain the idea of adding
>> generic programming facilities that can do such value extraction for dif=
ferent
>> types.
>>
>>
>> Vincente has a proposal (P0032) for unifying some operations over varian=
t, optional, any, etc.
>> That's why I'm wondering if get() and cast are different or not, and whe=
ther there should be one name (and which) or two.
>> Also David's std::recover (P0042).
> Vicente=E2=80=99s P0032 references P0042 and it=E2=80=99s more-or-less an=
extension of P0042. (The numbers aren=E2=80=99t strictly chronological as =
papers aren=E2=80=99t written in sequence.)
The concept I'm proposing PossiblyValued<T> (it is not yet explicit in=20
the paper) is related to holds/reference_of/address_of/value_of operations.
If the stored type can be a reference PossiblyValued<T&> is not a=20
coherent, neither the value_of<T&> function. I'm looking for a better=20
name, maybe instead of value underlying is more appropriated and just=20
Possibly<T&>
Any ErasureClass model can be seen as a Possibly<T> for a specific type T.
Another difference between P0042 and P0032 is that I want these=20
functions to be customization points. As for other customization points=20
I'm waiting for a solid direction from the committee on how we should=20
add more customization points (e.g. Eric proposal).
> Any such proposal would be taken to supersede any_cast and the notion of =
casting in general. If you really like unsafety, there=E2=80=99s using std:=
:experimental::fundamentals_v1::any_cast;.
>
I believe that having holds<T> and storage_address_of<T> it is natural=20
to provide unsafe access via reference_of<T> and address_of<T> functions=20
that are as unsafe as the operator*() and operator->(). The safe access=20
interface is recover<T>/value_of<T> which corresponds to=20
optional<T>::value().
Vicente
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Fri, 2 Oct 2015 08:21:07 +0200
Raw View
Le 29/09/15 17:02, Tony V E a =C3=A9crit :
> On Thu, Sep 24, 2015 at 2:03 PM, <nicesw123@gmail.com> wrote:
>
>> Hello,
>>
>> std::experimental::any (boost::any) is nice.
>> What I don't like about the current implementation and proposal
>> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3804.html>, is
>> the fact that I cannot any_cast to a type with added low-level const.
>>
>>
>> Example:
>> using std::experimental::any;
>> using std::experimental::any_cast;
>> char str[] =3D "a2";
>> any ay(str);
>> any_cast<const char*>(ay); // throws, since a const is added!!!
>>
>>
>> Why should that not be legal??
>> All it means is a read-only access to the contained type, and that
>> definitely should be legal.
>>
>> Compare:
>> char str2[] =3D "str2";
>> static_cast<const char *>(str2); // read-only access (const added)
>>
>>
>> I've written on the Boost Users mailing list:
>> http://lists.boost.org/boost-users/2015/09/85097.php
>>
>> I must say I'm pleased that any is in experimental and is proposed (whic=
h
>> is why I'm writing here): It's a great type for having a container of "a=
ny"
>> type, since it limits the dynamic memory that the container needs per
>> element (the mem-storage for large contained values residing on the heap=
).
>> This in big contranst to variant, which can lead to really fat memory-us=
age
>> in a container, if it is used to also be able to hold a fat type; even i=
f
>> most elements in a container of that variant, might be small. (My optimu=
m
>> would be a variant that contains needed small types as well as any)
>>
>> I hope any_cast'ing to a type with added low-level can be
>> * realized (is it possible to do safely?)
>> * be regarded as nice additional requirement for the recommendation.
>>
>> Thanks for comments,
>> Regards,
>> n.
>>
>>
> I think part of the problem, in general, is that any_cast is NOT a _cast_=
..
> It is a "get" (similar to variant<> and optional<>) and should be called
> get.
> ie casts are expected to be able to do some transformations, but any_cast
> doesn't.
It does as Ville as already noted. IMHO a cast should have as template=20
parameter the type we want as result. Each cast has its own constrains
any_cast<int>(a) and any_cast<int&>(a) should work if any stores an int=20
and the result will be respectively int and int&.
The accessors we are talking of in P0032 and P0042 have as template=20
parameter the stored type.
recover<int>/value_of<int>(a) returns a reference to the int stored on=20
a. The type of returned reference depends on the nature of a, whether it=20
is cv qualified and it is & or &&.
I prefer to have a specific function that returns the address of the=20
stored value to having an overload for any_cast/get on pointer as the=20
goal of this function is different.
any a =3D...;
auto * ptr =3D any_cast<int*>(&a);
auto * ptr =3D address_of<int>(a);
variant<int, string> v=3D ...;
auto * ptr =3D get<int*>(&v);
auto * ptr =3D address_of<int>(v);
Vicente
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: David Krauss <potswa@gmail.com>
Date: Fri, 2 Oct 2015 14:54:49 +0800
Raw View
--Apple-Mail=_F1AC4750-2508-4210-9C0E-E18FB73D2E3D
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9310=E2=80=9302, at 2:00 PM, Vicente J. Botet Escriba <vice=
nte.botet@wanadoo.fr> wrote:
>=20
>> Any such proposal would be taken to supersede any_cast and the notion of=
casting in general. If you really like unsafety, there=E2=80=99s using std=
::experimental::fundamentals_v1::any_cast;.
>>=20
> I believe that having holds<T> and storage_address_of<T> it is natural to=
provide unsafe access via reference_of<T> and address_of<T> functions that=
are as unsafe as the operator*() and operator->(). The safe access interfa=
ce is recover<T>/value_of<T> which corresponds to optional<T>::value().
I don=E2=80=99t mean type-unsafety (for which Boost already has unsafe_any_=
cast). I meant the way that any_cast throws away the input value category, =
so you can get an lvalue reference to an rvalue, or you can inadvertently m=
ove an lvalue, but you cannot do forwarding.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_F1AC4750-2508-4210-9C0E-E18FB73D2E3D
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9310=
=E2=80=9302, at 2:00 PM, Vicente J. Botet Escriba <<a href=3D"mailto:vic=
ente.botet@wanadoo.fr" class=3D"">vicente.botet@wanadoo.fr</a>> wrote:</=
div></blockquote><blockquote type=3D"cite" class=3D""><br class=3D""></bloc=
kquote><blockquote type=3D"cite" class=3D""><div class=3D""><blockquote typ=
e=3D"cite" class=3D"">Any such proposal would be taken to supersede any_cas=
t and the notion of casting in general. If you really like unsafety, there=
=E2=80=99s using std::experimental::fundamentals_v1::any_cast;.<br class=3D=
""><br class=3D""></blockquote>I believe that having holds<T> and sto=
rage_address_of<T> it is natural to provide unsafe access via referen=
ce_of<T> and address_of<T> functions that are as unsafe as the =
operator*() and operator->(). The safe access interface is recover<T&=
gt;/value_of<T> which corresponds to optional<T>::value().<br c=
lass=3D""></div></blockquote></div><br class=3D""><div class=3D"">I don=E2=
=80=99t mean type-unsafety (for which Boost already has <font face=3D"Couri=
er" class=3D"">unsafe_any_cast</font>). I meant the way that <font face=3D"=
Courier" class=3D"">any_cast</font> throws away the input value category, s=
o you can get an lvalue reference to an rvalue, or you can inadvertently mo=
ve an lvalue, but you cannot do forwarding.</div><div class=3D""><br class=
=3D""></div></body></html>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--Apple-Mail=_F1AC4750-2508-4210-9C0E-E18FB73D2E3D--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Fri, 2 Oct 2015 09:57:36 +0300
Raw View
On 2 October 2015 at 09:54, David Krauss <potswa@gmail.com> wrote:
>
> On 2015=E2=80=9310=E2=80=9302, at 2:00 PM, Vicente J. Botet Escriba
> <vicente.botet@wanadoo.fr> wrote:
>
>
> Any such proposal would be taken to supersede any_cast and the notion of
> casting in general. If you really like unsafety, there=E2=80=99s using
> std::experimental::fundamentals_v1::any_cast;.
>
> I believe that having holds<T> and storage_address_of<T> it is natural to
> provide unsafe access via reference_of<T> and address_of<T> functions tha=
t
> are as unsafe as the operator*() and operator->(). The safe access interf=
ace
> is recover<T>/value_of<T> which corresponds to optional<T>::value().
>
>
> I don=E2=80=99t mean type-unsafety (for which Boost already has unsafe_an=
y_cast). I
> meant the way that any_cast throws away the input value category, so you =
can
> get an lvalue reference to an rvalue, or you can inadvertently move an
> lvalue, but you cannot do forwarding.
Some of the things you mentioned are open library issues, so fixing them
by introducing a completely new facility is a heavy-weight solution.
I'm not saying that
the proposed new facility doesn't have other merits, but issues in any
aren't it.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: David Krauss <potswa@gmail.com>
Date: Fri, 2 Oct 2015 15:31:23 +0800
Raw View
--Apple-Mail=_ACBFFE01-E655-4EBE-87DC-98945B5FD9B5
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9310=E2=80=9302, at 2:57 PM, Ville Voutilainen <ville.vouti=
lainen@gmail.com> wrote:
>=20
> On 2 October 2015 at 09:54, David Krauss <potswa@gmail.com> wrote:
>>=20
>> I don=E2=80=99t mean type-unsafety (for which Boost already has unsafe_a=
ny_cast). I
>> meant the way that any_cast throws away the input value category, so you=
can
>> get an lvalue reference to an rvalue, or you can inadvertently move an
>> lvalue, but you cannot do forwarding.
>=20
> Some of the things you mentioned are open library issues, so fixing them
> by introducing a completely new facility is a heavy-weight solution.
> I'm not saying that
> the proposed new facility doesn't have other merits, but issues in any
> aren't it.
We=E2=80=99re getting into philosophical territory, but how much can you ch=
ange an interface before you have something new? How much of any_cast is in=
disputably in error? After all, you can bind a const& lvalue reference to a=
temporary. The only case that is certainly wrong is passing an rvalue and =
getting a non-const lvalue. (And, now that I check this, Boost actually rai=
ses a static_assert in this one case, which is not conforming to the TS.)
Now I finally see LWG 2509 <http://wg21.cmeerw.net/lwg/issue2509>=E2=80=A6 =
your interpretation of the problems is different from mine, and you suggest=
non-breaking changes, especially to let any_cast<T&&> represent forwarding=
.. This would be a novel idea, but:
1. You omitted the return type so it=E2=80=99s still ambiguous whether the =
intent is really forwarding or moving.
2. Boost already implements the behavior as an explicit move, regardless of=
its own spec, so the foundation of the DR is a little shaky. Considering t=
he TR as an attempt to standardize Boost, the defects are as I described an=
d the proposed resolution is an extension.
Fixing experimental::any shouldn=E2=80=99t be underestimated. I say, fix Fu=
ndamentals v.1 to match Boost.Any to support the substantial codebase, and =
introduce changes under a new name without any ambiguity. DR 2509 is incomp=
lete and not yet accepted, so it seemingly would not be inappropriate to ad=
dress it directly with P0042.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_ACBFFE01-E655-4EBE-87DC-98945B5FD9B5
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9310=
=E2=80=9302, at 2:57 PM, Ville Voutilainen <<a href=3D"mailto:ville.vout=
ilainen@gmail.com" class=3D"">ville.voutilainen@gmail.com</a>> wrote:</d=
iv><br class=3D"Apple-interchange-newline"><div class=3D"">On 2 October 201=
5 at 09:54, David Krauss <<a href=3D"mailto:potswa@gmail.com" class=3D""=
>potswa@gmail.com</a>> wrote:<br class=3D""><blockquote type=3D"cite" cl=
ass=3D""><br class=3D"">I don=E2=80=99t mean type-unsafety (for which Boost=
already has unsafe_any_cast). I<br class=3D"">meant the way that any_cast =
throws away the input value category, so you can<br class=3D"">get an lvalu=
e reference to an rvalue, or you can inadvertently move an<br class=3D"">lv=
alue, but you cannot do forwarding.<br class=3D""></blockquote><br class=3D=
"">Some of the things you mentioned are open library issues, so fixing them=
<br class=3D"">by introducing a completely new facility is a heavy-weight s=
olution.<br class=3D"">I'm not saying that<br class=3D"">the proposed new f=
acility doesn't have other merits, but issues in any<br class=3D"">aren't i=
t.<br class=3D""></div></blockquote></div><br class=3D""><div class=3D"">We=
=E2=80=99re getting into philosophical territory, but how much can you chan=
ge an interface before you have something new? How much of <font face=3D"Co=
urier" class=3D"">any_cast</font> is indisputably in error? After all, you =
can bind a <font face=3D"Courier" class=3D"">const&</font> lvalue refer=
ence to a temporary. The only case that is certainly wrong is passing an rv=
alue and getting a non-const lvalue. (And, now that I check this, Boost act=
ually raises a <font face=3D"Courier" class=3D"">static_assert</font> in th=
is one case, which is not conforming to the TS.)</div><div class=3D""><br c=
lass=3D""></div><div class=3D"">Now I finally see <a href=3D"http://wg=
21.cmeerw.net/lwg/issue2509" class=3D"">LWG 2509</a>=E2=80=A6 your interpre=
tation of the problems is different from mine, and you suggest non-breaking=
changes, especially to let <font face=3D"Courier" class=3D"">any_cast<T=
&&></font> represent forwarding. This would be a novel idea, but=
:</div><div class=3D""><br class=3D""></div><div class=3D"">1. You omitted =
the return type so it=E2=80=99s still ambiguous whether the intent is reall=
y forwarding or moving.</div><div class=3D"">2. Boost already implements th=
e behavior as an explicit move, regardless of its own spec, so the foundati=
on of the DR is a little shaky. Considering the TR as an attempt to standar=
dize Boost, the defects are as I described and the proposed resolution is a=
n extension.</div><div class=3D""><br class=3D""></div><div class=3D"">Fixi=
ng <font face=3D"Courier" class=3D"">experimental::any</font> shouldn=E2=80=
=99t be underestimated. I say, fix Fundamentals v.1 to match Boost.Any to s=
upport the substantial codebase, and introduce changes under a new name wit=
hout any ambiguity. DR 2509 is incomplete and not yet accepted, so it seemi=
ngly would not be inappropriate to address it directly with P0042.</div><di=
v class=3D""><br class=3D""></div></body></html>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--Apple-Mail=_ACBFFE01-E655-4EBE-87DC-98945B5FD9B5--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Fri, 2 Oct 2015 10:48:04 +0300
Raw View
On 2 October 2015 at 10:31, David Krauss <potswa@gmail.com> wrote:
> Now I finally see LWG 2509=E2=80=A6 your interpretation of the problems i=
s different
> from mine, and you suggest non-breaking changes, especially to let
> any_cast<T&&> represent forwarding. This would be a novel idea, but:
>
> 1. You omitted the return type so it=E2=80=99s still ambiguous whether th=
e intent is
> really forwarding or moving.
I reported an issue, rather than spoon-feeding LEWG how to fix it.
> 2. Boost already implements the behavior as an explicit move, regardless =
of
> its own spec, so the foundation of the DR is a little shaky. Considering =
the
> TR as an attempt to standardize Boost, the defects are as I described and
> the proposed resolution is an extension.
I can't really parse what this is trying to say. The "TR", or
std::experimental::any
is certainly trying to use as much of the field experience of
boost::any as possible,
but that doesn't mean it's attempting to standardize boost::any as is, so
"defects are as I described and the proposed resolution is an extension" is
an outrageous claim.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: David Krauss <potswa@gmail.com>
Date: Fri, 2 Oct 2015 16:07:36 +0800
Raw View
--Apple-Mail=_F8AF3505-50FD-40CF-8458-F643B0298C56
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9310=E2=80=9302, at 3:48 PM, Ville Voutilainen <ville.vouti=
lainen@gmail.com> wrote:
>=20
> On 2 October 2015 at 10:31, David Krauss <potswa@gmail.com> wrote:
>> Now I finally see LWG 2509=E2=80=A6 your interpretation of the problems =
is different
>> from mine, and you suggest non-breaking changes, especially to let
>> any_cast<T&&> represent forwarding. This would be a novel idea, but:
>>=20
>> 1. You omitted the return type so it=E2=80=99s still ambiguous whether t=
he intent is
>> really forwarding or moving.
>=20
> I reported an issue, rather than spoon-feeding LEWG how to fix it.
>=20
>> 2. Boost already implements the behavior as an explicit move, regardless=
of
>> its own spec, so the foundation of the DR is a little shaky. Considering=
the
>> TR as an attempt to standardize Boost, the defects are as I described an=
d
>> the proposed resolution is an extension.
>=20
> I can't really parse what this is trying to say. The "TR", or
> std::experimental::any
> is certainly trying to use as much of the field experience of
> boost::any as possible,
> but that doesn't mean it's attempting to standardize boost::any as is, so
> "defects are as I described and the proposed resolution is an extension" =
is
> an outrageous claim.
The DR doesn=E2=80=99t mention any field experience; it says that something=
is ill-formed, which =E2=80=9Cin the field=E2=80=9D is well formed.
If LWG chooses to follow Boost and define any_cast<T&&>(x) to perform the a=
ppropriate static_cast<ref_type>(*result), then the DR will be resolved and=
the three issues I mentioned will remain unaddressed. Unless any new field=
experience materializes, this seems the most likely outcome.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_F8AF3505-50FD-40CF-8458-F643B0298C56
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9310=
=E2=80=9302, at 3:48 PM, Ville Voutilainen <<a href=3D"mailto:ville.vout=
ilainen@gmail.com" class=3D"">ville.voutilainen@gmail.com</a>> wrote:</d=
iv><br class=3D"Apple-interchange-newline"><div class=3D"">On 2 October 201=
5 at 10:31, David Krauss <<a href=3D"mailto:potswa@gmail.com" class=3D""=
>potswa@gmail.com</a>> wrote:<br class=3D""><blockquote type=3D"cite" cl=
ass=3D"">Now I finally see LWG 2509=E2=80=A6 your interpretation of the pro=
blems is different<br class=3D"">from mine, and you suggest non-breaking ch=
anges, especially to let<br class=3D"">any_cast<T&&> represen=
t forwarding. This would be a novel idea, but:<br class=3D""><br class=3D""=
>1. You omitted the return type so it=E2=80=99s still ambiguous whether the=
intent is<br class=3D"">really forwarding or moving.<br class=3D""></block=
quote><br class=3D"">I reported an issue, rather than spoon-feeding LEWG ho=
w to fix it.<br class=3D""><br class=3D""><blockquote type=3D"cite" class=
=3D"">2. Boost already implements the behavior as an explicit move, regardl=
ess of<br class=3D"">its own spec, so the foundation of the DR is a little =
shaky. Considering the<br class=3D"">TR as an attempt to standardize Boost,=
the defects are as I described and<br class=3D"">the proposed resolution i=
s an extension.<br class=3D""></blockquote><br class=3D"">I can't really pa=
rse what this is trying to say. The "TR", or<br class=3D"">std::experimenta=
l::any<br class=3D"">is certainly trying to use as much of the field experi=
ence of<br class=3D"">boost::any as possible,<br class=3D"">but that doesn'=
t mean it's attempting to standardize boost::any as is, so<br class=3D"">"d=
efects are as I described and the proposed resolution is an extension" is<b=
r class=3D"">an outrageous claim.<br class=3D""></div></blockquote></div><b=
r class=3D""><div class=3D"">The DR doesn=E2=80=99t mention any field exper=
ience; it says that something is ill-formed, which =E2=80=9Cin the field=E2=
=80=9D is well formed.</div><div class=3D""><br class=3D""></div><div class=
=3D"">If LWG chooses to follow Boost and define <font face=3D"Courier"=
class=3D"">any_cast<T&&>(x)</font> to perform the appro=
priate <font face=3D"Courier" class=3D"">static_cast<ref_type>(*resul=
t)</font>, then the DR will be resolved and the three issues I mentioned wi=
ll remain unaddressed. Unless any new field experience materializes, this s=
eems the most likely outcome.</div><div class=3D""><br class=3D""></div></b=
ody></html>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--Apple-Mail=_F8AF3505-50FD-40CF-8458-F643B0298C56--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Fri, 2 Oct 2015 11:35:22 +0300
Raw View
On 2 October 2015 at 11:07, David Krauss <potswa@gmail.com> wrote:
> I can't really parse what this is trying to say. The "TR", or
> std::experimental::any
> is certainly trying to use as much of the field experience of
> boost::any as possible,
> but that doesn't mean it's attempting to standardize boost::any as is, so
> "defects are as I described and the proposed resolution is an extension" =
is
> an outrageous claim.
>
> The DR doesn=E2=80=99t mention any field experience; it says that somethi=
ng is
> ill-formed, which =E2=80=9Cin the field=E2=80=9D is well formed.
I again fail to parse what this is supposed to mean. The DR comes
"from the field".
I have better things to do than guess how to interpret whichever
figments of your
imagination you choose to spout next.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: David Krauss <potswa@gmail.com>
Date: Fri, 2 Oct 2015 17:40:28 +0800
Raw View
> On 2015=E2=80=9310=E2=80=9302, at 4:35 PM, Ville Voutilainen <ville.vouti=
lainen@gmail.com> wrote:
>=20
> On 2 October 2015 at 11:07, David Krauss <potswa@gmail.com> wrote:
>> I can't really parse what this is trying to say. The "TR", or
>> std::experimental::any
>> is certainly trying to use as much of the field experience of
>> boost::any as possible,
>> but that doesn't mean it's attempting to standardize boost::any as is, s=
o
>> "defects are as I described and the proposed resolution is an extension"=
is
>> an outrageous claim.
>>=20
>> The DR doesn=E2=80=99t mention any field experience; it says that someth=
ing is
>> ill-formed, which =E2=80=9Cin the field=E2=80=9D is well formed.
>=20
> I again fail to parse what this is supposed to mean. The DR comes
> "from the field".
> I have better things to do than guess how to interpret whichever
> figments of your
> imagination you choose to spout next.
By =E2=80=9Cin the field=E2=80=9D I meant usage of Boost, because you said =
"as much of the field experience of boost::any as possible." It seems that =
you specifically meant TR implementations which behave differently. You=E2=
=80=99re free to assume that LWG will choose to diverge from Boost on its o=
wn accord, but it=E2=80=99s not a =E2=80=9Cfigment of my imagination=E2=80=
=9D and I don=E2=80=99t need to make the same assumption.
/cc Jonathan Wakely because he=E2=80=99s handling LWG 2509. (Summary: Boost=
resolves both rvalue issues by returning a static_cast to the return type.=
)
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Fri, 2 Oct 2015 12:42:51 +0300
Raw View
On 2 October 2015 at 12:40, David Krauss <potswa@gmail.com> wrote:
> By =E2=80=9Cin the field=E2=80=9D I meant usage of Boost, because you sai=
d "as much of the field experience of boost::any as possible." It seems tha=
t you specifically meant TR implementations which behave differently. You=
=E2=80=99re free to assume that LWG will choose to diverge from Boost on it=
s own accord, but it=E2=80=99s not a =E2=80=9Cfigment of my imagination=E2=
=80=9D and I don=E2=80=99t need to make the same assumption.
I reported a library issue based on feedback from users of the
Fundamentals v1 implementation.
The rest of it is your own conjectures, i.e. figments of your imagination.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: David Krauss <potswa@gmail.com>
Date: Fri, 2 Oct 2015 18:35:00 +0800
Raw View
--Apple-Mail=_67707DC8-7AD7-49AC-B86C-2CB19BEE4599
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9310=E2=80=9302, at 5:42 PM, Ville Voutilainen <ville.vouti=
lainen@gmail.com> wrote:
>=20
> On 2 October 2015 at 12:40, David Krauss <potswa@gmail.com> wrote:
>> By =E2=80=9Cin the field=E2=80=9D I meant usage of Boost, because you sa=
id "as much of the field experience of boost::any as possible." It seems th=
at you specifically meant TR implementations which behave differently. You=
=E2=80=99re free to assume that LWG will choose to diverge from Boost on it=
s own accord, but it=E2=80=99s not a =E2=80=9Cfigment of my imagination=E2=
=80=9D and I don=E2=80=99t need to make the same assumption.
>=20
> I reported a library issue based on feedback from users of the
> Fundamentals v1 implementation.
> The rest of it is your own conjectures, i.e. figments of your imagination=
..
Conjecture is different from imagined invention.
This is conjecture, "an opinion or conclusion formed on the basis of incomp=
lete information":
> On 2015=E2=80=9310=E2=80=9302, at 2:57 PM, Ville Voutilainen <ville.vouti=
lainen@gmail.com> wrote:
>=20
> Some of the things you mentioned are open library issues, so fixing them
> by introducing a completely new facility is a heavy-weight solution.
I tried to provide new information which points to the conclusion that LWG =
2509 will probably not add std::get-like forwarding functionality to any_ca=
st.
Anyway, if my information were incomplete, I hope you=E2=80=99d try to fix =
that.
This is imagination:
> I'm not saying that
> the proposed new facility doesn't have other merits, but issues in any
> aren't it.
Regardless of what LWG decides, proposals are accounted-for in issue proces=
sing and issues are considered in proposal evaluation. You shouldn=E2=80=99=
t say that a proposal for new functionality has fewer merits because a DR c=
ould possibly, among other alternatives, add the functionality under an exi=
sting name. Even if it were true, it=E2=80=99s a bit demoralizing. Given P0=
042, LWG is free to keep any_cast faithful to Boost without worrying about =
leaving a hole in functionality. Given LWG 2509, LEWG can see that the prob=
lem of forwarding is on the radar. They complement each other; they do not =
conflict.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_67707DC8-7AD7-49AC-B86C-2CB19BEE4599
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9310=
=E2=80=9302, at 5:42 PM, Ville Voutilainen <<a href=3D"mailto:ville.vout=
ilainen@gmail.com" class=3D"">ville.voutilainen@gmail.com</a>> wrote:</d=
iv><br class=3D"Apple-interchange-newline"><div class=3D"">On 2 October 201=
5 at 12:40, David Krauss <<a href=3D"mailto:potswa@gmail.com" class=3D""=
>potswa@gmail.com</a>> wrote:<br class=3D""><blockquote type=3D"cite" cl=
ass=3D"">By =E2=80=9Cin the field=E2=80=9D I meant usage of Boost, because =
you said "as much of the field experience of boost::any as possible." It se=
ems that you specifically meant TR implementations which behave differently=
.. You=E2=80=99re free to assume that LWG will choose to diverge from Boost =
on its own accord, but it=E2=80=99s not a =E2=80=9Cfigment of my imaginatio=
n=E2=80=9D and I don=E2=80=99t need to make the same assumption.<br class=
=3D""></blockquote><br class=3D"">I reported a library issue based on feedb=
ack from users of the<br class=3D"">Fundamentals v1 implementation.<br clas=
s=3D"">The rest of it is your own conjectures, i.e. figments of your imagin=
ation.<br class=3D""></div></blockquote></div><br class=3D""><div class=3D"=
">Conjecture is different from imagined invention.</div><div class=3D""><br=
class=3D""></div><div class=3D"">This is conjecture, "an opinion or c=
onclusion formed on the basis of incomplete information":</div><div class=
=3D""><br class=3D""></div><div class=3D""><blockquote type=3D"cite" class=
=3D""><div class=3D"">On 2015=E2=80=9310=E2=80=9302, at 2:57 PM, Ville Vout=
ilainen <<a href=3D"mailto:ville.voutilainen@gmail.com" class=3D"">ville=
..voutilainen@gmail.com</a>> wrote:</div><br class=3D"Apple-interchange-n=
ewline"><div class=3D""><span class=3D"" style=3D"float: none; display: inl=
ine !important;">Some of the things you mentioned are open library issues, =
so fixing them</span><br class=3D""><span class=3D"" style=3D"float: none; =
display: inline !important;">by introducing a completely new facility is a =
heavy-weight solution.</span><br class=3D""></div></blockquote><div class=
=3D""><br class=3D""></div><div class=3D"">I tried to provide new informati=
on which points to the conclusion that LWG 2509 will probably not add std::=
get-like forwarding functionality to any_cast.</div><div class=3D""><br cla=
ss=3D""></div><div class=3D"">Anyway, if my information were incomplete, I =
hope you=E2=80=99d try to fix that.</div><div class=3D""><br class=3D""></d=
iv><div class=3D""><br class=3D""></div><div class=3D"">This is imagination=
:</div><br class=3D""><blockquote type=3D"cite" class=3D""><div class=3D"">=
<span class=3D"" style=3D"float: none; display: inline !important;">I'm not=
saying that</span><br class=3D""><span class=3D"" style=3D"float: none; di=
splay: inline !important;">the proposed new facility doesn't have other mer=
its, but issues in any</span><br class=3D""><span class=3D"" style=3D"float=
: none; display: inline !important;">aren't it.</span><br class=3D""></div>=
</blockquote></div><div class=3D""><div class=3D""><span class=3D"" style=
=3D"float: none; display: inline !important;"><br class=3D""></span></div><=
/div><div class=3D""><span class=3D"" style=3D"float: none; display: inline=
!important;">Regardless of what LWG decides, proposals are accounted-for i=
n issue processing and issues are considered in proposal evaluation. You sh=
ouldn=E2=80=99t say that a proposal for new functionality has fewer merits =
because a DR could possibly, among other alternatives, add the functionalit=
y under an existing name. Even if it were true, it=E2=80=99s a bit demorali=
zing. Given P0042, LWG is free to keep <font face=3D"Courier" class=3D"">an=
y_cast</font> faithful to Boost without worrying about leaving a hole in fu=
nctionality. Given LWG 2509, LEWG can see that the problem of forwarding is=
on the radar. They complement each other; they do not conflict.</span></di=
v><div class=3D""><span class=3D"" style=3D"float: none; display: inline !i=
mportant;"><br class=3D""></span></div></body></html>
<p></p>
-- <br />
<br />
--- <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 />
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 />
--Apple-Mail=_67707DC8-7AD7-49AC-B86C-2CB19BEE4599--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Fri, 2 Oct 2015 14:07:43 +0300
Raw View
On 2 October 2015 at 13:35, David Krauss <potswa@gmail.com> wrote:
> I tried to provide new information which points to the conclusion that LW=
G
> 2509 will probably not add std::get-like forwarding functionality to
> any_cast.
"Will probably not"? What exactly is this probability based on? The issue
makes no suggestions either way. Did I mention figments of imagination
already?
> Anyway, if my information were incomplete, I hope you=E2=80=99d try to fi=
x that.
You use the word "information" liberally.
> I'm not saying that
> the proposed new facility doesn't have other merits, but issues in any
> aren't it.
>
> Regardless of what LWG decides, proposals are accounted-for in issue
> processing and issues are considered in proposal evaluation. You shouldn=
=E2=80=99t
> say that a proposal for new functionality has fewer merits because a DR
> could possibly, among other alternatives, add the functionality under an
> existing name. Even if it were true, it=E2=80=99s a bit demoralizing. Giv=
en P0042,
Demoralizing? Pointing out that parts of your rationale for your std::recov=
er
proposal may be solved by an existing issue is demoralizing? Good day.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Fri, 2 Oct 2015 10:17:00 -0400
Raw View
--001a11c377a22e917505211fd16e
Content-Type: text/plain; charset=UTF-8
On Thu, Oct 1, 2015 at 10:07 PM, Ville Voutilainen <
ville.voutilainen@gmail.com> wrote:
> On 2 October 2015 at 02:39, David Krauss <potswa@gmail.com> wrote:
> > On Thu, Oct 1, 2015 at 3:33 PM, Ville Voutilainen
> > <ville.voutilainen@gmail.com> wrote:
> >> I don't think we should rename any_cast.
> > To be sure, nobody is suggesting to literally rename any_cast. P0042
>
> You should be more careful when making such bold statements in the presence
> of Tony. :)
>
True.
I don't want to go back in time and change the name of things already
published, but moving forward we can change things between now and
standardization.
I'm not (yet) suggesting any name changes, just trying to make sure our
naming across library types is somewhat consistent.
>
> > mentions preserving it perpetually in namespace fundamentals_v1 for
> backward
> > compatibility.
>
> Not that it's any of the business of the proposed std::recover whether
> any_cast
> exists and where, but I don't see that paper "mentioning preserving
> any_cast
> perpetually" anywhere.
>
> --
>
> ---
> 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/.
--001a11c377a22e917505211fd16e
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Thu, Oct 1, 2015 at 10:07 PM, Ville Voutilainen <span dir=3D"ltr">&l=
t;<a href=3D"mailto:ville.voutilainen@gmail.com" target=3D"_blank">ville.vo=
utilainen@gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail_quo=
te" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"=
><span class=3D"">On 2 October 2015 at 02:39, David Krauss <<a href=3D"m=
ailto:potswa@gmail.com">potswa@gmail.com</a>> wrote:<br>
> On Thu, Oct 1, 2015 at 3:33 PM, Ville Voutilainen<br>
> <<a href=3D"mailto:ville.voutilainen@gmail.com">ville.voutilainen@g=
mail.com</a>> wrote:<br>
>> I don't think we should rename any_cast.<br>
> To be sure, nobody is suggesting to literally rename any_cast. P0042<b=
r>
<br>
</span>You should be more careful when making such bold statements in the p=
resence<br>
of Tony. :)<br></blockquote><div><br></div><div>True.<br></div><div>I don&#=
39;t want to go back in time and change the name of things already publishe=
d, but moving forward we can change things between now and standardization.=
<br></div><div>I'm not (yet) suggesting any name changes, just trying t=
o make sure our naming across library types is somewhat consistent.<br><br>=
</div><div>=C2=A0<br></div><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=3D""><br>
> mentions preserving it perpetually in namespace fundamentals_v1 for ba=
ckward<br>
> compatibility.<br>
<br>
</span>Not that it's any of the business of the proposed std::recover w=
hether any_cast<br>
exists and where, but I don't see that paper "mentioning preservin=
g any_cast<br>
perpetually" anywhere.<br>
<div class=3D"HOEnZb"><div class=3D"h5"><br>
--<br>
<br>
---<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%2Bunsubscribe@isocpp.org">std-propo=
sals+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/" rel=3D"noreferrer" target=3D"_blank">http://groups.google.c=
om/a/isocpp.org/group/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--001a11c377a22e917505211fd16e--
.