Topic: Unified coercion protocol: static_cast explicit overload
Author: Igor Baidiuk <target.san@gmail.com>
Date: Wed, 1 Jul 2015 04:17:51 -0700 (PDT)
Raw View
------=_Part_1852_1279424045.1435749471762
Content-Type: multipart/alternative;
boundary="----=_Part_1853_526166904.1435749471762"
------=_Part_1853_526166904.1435749471762
Content-Type: text/plain; charset=UTF-8
What if we could define
operator static_cast<To>(From const& from)
{
return { from.a, from.b};
}
// later in code
From from;
auto to = static_cast<To>(from);
as means of non-member, explicit conversion syntax?
So we don't need to write tons of functions like toFoo, toBar, toBaz etc.
Or, allow declaring non-member conversion operators, which are explicit by
default?
--
---
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_1853_526166904.1435749471762
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">What if we could define<br><div class=3D"prettyprint" 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 cla=
ss=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008=
;" class=3D"styled-by-prettify">operator</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> </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: #606;" class=3D"st=
yled-by-prettify">To</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">>(</span><span style=3D"color: #606;" class=3D"styled-by-prett=
ify">From</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">const</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">&</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">from</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br> </span><span style=3D"color: #008;" clas=
s=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-b=
y-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">from</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">a</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">from</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">b</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></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">// later in code</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #606;" class=3D"styled-by-prettify">From</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">from</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"st=
yled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> to </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">static_cas=
t</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</spa=
n><span style=3D"color: #606;" class=3D"styled-by-prettify">To</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">>(</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">from</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></span></div></code></div>as means of =
non-member, explicit conversion syntax?<br>So we don't need to write tons o=
f functions like toFoo, toBar, toBaz etc.<br>Or, allow declaring non-member=
conversion operators, which are explicit by default?<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_1853_526166904.1435749471762--
------=_Part_1852_1279424045.1435749471762--
.
Author: Patrice Roy <patricer@gmail.com>
Date: Wed, 1 Jul 2015 09:17:20 -0400
Raw View
--089e0158b5e492b2280519d02414
Content-Type: text/plain; charset=UTF-8
What is missing from explicit conversion operators in your mind? For
example, what effect do you want to acheive that is not acheived by
something like the following?
#include <string>
struct Three
{
explicit operator int() const { return 3; }
explicit operator std::string() const { return "three"; }
};
int main()
{
Three three;
auto i = static_cast<int>(three); // yields 3
auto s = static_cast<std::string>(three); // yields std::string("three")
// int j = three; // illegal
// string str = three; // illegal
}
Cheers!
2015-07-01 7:17 GMT-04:00 Igor Baidiuk <target.san@gmail.com>:
> What if we could define
> operator static_cast<To>(From const& from)
> {
> return { from.a, from.b};
> }
> // later in code
> From from;
> auto to = static_cast<To>(from);
> as means of non-member, explicit conversion syntax?
> So we don't need to write tons of functions like toFoo, toBar, toBaz etc.
> Or, allow declaring non-member conversion operators, which are explicit by
> default?
>
> --
>
> ---
> 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/.
--089e0158b5e492b2280519d02414
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>What is missing from explicit conversion operators in=
your mind? For example, what effect do you want to acheive that is not ach=
eived by something like the following?<br><br>#include <string><br>st=
ruct Three<br>{<br>=C2=A0=C2=A0=C2=A0 explicit operator int() const { retur=
n 3; }<br>=C2=A0=C2=A0=C2=A0 explicit operator std::string() const { return=
"three"; }<br>};<br><br>int main()<br>{<br>=C2=A0=C2=A0=C2=A0 Th=
ree three;<br>=C2=A0=C2=A0=C2=A0 auto i =3D static_cast<int>(three); =
// yields 3<br>=C2=A0=C2=A0=C2=A0 auto s =3D static_cast<std::string>=
(three); // yields std::string("three")<br>=C2=A0=C2=A0=C2=A0 // =
int j =3D three; // illegal<br>=C2=A0=C2=A0=C2=A0 // string str =3D three; =
// illegal<br>}<br><br></div>Cheers!<br></div><div class=3D"gmail_extra"><b=
r><div class=3D"gmail_quote">2015-07-01 7:17 GMT-04:00 Igor Baidiuk <span d=
ir=3D"ltr"><<a href=3D"mailto:target.san@gmail.com" target=3D"_blank">ta=
rget.san@gmail.com</a>></span>:<br><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div d=
ir=3D"ltr">What if we could define<br><div style=3D"background-color:rgb(25=
0,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:1p=
x;word-wrap:break-word"><code><div><span style=3D"color:#008">operator</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#008">static_cast=
</span><span style=3D"color:#660"><</span><span style=3D"color:#606">To<=
/span><span style=3D"color:#660">>(</span><span style=3D"color:#606">Fro=
m</span><span style=3D"color:#000"> </span><span style=3D"color:#008">const=
</span><span style=3D"color:#660">&</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">from</span><span style=3D"color:#660">)</s=
pan><span style=3D"color:#000"><br></span><span style=3D"color:#660">{</spa=
n><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:=
#008">return</span><span style=3D"color:#000"> </span><span style=3D"color:=
#660">{</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>from</span><span style=3D"color:#660">.</span><span style=3D"color:#000">a=
</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#008">from</span><span style=3D"color:#660">.</span>=
<span style=3D"color:#000">b</span><span style=3D"color:#660">};</span><spa=
n style=3D"color:#000"><br></span><span style=3D"color:#660">}</span><span =
style=3D"color:#000"><br></span><span style=3D"color:#800">// later in code=
</span><span style=3D"color:#000"><br></span><span style=3D"color:#606">Fro=
m</span><span style=3D"color:#000"> </span><span style=3D"color:#008">from<=
/span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br></s=
pan><span style=3D"color:#008">auto</span><span style=3D"color:#000"> to </=
span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#008">static_cast</span><span style=3D"color:#660">&=
lt;</span><span style=3D"color:#606">To</span><span style=3D"color:#660">&g=
t;(</span><span style=3D"color:#008">from</span><span style=3D"color:#660">=
);</span><span style=3D"color:#000"><br></span></div></code></div>as means =
of non-member, explicit conversion syntax?<br>So we don't need to write=
tons of functions like toFoo, toBar, toBaz etc.<br>Or, allow declaring non=
-member conversion operators, which are explicit by default?<span class=3D"=
HOEnZb"><font color=3D"#888888"><br></font></span></div><span class=3D"HOEn=
Zb"><font color=3D"#888888">
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--089e0158b5e492b2280519d02414--
.
Author: Igor Baidiuk <target.san@gmail.com>
Date: Wed, 1 Jul 2015 06:55:52 -0700 (PDT)
Raw View
------=_Part_89_176607337.1435758952320
Content-Type: multipart/alternative;
boundary="----=_Part_90_417112805.1435758952320"
------=_Part_90_417112805.1435758952320
Content-Type: text/plain; charset=UTF-8
On Wednesday, July 1, 2015 at 4:17:23 PM UTC+3, Patrice Roy wrote:
>
> What is missing from explicit conversion operators in your mind? For
> example, what effect do you want to acheive that is not acheived by
> something like the following?
>
> I cannot define conversions as free-standing functions.
Sometimes it's really useful when you want those conversions, but don't
want to pollute struct interface, because those conversions are used only
inside of some module.
> #include <string>
> struct Three
> {
> explicit operator int() const { return 3; }
> explicit operator std::string() const { return "three"; }
> };
>
> int main()
> {
> Three three;
> auto i = static_cast<int>(three); // yields 3
> auto s = static_cast<std::string>(three); // yields
> std::string("three")
> // int j = three; // illegal
> // string str = three; // illegal
> }
>
> Cheers!
>
> 2015-07-01 7:17 GMT-04:00 Igor Baidiuk <targe...@gmail.com <javascript:>>:
>
>> What if we could define
>> operator static_cast<To>(From const& from)
>> {
>> return { from.a, from.b};
>> }
>> // later in code
>> From from;
>> auto to = static_cast<To>(from);
>> as means of non-member, explicit conversion syntax?
>> So we don't need to write tons of functions like toFoo, toBar, toBaz etc.
>> Or, allow declaring non-member conversion operators, which are explicit
>> by default?
>>
>> --
>>
>> ---
>> 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-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> 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/.
------=_Part_90_417112805.1435758952320
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Wednesday, July 1, 2015 at 4:17:23 PM UTC+3, Pa=
trice Roy wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"lt=
r"><div>What is missing from explicit conversion operators in your mind? Fo=
r example, what effect do you want to acheive that is not acheived by somet=
hing like the following?<br><br></div></div></blockquote><div>I cannot defi=
ne conversions as free-standing functions.<br>Sometimes it's really useful =
when you want those conversions, but don't want to pollute struct interface=
, because those conversions are used only inside of some module.<br> <=
br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: =
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div=
>#include <string><br>struct Three<br>{<br> explici=
t operator int() const { return 3; }<br> explicit operato=
r std::string() const { return "three"; }<br>};<br><br>int main()<br>{<br>&=
nbsp; Three three;<br> auto i =3D static_cast=
<int>(three); // yields 3<br> auto s =3D static_cas=
t<std::string>(<wbr>three); // yields std::string("three")<br> &=
nbsp; // int j =3D three; // illegal<br> // string =
str =3D three; // illegal<br>}<br><br></div></div></blockquote><div></div><=
blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bord=
er-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div></div>Che=
ers!<br></div><div><br><div class=3D"gmail_quote">2015-07-01 7:17 GMT-04:00=
Igor Baidiuk <span dir=3D"ltr"><<a href=3D"javascript:" target=3D"_blan=
k" gdf-obfuscated-mailto=3D"Ls14sZzXXTwJ" rel=3D"nofollow" onmousedown=3D"t=
his.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:'=
;return true;">targe...@gmail.com</a>></span>:<br><blockquote class=3D"g=
mail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-l=
eft:1ex"><div dir=3D"ltr">What if we could define<br><div style=3D"backgrou=
nd-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=
">operator</span><span style=3D"color:#000"> </span><span style=3D"color:#0=
08">static_cast</span><span style=3D"color:#660"><</span><span style=3D"=
color:#606">To</span><span style=3D"color:#660">>(</span><span style=3D"=
color:#606">From</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#008">const</span><span style=3D"color:#660">&</span><span style=3D=
"color:#000"> </span><span style=3D"color:#008">from</span><span style=3D"c=
olor:#660">)</span><span style=3D"color:#000"><br></span><span style=3D"col=
or:#660">{</span><span style=3D"color:#000"><br> </span><span =
style=3D"color:#008">return</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">{</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">from</span><span style=3D"color:#660">.</span><span style=
=3D"color:#000">a</span><span style=3D"color:#660">,</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#008">from</span><span style=3D"col=
or:#660">.</span><span style=3D"color:#000">b</span><span style=3D"color:#6=
60">};</span><span style=3D"color:#000"><br></span><span style=3D"color:#66=
0">}</span><span style=3D"color:#000"><br></span><span style=3D"color:#800"=
>// later in code</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#606">From</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">from</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#008">auto</span><span styl=
e=3D"color:#000"> to </span><span style=3D"color:#660">=3D</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#008">static_cast</span><span=
style=3D"color:#660"><</span><span style=3D"color:#606">To</span><span =
style=3D"color:#660">>(</span><span style=3D"color:#008">from</span><spa=
n style=3D"color:#660">);</span><span style=3D"color:#000"><br></span></div=
></code></div>as means of non-member, explicit conversion syntax?<br>So we =
don't need to write tons of functions like toFoo, toBar, toBaz etc.<br>Or, =
allow declaring non-member conversion operators, which are explicit by defa=
ult?<span><font color=3D"#888888"><br></font></span></div><span><font color=
=3D"#888888">
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
Ls14sZzXXTwJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';ret=
urn true;" onclick=3D"this.href=3D'javascript:';return true;">std-proposal.=
...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"Ls14sZzXXTwJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:=
';return true;">std-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=
=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';return true=
;" onclick=3D"this.href=3D'http://groups.google.com/a/isocpp.org/group/std-=
proposals/';return true;">http://groups.google.com/a/<wbr>isocpp.org/group/=
std-<wbr>proposals/</a>.<br>
</font></span></blockquote></div><br></div>
</blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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_90_417112805.1435758952320--
------=_Part_89_176607337.1435758952320--
.
Author: =?UTF-8?Q?David_Rodr=C3=ADguez_Ibeas?= <dibeas@ieee.org>
Date: Wed, 1 Jul 2015 16:53:29 +0100
Raw View
--001a11c35152f7bed10519d2525b
Content-Type: text/plain; charset=UTF-8
You could create a free function in the module that does the same, right?
To convert(From f) { return To{ f.a, f.b }; }
....
auto to = convert(getSomeFrom());
On Wed, Jul 1, 2015 at 2:55 PM, Igor Baidiuk <target.san@gmail.com> wrote:
>
>
> On Wednesday, July 1, 2015 at 4:17:23 PM UTC+3, Patrice Roy wrote:
>>
>> What is missing from explicit conversion operators in your mind? For
>> example, what effect do you want to acheive that is not acheived by
>> something like the following?
>>
>> I cannot define conversions as free-standing functions.
> Sometimes it's really useful when you want those conversions, but don't
> want to pollute struct interface, because those conversions are used only
> inside of some module.
>
>
>> #include <string>
>> struct Three
>> {
>> explicit operator int() const { return 3; }
>> explicit operator std::string() const { return "three"; }
>> };
>>
>> int main()
>> {
>> Three three;
>> auto i = static_cast<int>(three); // yields 3
>> auto s = static_cast<std::string>(three); // yields
>> std::string("three")
>> // int j = three; // illegal
>> // string str = three; // illegal
>> }
>>
>> Cheers!
>>
>> 2015-07-01 7:17 GMT-04:00 Igor Baidiuk <targe...@gmail.com>:
>>
>>> What if we could define
>>> operator static_cast<To>(From const& from)
>>> {
>>> return { from.a, from.b};
>>> }
>>> // later in code
>>> From from;
>>> auto to = static_cast<To>(from);
>>> as means of non-member, explicit conversion syntax?
>>> So we don't need to write tons of functions like toFoo, toBar, toBaz etc.
>>> Or, allow declaring non-member conversion operators, which are explicit
>>> by default?
>>>
>>> --
>>>
>>> ---
>>> 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-proposal...@isocpp.org.
>>> To post to this group, send email to std-pr...@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/.
>
--
---
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/.
--001a11c35152f7bed10519d2525b
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">You could create a free function in the module that does t=
he same, right?<br><br>To convert(From f) { return To{ f.a, f.b }; }<br>...=
<br>auto to =3D convert(getSomeFrom());</div><div class=3D"gmail_extra"><br=
><div class=3D"gmail_quote">On Wed, Jul 1, 2015 at 2:55 PM, Igor Baidiuk <s=
pan dir=3D"ltr"><<a href=3D"mailto:target.san@gmail.com" target=3D"_blan=
k">target.san@gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail=
_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:=
1ex"><div dir=3D"ltr"><span class=3D""><br><br>On Wednesday, July 1, 2015 a=
t 4:17:23 PM UTC+3, Patrice Roy wrote:<blockquote class=3D"gmail_quote" sty=
le=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1e=
x"><div dir=3D"ltr"><div>What is missing from explicit conversion operators=
in your mind? For example, what effect do you want to acheive that is not =
acheived by something like the following?<br><br></div></div></blockquote><=
/span><div>I cannot define conversions as free-standing functions.<br>Somet=
imes it's really useful when you want those conversions, but don't =
want to pollute struct interface, because those conversions are used only i=
nside of some module.<br>=C2=A0<br></div><span class=3D""><blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr"><div>#include <string><br>str=
uct Three<br>{<br>=C2=A0=C2=A0=C2=A0 explicit operator int() const { return=
3; }<br>=C2=A0=C2=A0=C2=A0 explicit operator std::string() const { return =
"three"; }<br>};<br><br>int main()<br>{<br>=C2=A0=C2=A0=C2=A0 Thr=
ee three;<br>=C2=A0=C2=A0=C2=A0 auto i =3D static_cast<int>(three); /=
/ yields 3<br>=C2=A0=C2=A0=C2=A0 auto s =3D static_cast<std::string>(=
three); // yields std::string("three")<br>=C2=A0=C2=A0=C2=A0 // i=
nt j =3D three; // illegal<br>=C2=A0=C2=A0=C2=A0 // string str =3D three; /=
/ illegal<br>}<br><br></div></div></blockquote><div></div></span><blockquot=
e class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px=
#ccc solid;padding-left:1ex"><div dir=3D"ltr"><div></div>Cheers!<br></div>=
<div><br><div class=3D"gmail_quote"><span class=3D"">2015-07-01 7:17 GMT-04=
:00 Igor Baidiuk <span dir=3D"ltr"><<a rel=3D"nofollow">targe...@gmail.c=
om</a>></span>:<br></span><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D"=
"><div dir=3D"ltr">What if we could define<br><div style=3D"background-colo=
r: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">opera=
tor</span><span style=3D"color:#000"> </span><span style=3D"color:#008">sta=
tic_cast</span><span style=3D"color:#660"><</span><span style=3D"color:#=
606">To</span><span style=3D"color:#660">>(</span><span style=3D"color:#=
606">From</span><span style=3D"color:#000"> </span><span style=3D"color:#00=
8">const</span><span style=3D"color:#660">&</span><span style=3D"color:=
#000"> </span><span style=3D"color:#008">from</span><span style=3D"color:#6=
60">)</span><span style=3D"color:#000"><br></span><span style=3D"color:#660=
">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#008">return</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">{</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#008">from</span><span style=3D"color:#660">.</span><span style=3D"col=
or:#000">a</span><span style=3D"color:#660">,</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#008">from</span><span style=3D"color:#660=
">.</span><span style=3D"color:#000">b</span><span style=3D"color:#660">};<=
/span><span style=3D"color:#000"><br></span><span style=3D"color:#660">}</s=
pan><span style=3D"color:#000"><br></span><span style=3D"color:#800">// lat=
er in code</span><span style=3D"color:#000"><br></span><span style=3D"color=
:#606">From</span><span style=3D"color:#000"> </span><span style=3D"color:#=
008">from</span><span style=3D"color:#660">;</span><span style=3D"color:#00=
0"><br></span><span style=3D"color:#008">auto</span><span style=3D"color:#0=
00"> to </span><span style=3D"color:#660">=3D</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#008">static_cast</span><span style=3D"col=
or:#660"><</span><span style=3D"color:#606">To</span><span style=3D"colo=
r:#660">>(</span><span style=3D"color:#008">from</span><span style=3D"co=
lor:#660">);</span><span style=3D"color:#000"><br></span></div></code></div=
>as means of non-member, explicit conversion syntax?<br>So we don't nee=
d to write tons of functions like toFoo, toBar, toBaz etc.<br>Or, allow dec=
laring non-member conversion operators, which are explicit by default?<span=
><font color=3D"#888888"><br></font></span></div></span><span><font color=
=3D"#888888"><span class=3D"">
<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></span>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</a>.<span class=3D""><br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" rel=3D"nofollow" target=3D"_blank">http://groups.google.com=
/a/isocpp.org/group/std-proposals/</a>.<br>
</span></font></span></blockquote></div><br></div>
</blockquote></div><div class=3D"HOEnZb"><div class=3D"h5">
<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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--001a11c35152f7bed10519d2525b--
.
Author: Igor Baidiuk <target.san@gmail.com>
Date: Wed, 1 Jul 2015 09:38:37 -0700 (PDT)
Raw View
------=_Part_2272_998513374.1435768717283
Content-Type: multipart/alternative;
boundary="----=_Part_2273_1577059160.1435768717283"
------=_Part_2273_1577059160.1435768717283
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
To1 convert(From const& from);
To2 convert(From const& from);
Any ideas?
Yes, I can do
template<typename To, typename From>
To convert(From&& from);
///...
template<>
To1 convert<To1, From1>(From1 const& from);
Though it's a bit ugly, and looks like reinventing the wheel for each=20
specific case.
On Wednesday, July 1, 2015 at 6:53:31 PM UTC+3, David Rodr=C3=ADguez Ibeas =
wrote:
>
> You could create a free function in the module that does the same, right?
>
> To convert(From f) { return To{ f.a, f.b }; }
> ...
> auto to =3D convert(getSomeFrom());
>
> On Wed, Jul 1, 2015 at 2:55 PM, Igor Baidiuk <targe...@gmail.com=20
> <javascript:>> wrote:
>
>>
>>
>> On Wednesday, July 1, 2015 at 4:17:23 PM UTC+3, Patrice Roy wrote:
>>>
>>> What is missing from explicit conversion operators in your mind? For=20
>>> example, what effect do you want to acheive that is not acheived by=20
>>> something like the following?
>>>
>>> I cannot define conversions as free-standing functions.
>> Sometimes it's really useful when you want those conversions, but don't=
=20
>> want to pollute struct interface, because those conversions are used onl=
y=20
>> inside of some module.
>> =20
>>
>>> #include <string>
>>> struct Three
>>> {
>>> explicit operator int() const { return 3; }
>>> explicit operator std::string() const { return "three"; }
>>> };
>>>
>>> int main()
>>> {
>>> Three three;
>>> auto i =3D static_cast<int>(three); // yields 3
>>> auto s =3D static_cast<std::string>(three); // yields=20
>>> std::string("three")
>>> // int j =3D three; // illegal
>>> // string str =3D three; // illegal
>>> }
>>>
>>> Cheers!
>>>
>>> 2015-07-01 7:17 GMT-04:00 Igor Baidiuk <targe...@gmail.com>:
>>>
>>>> What if we could define
>>>> operator static_cast<To>(From const& from)
>>>> {
>>>> return { from.a, from.b};
>>>> }
>>>> // later in code
>>>> From from;
>>>> auto to =3D static_cast<To>(from);
>>>> as means of non-member, explicit conversion syntax?
>>>> So we don't need to write tons of functions like toFoo, toBar, toBaz=
=20
>>>> etc.
>>>> Or, allow declaring non-member conversion operators, which are explici=
t=20
>>>> by default?
>>>>
>>>> --=20
>>>>
>>>> ---=20
>>>> You received this message because you are subscribed to the Google=20
>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send=
=20
>>>> an email to std-proposal...@isocpp.org.
>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>> Visit this group at=20
>>>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>>>
>>>
>>> --=20
>>
>> ---=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=20
>> email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> Visit this group at=20
>> 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/.
------=_Part_2273_1577059160.1435768717283
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"prettyprint" style=3D"background-color: rgb(=
250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bord=
er-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div cla=
ss=3D"subprettyprint"><span style=3D"color: #606;" class=3D"styled-by-prett=
ify">To1</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> c=
onvert</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #606;" class=3D"styled-by-prettify">From</span><s=
pan 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"c=
olor: #660;" class=3D"styled-by-prettify">&</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">from</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: #606;" class=3D"styled-by-=
prettify">To2</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> convert</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">From</sp=
an><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: #660;" class=3D"styled-by-prettify">&</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">from</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>Any ideas?<br><br>Yes,=
I can do<br><div class=3D"prettyprint" style=3D"background-color: rgb(250,=
250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-w=
idth: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">template</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
><</span><span style=3D"color: #008;" class=3D"styled-by-prettify">typen=
ame</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #606;" class=3D"styled-by-prettify">To</span><span s=
tyle=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: #00=
8;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">From</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #606;" class=3D"styled-by-pret=
tify">To</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> c=
onvert</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #606;" class=3D"styled-by-prettify">From</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">&&</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">from</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><br></span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">///...</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">template</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: #606;" class=3D"st=
yled-by-prettify">To1</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> convert</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify"><</span><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">To1</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: #606;" class=3D"styled-by-prettify">From1</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">>(</span><span style=3D"=
color: #606;" class=3D"styled-by-prettify">From1</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: #660;" class=
=3D"styled-by-prettify">&</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">from</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
</span></div></code></div><br>Though it's a bit ugly, and looks like reinve=
nting the wheel for each specific case.<br><br>On Wednesday, July 1, 2015 a=
t 6:53:31 PM UTC+3, David Rodr=C3=ADguez Ibeas wrote:<blockquote class=3D"g=
mail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc sol=
id;padding-left: 1ex;"><div dir=3D"ltr">You could create a free function in=
the module that does the same, right?<br><br>To convert(From f) { return T=
o{ f.a, f.b }; }<br>...<br>auto to =3D convert(getSomeFrom());</div><div><b=
r><div class=3D"gmail_quote">On Wed, Jul 1, 2015 at 2:55 PM, Igor Baidiuk <=
span dir=3D"ltr"><<a href=3D"javascript:" target=3D"_blank" gdf-obfuscat=
ed-mailto=3D"LttGaeAuxLYJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'jav=
ascript:';return true;" onclick=3D"this.href=3D'javascript:';return true;">=
targe...@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">=
<div dir=3D"ltr"><span><br><br>On Wednesday, July 1, 2015 at 4:17:23 PM UTC=
+3, Patrice Roy wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;m=
argin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"l=
tr"><div>What is missing from explicit conversion operators in your mind? F=
or example, what effect do you want to acheive that is not acheived by some=
thing like the following?<br><br></div></div></blockquote></span><div>I can=
not define conversions as free-standing functions.<br>Sometimes it's really=
useful when you want those conversions, but don't want to pollute struct i=
nterface, because those conversions are used only inside of some module.<br=
> <br></div><span><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>#include <string><br>struct Three<br>{<br>  =
; explicit operator int() const { return 3; }<br> explici=
t operator std::string() const { return "three"; }<br>};<br><br>int main()<=
br>{<br> Three three;<br> auto i =3D st=
atic_cast<int>(three); // yields 3<br> auto s =3D s=
tatic_cast<std::string>(<wbr>three); // yields std::string("three")<b=
r> // int j =3D three; // illegal<br> /=
/ string str =3D three; // illegal<br>}<br><br></div></div></blockquote><di=
v></div></span><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-l=
eft:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><di=
v></div>Cheers!<br></div><div><br><div class=3D"gmail_quote"><span>2015-07-=
01 7:17 GMT-04:00 Igor Baidiuk <span dir=3D"ltr"><<a rel=3D"nofollow">ta=
rge...@gmail.com</a>></span>:<br></span><blockquote class=3D"gmail_quote=
" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><=
span><div dir=3D"ltr">What if we could define<br><div style=3D"background-c=
olor:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bord=
er-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#008">op=
erator</span><span style=3D"color:#000"> </span><span style=3D"color:#008">=
static_cast</span><span style=3D"color:#660"><</span><span style=3D"colo=
r:#606">To</span><span style=3D"color:#660">>(</span><span style=3D"colo=
r:#606">From</span><span style=3D"color:#000"> </span><span style=3D"color:=
#008">const</span><span style=3D"color:#660">&</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#008">from</span><span style=3D"color=
:#660">)</span><span style=3D"color:#000"><br></span><span style=3D"color:#=
660">{</span><span style=3D"color:#000"><br> </span><span styl=
e=3D"color:#008">return</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#660">{</span><span style=3D"color:#000"> </span><span style=3D"=
color:#008">from</span><span style=3D"color:#660">.</span><span style=3D"co=
lor:#000">a</span><span style=3D"color:#660">,</span><span style=3D"color:#=
000"> </span><span style=3D"color:#008">from</span><span style=3D"color:#66=
0">.</span><span style=3D"color:#000">b</span><span style=3D"color:#660">};=
</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">}</=
span><span style=3D"color:#000"><br></span><span style=3D"color:#800">// la=
ter in code</span><span style=3D"color:#000"><br></span><span style=3D"colo=
r:#606">From</span><span style=3D"color:#000"> </span><span style=3D"color:=
#008">from</span><span style=3D"color:#660">;</span><span style=3D"color:#0=
00"><br></span><span style=3D"color:#008">auto</span><span style=3D"color:#=
000"> to </span><span style=3D"color:#660">=3D</span><span style=3D"color:#=
000"> </span><span style=3D"color:#008">static_cast</span><span style=3D"co=
lor:#660"><</span><span style=3D"color:#606">To</span><span style=3D"col=
or:#660">>(</span><span style=3D"color:#008">from</span><span style=3D"c=
olor:#660">);</span><span style=3D"color:#000"><br></span></div></code></di=
v>as means of non-member, explicit conversion syntax?<br>So we don't need t=
o write tons of functions like toFoo, toBar, toBaz etc.<br>Or, allow declar=
ing non-member conversion operators, which are explicit by default?<span><f=
ont color=3D"#888888"><br></font></span></div></span><span><font color=3D"#=
888888"><span>
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br></span>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</a>.<span><br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=
=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';return true=
;" onclick=3D"this.href=3D'http://groups.google.com/a/isocpp.org/group/std-=
proposals/';return true;">http://groups.google.com/a/<wbr>isocpp.org/group/=
std-<wbr>proposals/</a>.<br>
</span></font></span></blockquote></div><br></div>
</blockquote></div><div><div>
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
LttGaeAuxLYJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';ret=
urn true;" onclick=3D"this.href=3D'javascript:';return true;">std-proposal.=
...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"LttGaeAuxLYJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:=
';return true;">std-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=
=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';return true=
;" onclick=3D"this.href=3D'http://groups.google.com/a/isocpp.org/group/std-=
proposals/';return true;">http://groups.google.com/a/<wbr>isocpp.org/group/=
std-<wbr>proposals/</a>.<br>
</div></div></blockquote></div><br></div>
</blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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_2273_1577059160.1435768717283--
------=_Part_2272_998513374.1435768717283--
.
Author: Edward Catmur <ed@catmur.co.uk>
Date: Thu, 2 Jul 2015 03:38:09 -0700 (PDT)
Raw View
------=_Part_216_1050109078.1435833489443
Content-Type: multipart/alternative;
boundary="----=_Part_217_1162662900.1435833489443"
------=_Part_217_1162662900.1435833489443
Content-Type: text/plain; charset=UTF-8
On Wednesday, 1 July 2015 14:55:52 UTC+1, Igor Baidiuk wrote:
>
> I cannot define conversions as free-standing functions.
> Sometimes it's really useful when you want those conversions, but don't
> want to pollute struct interface, because those conversions are used only
> inside of some module.
>
Also when defining vocabulary type interoperations; I might have a Date
type that I want to be able to convert to/from Boost.Gregorian, but I don't
want to impose a dependency on clients that don't need the interop.
The easiest way to write this would be to allow non-member conversion
functions:
explicit operator To(From const& from) { ... }
I think this was raised in passing here last year, although without much
result: https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/CmBERU_sr8Y
--
---
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_217_1162662900.1435833489443
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Wednesday, 1 July 2015 14:55:52 UTC+1, Igor Baidiuk wr=
ote:<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">I cannot =
define conversions as free-standing functions.<br>Sometimes it's really use=
ful when you want those conversions, but don't want to pollute struct inter=
face, because those conversions are used only inside of some module.<br></d=
iv></blockquote><div><br></div><div>Also when defining vocabulary type inte=
roperations; I might have a Date type that I want to be able to convert to/=
from Boost.Gregorian, but I don't want to impose a dependency on clients th=
at don't need the interop.</div><div><br></div><div>The easiest way to writ=
e this would be to allow non-member conversion functions:</div><div><br></d=
iv><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187)=
; word-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;"=
class=3D"styled-by-prettify">explicit</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">operator</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pr=
ettify">To</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">From</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">const</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: #00=
8;" class=3D"styled-by-prettify">from</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">=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">...</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span></div></code></div><div=
><br></div><div>I think this was raised in passing here last year, although=
without much result: https://groups.google.com/a/isocpp.org/forum/#!t=
opic/std-proposals/CmBERU_sr8Y</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_217_1162662900.1435833489443--
------=_Part_216_1050109078.1435833489443--
.
Author: =?UTF-8?Q?David_Rodr=C3=ADguez_Ibeas?= <dibeas@ieee.org>
Date: Thu, 2 Jul 2015 11:56:03 +0100
Raw View
--001a1133d13c1e514c0519e24978
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
template <typename To, typename From>
To convert(From&& from) {...};
The 'From' type can be deduced, so it is not uglier than the
static_cast<To> case:
From from =3D ...;
auto x =3D convert<To>(from);
On Wed, Jul 1, 2015 at 5:38 PM, Igor Baidiuk <target.san@gmail.com> wrote:
> To1 convert(From const& from);
> To2 convert(From const& from);
>
> Any ideas?
>
> Yes, I can do
> template<typename To, typename From>
> To convert(From&& from);
>
> ///...
>
> template<>
> To1 convert<To1, From1>(From1 const& from);
>
> Though it's a bit ugly, and looks like reinventing the wheel for each
> specific case.
>
> On Wednesday, July 1, 2015 at 6:53:31 PM UTC+3, David Rodr=C3=ADguez Ibea=
s
> wrote:
>>
>> You could create a free function in the module that does the same, right=
?
>>
>> To convert(From f) { return To{ f.a, f.b }; }
>> ...
>> auto to =3D convert(getSomeFrom());
>>
>> On Wed, Jul 1, 2015 at 2:55 PM, Igor Baidiuk <targe...@gmail.com> wrote:
>>
>>>
>>>
>>> On Wednesday, July 1, 2015 at 4:17:23 PM UTC+3, Patrice Roy wrote:
>>>>
>>>> What is missing from explicit conversion operators in your mind? For
>>>> example, what effect do you want to acheive that is not acheived by
>>>> something like the following?
>>>>
>>>> I cannot define conversions as free-standing functions.
>>> Sometimes it's really useful when you want those conversions, but don't
>>> want to pollute struct interface, because those conversions are used on=
ly
>>> inside of some module.
>>>
>>>
>>>> #include <string>
>>>> struct Three
>>>> {
>>>> explicit operator int() const { return 3; }
>>>> explicit operator std::string() const { return "three"; }
>>>> };
>>>>
>>>> int main()
>>>> {
>>>> Three three;
>>>> auto i =3D static_cast<int>(three); // yields 3
>>>> auto s =3D static_cast<std::string>(three); // yields
>>>> std::string("three")
>>>> // int j =3D three; // illegal
>>>> // string str =3D three; // illegal
>>>> }
>>>>
>>>> Cheers!
>>>>
>>>> 2015-07-01 7:17 GMT-04:00 Igor Baidiuk <targe...@gmail.com>:
>>>>
>>>>> What if we could define
>>>>> operator static_cast<To>(From const& from)
>>>>> {
>>>>> return { from.a, from.b};
>>>>> }
>>>>> // later in code
>>>>> From from;
>>>>> auto to =3D static_cast<To>(from);
>>>>> as means of non-member, explicit conversion syntax?
>>>>> So we don't need to write tons of functions like toFoo, toBar, toBaz
>>>>> etc.
>>>>> Or, allow declaring non-member conversion operators, which are
>>>>> explicit by default?
>>>>>
>>>>> --
>>>>>
>>>>> ---
>>>>> 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, sen=
d
>>>>> an email to std-proposal...@isocpp.org.
>>>>> To post to this group, send email to std-pr...@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-proposal...@isocpp.org.
>>> To post to this group, send email to std-pr...@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/.
>
--=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/.
--001a1133d13c1e514c0519e24978
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">template <typename To, typename From><br>To convert(=
From&& from) {...};<br><br><div>The 'From' type can be dedu=
ced, so it is not uglier than the static_cast<To> case:<br><br>From f=
rom =3D ...;<br>auto x =3D convert<To>(from);</div></div><div class=
=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed, Jul 1, 2015 at 5:38=
PM, Igor Baidiuk <span dir=3D"ltr"><<a href=3D"mailto:target.san@gmail.=
com" target=3D"_blank">target.san@gmail.com</a>></span> wrote:<br><block=
quote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc=
solid;padding-left:1ex"><div dir=3D"ltr"><div style=3D"background-color:rg=
b(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-widt=
h:1px;word-wrap:break-word"><code><div><span style=3D"color:#606">To1</span=
><span style=3D"color:#000"> convert</span><span style=3D"color:#660">(</sp=
an><span style=3D"color:#606">From</span><span style=3D"color:#000"> </span=
><span style=3D"color:#008">const</span><span style=3D"color:#660">&</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#008">from</spa=
n><span style=3D"color:#660">);</span><span style=3D"color:#000"><br></span=
><span style=3D"color:#606">To2</span><span style=3D"color:#000"> convert</=
span><span style=3D"color:#660">(</span><span style=3D"color:#606">From</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#008">const</spa=
n><span style=3D"color:#660">&</span><span style=3D"color:#000"> </span=
><span style=3D"color:#008">from</span><span style=3D"color:#660">);</span>=
<span style=3D"color:#000"><br></span></div></code></div><br>Any ideas?<br>=
<br>Yes, I can do<br><div 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><div><span style=3D"color:#008">template</span><span style=3D"=
color:#660"><</span><span style=3D"color:#008">typename</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#606">To</span><span style=3D=
"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#008">typename</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#606">From</span><span style=3D"color:#660">></span><span style=3D"c=
olor:#000"><br></span><span style=3D"color:#606">To</span><span style=3D"co=
lor:#000"> convert</span><span style=3D"color:#660">(</span><span style=3D"=
color:#606">From</span><span style=3D"color:#660">&&</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#008">from</span><span styl=
e=3D"color:#660">);</span><span style=3D"color:#000"><br><br></span><span s=
tyle=3D"color:#800">///...</span><span style=3D"color:#000"><br><br></span>=
<span style=3D"color:#008">template</span><span style=3D"color:#660"><&g=
t;</span><span style=3D"color:#000"><br></span><span style=3D"color:#606">T=
o1</span><span style=3D"color:#000"> convert</span><span style=3D"color:#66=
0"><</span><span style=3D"color:#606">To1</span><span style=3D"color:#66=
0">,</span><span style=3D"color:#000"> </span><span style=3D"color:#606">Fr=
om1</span><span style=3D"color:#660">>(</span><span style=3D"color:#606"=
>From1</span><span style=3D"color:#000"> </span><span style=3D"color:#008">=
const</span><span style=3D"color:#660">&</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#008">from</span><span style=3D"color:#660"=
>);</span><span style=3D"color:#000"><br></span></div></code></div><br>Thou=
gh it's a bit ugly, and looks like reinventing the wheel for each speci=
fic case.<span class=3D""><br><br>On Wednesday, July 1, 2015 at 6:53:31 PM =
UTC+3, David Rodr=C3=ADguez Ibeas wrote:</span><blockquote class=3D"gmail_q=
uote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;paddin=
g-left:1ex"><span class=3D""><div dir=3D"ltr">You could create a free funct=
ion in the module that does the same, right?<br><br>To convert(From f) { re=
turn To{ f.a, f.b }; }<br>...<br>auto to =3D convert(getSomeFrom());</div><=
/span><div><div class=3D"h5"><div><br><div class=3D"gmail_quote">On Wed, Ju=
l 1, 2015 at 2:55 PM, Igor Baidiuk <span dir=3D"ltr"><<a rel=3D"nofollow=
">targe...@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=
"><div dir=3D"ltr"><span><br><br>On Wednesday, July 1, 2015 at 4:17:23 PM U=
TC+3, Patrice Roy 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>What is missing from explicit conversion operators in your mind?=
For example, what effect do you want to acheive that is not acheived by so=
mething like the following?<br><br></div></div></blockquote></span><div>I c=
annot define conversions as free-standing functions.<br>Sometimes it's =
really useful when you want those conversions, but don't want to pollut=
e struct interface, because those conversions are used only inside of some =
module.<br>=C2=A0<br></div><span><blockquote class=3D"gmail_quote" style=3D=
"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><d=
iv dir=3D"ltr"><div>#include <string><br>struct Three<br>{<br>=C2=A0=
=C2=A0=C2=A0 explicit operator int() const { return 3; }<br>=C2=A0=C2=A0=C2=
=A0 explicit operator std::string() const { return "three"; }<br>=
};<br><br>int main()<br>{<br>=C2=A0=C2=A0=C2=A0 Three three;<br>=C2=A0=C2=
=A0=C2=A0 auto i =3D static_cast<int>(three); // yields 3<br>=C2=A0=
=C2=A0=C2=A0 auto s =3D static_cast<std::string>(three); // yields st=
d::string("three")<br>=C2=A0=C2=A0=C2=A0 // int j =3D three; // i=
llegal<br>=C2=A0=C2=A0=C2=A0 // string str =3D three; // illegal<br>}<br><b=
r></div></div></blockquote><div></div></span><blockquote class=3D"gmail_quo=
te" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-=
left:1ex"><div dir=3D"ltr"><div></div>Cheers!<br></div><div><br><div class=
=3D"gmail_quote"><span>2015-07-01 7:17 GMT-04:00 Igor Baidiuk <span dir=3D"=
ltr"><<a rel=3D"nofollow">targe...@gmail.com</a>></span>:<br></span><=
blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px=
#ccc solid;padding-left:1ex"><span><div dir=3D"ltr">What if we could defin=
e<br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,1=
87,187);border-style:solid;border-width:1px;word-wrap:break-word"><code><di=
v><span style=3D"color:#008">operator</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#008">static_cast</span><span style=3D"color:#660"=
><</span><span style=3D"color:#606">To</span><span style=3D"color:#660">=
>(</span><span style=3D"color:#606">From</span><span style=3D"color:#000=
"> </span><span style=3D"color:#008">const</span><span style=3D"color:#660"=
>&</span><span style=3D"color:#000"> </span><span style=3D"color:#008">=
from</span><span style=3D"color:#660">)</span><span style=3D"color:#000"><b=
r></span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><span style=3D=
"color:#000"> </span><span style=3D"color:#660">{</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#008">from</span><span style=3D"color:=
#660">.</span><span style=3D"color:#000">a</span><span style=3D"color:#660"=
>,</span><span style=3D"color:#000"> </span><span style=3D"color:#008">from=
</span><span style=3D"color:#660">.</span><span style=3D"color:#000">b</spa=
n><span style=3D"color:#660">};</span><span style=3D"color:#000"><br></span=
><span style=3D"color:#660">}</span><span style=3D"color:#000"><br></span><=
span style=3D"color:#800">// later in code</span><span style=3D"color:#000"=
><br></span><span style=3D"color:#606">From</span><span style=3D"color:#000=
"> </span><span style=3D"color:#008">from</span><span style=3D"color:#660">=
;</span><span style=3D"color:#000"><br></span><span style=3D"color:#008">au=
to</span><span style=3D"color:#000"> to </span><span style=3D"color:#660">=
=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#008">sta=
tic_cast</span><span style=3D"color:#660"><</span><span style=3D"color:#=
606">To</span><span style=3D"color:#660">>(</span><span style=3D"color:#=
008">from</span><span style=3D"color:#660">);</span><span style=3D"color:#0=
00"><br></span></div></code></div>as means of non-member, explicit conversi=
on syntax?<br>So we don't need to write tons of functions like toFoo, t=
oBar, toBaz etc.<br>Or, allow declaring non-member conversion operators, wh=
ich are explicit by default?<span><font color=3D"#888888"><br></font></span=
></div></span><span><font color=3D"#888888"><span>
<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></span>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</a>.<span><br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" rel=3D"nofollow" target=3D"_blank">http://groups.google.com=
/a/isocpp.org/group/std-proposals/</a>.<br>
</span></font></span></blockquote></div><br></div>
</blockquote></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 rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" rel=3D"nofollow" target=3D"_blank">http://groups.google.com=
/a/isocpp.org/group/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><div class=3D"HOEnZb"><div class=3D"h5">
<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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--001a1133d13c1e514c0519e24978--
.