Topic: explicit blocks


Author: Michael Boyko <mboyko2000@gmail.com>
Date: Wed, 20 May 2015 09:11:23 -0700 (PDT)
Raw View
------=_Part_228_1798307834.1432138283374
Content-Type: multipart/alternative;
 boundary="----=_Part_229_474918160.1432138283374"

------=_Part_229_474918160.1432138283374
Content-Type: text/plain; charset=UTF-8

An explicit block would be a way to write code where implicit conversions
would not be generated. For example:

void fn(double d) {...}

void test()
{
   int i = 1;
   double d = 2.0;
   auto p = make_unique<int>(0);

   explicit {
      d = i; //error
      fn(i); //error
      fn(d); //fn's body does not inherit explicit
      bool b = p;
   }
}

void test2() explicit; //error for declaration

//some shorthand ways to declar explicit for blocks
void test2() explicit //ok for definition
{
   if (condition) explicit {
   }
}

Maybe (but not as sure on this one) also for functions as follows:
explicit void fn(double d) //this explicit applies to function params not
the body
{
}

void test()
{
   int i = 1;
   fn(i); //error
}


--

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

<div dir=3D"ltr"><div>An explicit block would be a way to write code where =
implicit conversions would not be generated. For example:</div><div><br></d=
iv><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187)=
; border-image: none; -ms-word-wrap: break-word; background-color: rgb(250,=
 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><spa=
n class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">void</span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> fn</span=
><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">(</s=
pan><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">dou=
ble</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"=
> d</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, =
0);">)</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0=
);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102=
, 0);">{...}</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0=
, 0, 0);"><br><br></span><span class=3D"styled-by-prettify" style=3D"color:=
 rgb(0, 0, 136);">void</span><span class=3D"styled-by-prettify" style=3D"co=
lor: rgb(0, 0, 0);"> test</span><span class=3D"styled-by-prettify" style=3D=
"color: rgb(102, 102, 0);">()</span><span class=3D"styled-by-prettify" styl=
e=3D"color: rgb(0, 0, 0);"><br></span><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(102, 102, 0);">{</span><span class=3D"styled-by-prettify"=
 style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp;</span><span class=3D"styl=
ed-by-prettify" style=3D"color: rgb(0, 0, 136);">int</span><span class=3D"s=
tyled-by-prettify" style=3D"color: rgb(0, 0, 0);"> i </span><span class=3D"=
styled-by-prettify" style=3D"color: rgb(102, 102, 0);">=3D</span><span clas=
s=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 102, 102);">1</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">;</span><span=
 class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nb=
sp;</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136)=
;">double</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0=
, 0);"> d </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102=
, 102, 0);">=3D</span><span class=3D"styled-by-prettify" style=3D"color: rg=
b(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb=
(0, 102, 102);">2.0</span><span class=3D"styled-by-prettify" style=3D"color=
: rgb(102, 102, 0);">;</span><span class=3D"styled-by-prettify" style=3D"co=
lor: rgb(0, 0, 0);"><br>&nbsp; &nbsp;</span><span class=3D"styled-by-pretti=
fy" style=3D"color: rgb(0, 0, 136);">auto</span><span class=3D"styled-by-pr=
ettify" style=3D"color: rgb(0, 0, 0);"> p </span><span class=3D"styled-by-p=
rettify" style=3D"color: rgb(102, 102, 0);">=3D</span><span class=3D"styled=
-by-prettify" style=3D"color: rgb(0, 0, 0);"> make_unique</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 136, 0);">&lt;int&gt;</span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">(</sp=
an><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 102, 102);">0<=
/span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);"=
>);</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"=
><br><br>&nbsp; &nbsp;</span><span class=3D"styled-by-prettify" style=3D"co=
lor: rgb(0, 0, 136);">explicit</span><span class=3D"styled-by-prettify" sty=
le=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" styl=
e=3D"color: rgb(102, 102, 0);">{</span><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; d </span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">=3D</span><span =
class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> i</span><span =
class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">;</span><sp=
an class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><spa=
n class=3D"styled-by-prettify" style=3D"color: rgb(136, 0, 0);">//error</sp=
an><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&n=
bsp; &nbsp; &nbsp; fn</span><span class=3D"styled-by-prettify" style=3D"col=
or: rgb(102, 102, 0);">(</span><span class=3D"styled-by-prettify" style=3D"=
color: rgb(0, 0, 0);">i</span><span class=3D"styled-by-prettify" style=3D"c=
olor: rgb(102, 102, 0);">);</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(136, 0, 0);">//error</span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; fn</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">(</span><span=
 class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">d</span><span =
class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">);</span><s=
pan class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><sp=
an class=3D"styled-by-prettify" style=3D"color: rgb(136, 0, 0);">//fn's bod=
y does not inherit explicit</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; </span><span class=3D"st=
yled-by-prettify" style=3D"color: rgb(0, 0, 136);">bool</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> b </span><span clas=
s=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">=3D</span><span=
 class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> p</span><span=
 class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">;</span><s=
pan class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; =
&nbsp;</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 10=
2, 0);">}</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0=
, 0);"><br></span><span class=3D"styled-by-prettify" style=3D"color: rgb(10=
2, 102, 0);">}</span><span class=3D"styled-by-prettify" style=3D"color: rgb=
(0, 0, 0);"><br><br></span><span class=3D"styled-by-prettify" style=3D"colo=
r: rgb(0, 0, 136);">void</span><span class=3D"styled-by-prettify" style=3D"=
color: rgb(0, 0, 0);"> test2</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(102, 102, 0);">()</span><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(0, 0, 136);">explicit</span><span class=3D"styled-by-pret=
tify" style=3D"color: rgb(102, 102, 0);">;</span><span class=3D"styled-by-p=
rettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-pr=
ettify" style=3D"color: rgb(136, 0, 0);">//error for declaration</span><spa=
n class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br><br></spa=
n><span class=3D"styled-by-prettify" style=3D"color: rgb(136, 0, 0);">//som=
e shorthand ways to declar explicit for blocks</span><span class=3D"styled-=
by-prettify" style=3D"color: rgb(0, 0, 0);"><br></span><span class=3D"style=
d-by-prettify" style=3D"color: rgb(0, 0, 136);">void</span><span class=3D"s=
tyled-by-prettify" style=3D"color: rgb(0, 0, 0);"> test2</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">()</span><span c=
lass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">explicit</span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(136, 0, 0);">//ok for=
 definition</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0,=
 0, 0);"><br></span><span class=3D"styled-by-prettify" style=3D"color: rgb(=
102, 102, 0);">{</span><span class=3D"styled-by-prettify" style=3D"color: r=
gb(0, 0, 0);"><br>&nbsp; &nbsp;</span><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(0, 0, 136);">if</span><span class=3D"styled-by-prettify" =
style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(102, 102, 0);">(</span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(0, 0, 0);">condition</span><span class=3D"styled-by-p=
rettify" style=3D"color: rgb(102, 102, 0);">)</span><span class=3D"styled-b=
y-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by=
-prettify" style=3D"color: rgb(0, 0, 136);">explicit</span><span class=3D"s=
tyled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"st=
yled-by-prettify" style=3D"color: rgb(102, 102, 0);">{</span><span class=3D=
"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp;</span=
><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">}</s=
pan><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br><=
/span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);"=
>}</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">=
<br></span></div></code></div><div><br></div><div>Maybe (but not as sure on=
 this one) also for functions as follows:</div><div class=3D"prettyprint" s=
tyle=3D"border: 1px solid rgb(187, 187, 187); border-image: none; -ms-word-=
wrap: break-word; background-color: rgb(250, 250, 250);"><code class=3D"pre=
ttyprint"><div class=3D"subprettyprint"><span class=3D"styled-by-prettify" =
style=3D"color: rgb(0, 0, 136);">explicit</span><span class=3D"styled-by-pr=
ettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-pre=
ttify" style=3D"color: rgb(0, 0, 136);">void</span><span class=3D"styled-by=
-prettify" style=3D"color: rgb(0, 0, 0);"> fn</span><span class=3D"styled-b=
y-prettify" style=3D"color: rgb(102, 102, 0);">(</span><span class=3D"style=
d-by-prettify" style=3D"color: rgb(0, 0, 136);">double</span><span class=3D=
"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> d</span><span class=3D=
"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">)</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(136, 0, 0);">//this explicit ap=
plies to function params not the body</span><span class=3D"styled-by-pretti=
fy" style=3D"color: rgb(0, 0, 0);"><br></span><span class=3D"styled-by-pret=
tify" style=3D"color: rgb(102, 102, 0);">{</span><span class=3D"styled-by-p=
rettify" style=3D"color: rgb(0, 0, 0);"><br></span><span class=3D"styled-by=
-prettify" style=3D"color: rgb(102, 102, 0);">}</span><span class=3D"styled=
-by-prettify" style=3D"color: rgb(0, 0, 0);"><br><br></span><span class=3D"=
styled-by-prettify" style=3D"color: rgb(0, 0, 136);">void</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> test</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">()</span><spa=
n class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br></span><s=
pan class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">{</span=
><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbs=
p; &nbsp;</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0=
, 136);">int</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0=
, 0, 0);"> i </span><span class=3D"styled-by-prettify" style=3D"color: rgb(=
102, 102, 0);">=3D</span><span class=3D"styled-by-prettify" style=3D"color:=
 rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: =
rgb(0, 102, 102);">1</span><span class=3D"styled-by-prettify" style=3D"colo=
r: rgb(102, 102, 0);">;</span><span class=3D"styled-by-prettify" style=3D"c=
olor: rgb(0, 0, 0);"><br>&nbsp; &nbsp;fn</span><span class=3D"styled-by-pre=
ttify" style=3D"color: rgb(102, 102, 0);">(</span><span class=3D"styled-by-=
prettify" style=3D"color: rgb(0, 0, 0);">i</span><span class=3D"styled-by-p=
rettify" style=3D"color: rgb(102, 102, 0);">);</span><span class=3D"styled-=
by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-b=
y-prettify" style=3D"color: rgb(136, 0, 0);">//error</span><span class=3D"s=
tyled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br></span><span class=3D=
"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">}</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br></span></div></c=
ode></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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_229_474918160.1432138283374--
------=_Part_228_1798307834.1432138283374--

.


Author: Patrice Roy <patricer@gmail.com>
Date: Wed, 20 May 2015 12:24:26 -0400
Raw View
--001a113b0bfe5098a1051685dc1e
Content-Type: text/plain; charset=UTF-8

Before going for something like this, there would be a need for some
clarifications:


   - would there be an impact on constructors within an explicit block,
   e.g. making all implicit construction explicit within the block?
   - what would happen if an explicit function calls a non-explicit
   function? Would the impact be transitive? Would there be an error?
   - can one overload on the explicit-ness of a function?
   - how does it interact with virtual functions?
   - what happens if someone has the funny idea to mark main() as explicit?


That would be a start if we want to weigh in the pros and cons of such a
proposal.

Cheers!

2015-05-20 12:11 GMT-04:00 Michael Boyko <mboyko2000@gmail.com>:

> An explicit block would be a way to write code where implicit conversions
> would not be generated. For example:
>
> void fn(double d) {...}
>
> void test()
> {
>    int i = 1;
>    double d = 2.0;
>    auto p = make_unique<int>(0);
>
>    explicit {
>       d = i; //error
>       fn(i); //error
>       fn(d); //fn's body does not inherit explicit
>       bool b = p;
>    }
> }
>
> void test2() explicit; //error for declaration
>
> //some shorthand ways to declar explicit for blocks
> void test2() explicit //ok for definition
> {
>    if (condition) explicit {
>    }
> }
>
> Maybe (but not as sure on this one) also for functions as follows:
> explicit void fn(double d) //this explicit applies to function params not
> the body
> {
> }
>
> void test()
> {
>    int i = 1;
>    fn(i); //error
> }
>
>
>  --
>
> ---
> 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/.

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

<div dir=3D"ltr"><div><div><div><div><div>Before going for something like t=
his, there would be a need for some clarifications:<br><br></div><ul><li>wo=
uld there be an impact on constructors within an explicit block, e.g. makin=
g all implicit construction explicit within the block?</li><li>what would h=
appen if an explicit function calls a non-explicit function? Would the impa=
ct be transitive? Would there be an error?</li><li>can one overload on the =
explicit-ness of a function?</li><li>how does it interact with virtual func=
tions?</li><li>what happens if someone has the funny idea to mark main() as=
 explicit?</li></ul></div></div><br></div>That would be a start if we want =
to weigh in the pros and cons of such a proposal.<br><br></div>Cheers!<br><=
/div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">2015-05-20 1=
2:11 GMT-04:00 Michael Boyko <span dir=3D"ltr">&lt;<a href=3D"mailto:mboyko=
2000@gmail.com" target=3D"_blank">mboyko2000@gmail.com</a>&gt;</span>:<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"><div>An explicit block would=
 be a way to write code where implicit conversions would not be generated. =
For example:</div><div><br></div><div style=3D"border:1px solid rgb(187,187=
,187);background-color:rgb(250,250,250)"><code><div><span style=3D"color:rg=
b(0,0,136)">void</span><span style=3D"color:rgb(0,0,0)"> fn</span><span sty=
le=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,136)">doub=
le</span><span style=3D"color:rgb(0,0,0)"> d</span><span style=3D"color:rgb=
(102,102,0)">)</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,102,0)">{...}</span><span style=3D"color:rgb(0,0,0)"><br>=
<br></span><span style=3D"color:rgb(0,0,136)">void</span><span style=3D"col=
or:rgb(0,0,0)"> test</span><span style=3D"color:rgb(102,102,0)">()</span><s=
pan style=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(102,102,=
0)">{</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0</span><span =
style=3D"color:rgb(0,0,136)">int</span><span style=3D"color:rgb(0,0,0)"> i =
</span><span style=3D"color:rgb(102,102,0)">=3D</span><span style=3D"color:=
rgb(0,0,0)"> </span><span style=3D"color:rgb(0,102,102)">1</span><span styl=
e=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br>=C2=
=A0 =C2=A0</span><span style=3D"color:rgb(0,0,136)">double</span><span styl=
e=3D"color:rgb(0,0,0)"> d </span><span style=3D"color:rgb(102,102,0)">=3D</=
span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,10=
2,102)">2.0</span><span style=3D"color:rgb(102,102,0)">;</span><span style=
=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0</span><span style=3D"color:rgb(0,0,=
136)">auto</span><span style=3D"color:rgb(0,0,0)"> p </span><span style=3D"=
color:rgb(102,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> make_uniq=
ue</span><span style=3D"color:rgb(0,136,0)">&lt;int&gt;</span><span style=
=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,102,102)">0</s=
pan><span style=3D"color:rgb(102,102,0)">);</span><span style=3D"color:rgb(=
0,0,0)"><br><br>=C2=A0 =C2=A0</span><span style=3D"color:rgb(0,0,136)">expl=
icit</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rg=
b(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =
=C2=A0 d </span><span style=3D"color:rgb(102,102,0)">=3D</span><span style=
=3D"color:rgb(0,0,0)"> i</span><span style=3D"color:rgb(102,102,0)">;</span=
><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0,0)=
">//error</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =C2=A0 f=
n</span><span style=3D"color:rgb(102,102,0)">(</span><span style=3D"color:r=
gb(0,0,0)">i</span><span style=3D"color:rgb(102,102,0)">);</span><span styl=
e=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0,0)">//error</=
span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 =C2=A0 fn</span><sp=
an style=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">=
d</span><span style=3D"color:rgb(102,102,0)">);</span><span style=3D"color:=
rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0,0)">//fn&#39;s body does=
 not inherit explicit</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=
=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">bool</span><span style=
=3D"color:rgb(0,0,0)"> b </span><span style=3D"color:rgb(102,102,0)">=3D</s=
pan><span style=3D"color:rgb(0,0,0)"> p</span><span style=3D"color:rgb(102,=
102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0</span><s=
pan style=3D"color:rgb(102,102,0)">}</span><span style=3D"color:rgb(0,0,0)"=
><br></span><span style=3D"color:rgb(102,102,0)">}</span><span style=3D"col=
or:rgb(0,0,0)"><br><br></span><span style=3D"color:rgb(0,0,136)">void</span=
><span style=3D"color:rgb(0,0,0)"> test2</span><span style=3D"color:rgb(102=
,102,0)">()</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"c=
olor:rgb(0,0,136)">explicit</span><span style=3D"color:rgb(102,102,0)">;</s=
pan><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0=
,0)">//error for declaration</span><span style=3D"color:rgb(0,0,0)"><br><br=
></span><span style=3D"color:rgb(136,0,0)">//some shorthand ways to declar =
explicit for blocks</span><span style=3D"color:rgb(0,0,0)"><br></span><span=
 style=3D"color:rgb(0,0,136)">void</span><span style=3D"color:rgb(0,0,0)"> =
test2</span><span style=3D"color:rgb(102,102,0)">()</span><span style=3D"co=
lor:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">explicit</span><=
span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0,0)">=
//ok for definition</span><span style=3D"color:rgb(0,0,0)"><br></span><span=
 style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><b=
r>=C2=A0 =C2=A0</span><span style=3D"color:rgb(0,0,136)">if</span><span sty=
le=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">(</spa=
n><span style=3D"color:rgb(0,0,0)">condition</span><span style=3D"color:rgb=
(102,102,0)">)</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(0,0,136)">explicit</span><span style=3D"color:rgb(0,0,0)"> </=
span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(=
0,0,0)"><br>=C2=A0 =C2=A0</span><span style=3D"color:rgb(102,102,0)">}</spa=
n><span style=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(102,=
102,0)">}</span><span style=3D"color:rgb(0,0,0)"><br></span></div></code></=
div><div><br></div><div>Maybe (but not as sure on this one) also for functi=
ons as follows:</div><div style=3D"border:1px solid rgb(187,187,187);backgr=
ound-color:rgb(250,250,250)"><code><div><span style=3D"color:rgb(0,0,136)">=
explicit</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"colo=
r:rgb(0,0,136)">void</span><span style=3D"color:rgb(0,0,0)"> fn</span><span=
 style=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,136)">=
double</span><span style=3D"color:rgb(0,0,0)"> d</span><span style=3D"color=
:rgb(102,102,0)">)</span><span style=3D"color:rgb(0,0,0)"> </span><span sty=
le=3D"color:rgb(136,0,0)">//this explicit applies to function params not th=
e body</span><span style=3D"color:rgb(0,0,0)"><br></span><span style=3D"col=
or:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br></span><spa=
n style=3D"color:rgb(102,102,0)">}</span><span style=3D"color:rgb(0,0,0)"><=
br><br></span><span style=3D"color:rgb(0,0,136)">void</span><span style=3D"=
color:rgb(0,0,0)"> test</span><span style=3D"color:rgb(102,102,0)">()</span=
><span style=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(102,1=
02,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0</span><sp=
an style=3D"color:rgb(0,0,136)">int</span><span style=3D"color:rgb(0,0,0)">=
 i </span><span style=3D"color:rgb(102,102,0)">=3D</span><span style=3D"col=
or:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,102,102)">1</span><span s=
tyle=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br>=
=C2=A0 =C2=A0fn</span><span style=3D"color:rgb(102,102,0)">(</span><span st=
yle=3D"color:rgb(0,0,0)">i</span><span style=3D"color:rgb(102,102,0)">);</s=
pan><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0=
,0)">//error</span><span style=3D"color:rgb(0,0,0)"><br></span><span style=
=3D"color:rgb(102,102,0)">}</span><span class=3D"HOEnZb"><font color=3D"#88=
8888"><span style=3D"color:rgb(0,0,0)"><br></span></font></span></div></cod=
e></div><span class=3D"HOEnZb"><font color=3D"#888888"><div><br></div><div>=
<br></div></font></span></div><span class=3D"HOEnZb"><font color=3D"#888888=
">

<p></p>

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

<p></p>

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

--001a113b0bfe5098a1051685dc1e--

.


Author: David Krauss <potswa@mac.com>
Date: Thu, 21 May 2015 00:25:58 +0800
Raw View
--Apple-Mail=_C9BC76D8-EC69-4EE0-A796-C7E073CC8346
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9305=E2=80=9321, at 12:11 AM, Michael Boyko <mboyko2000@gma=
il.com> wrote:
>=20
> An explicit block would be a way to write code where implicit conversions=
 would not be generated.

An implicit block would be a way to write code where all explicit conversio=
ns would be generated automatically.

For example:

struct foo {
    explicit foo();
};

foo test(void *x) {
    implicit {
        foo *pf =3D x;
        double *pd =3D pf;
        short s{ *pd };
        return {}; // per N4074
    }
}

;)

--=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=_C9BC76D8-EC69-4EE0-A796-C7E073CC8346
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=9305=
=E2=80=9321, at 12:11 AM, Michael Boyko &lt;<a href=3D"mailto:mboyko2000@gm=
ail.com" class=3D"">mboyko2000@gmail.com</a>&gt; wrote:</div><br class=3D"A=
pple-interchange-newline"><div class=3D""><div dir=3D"ltr" class=3D""><div =
class=3D"">An explicit block would be a way to write code where implicit co=
nversions would not be generated.</div></div></div></blockquote><div><br cl=
ass=3D""></div><div>An <font face=3D"Courier" class=3D"">implicit</font> bl=
ock would be a way to write code where all explicit conversions would be ge=
nerated automatically.</div><div><br class=3D""></div><div><font face=3D"Co=
urier" class=3D"">For example:</font></div><div><font face=3D"Courier" clas=
s=3D""><br class=3D""></font></div><div><font face=3D"Courier" class=3D"">s=
truct foo {</font></div><div><font face=3D"Courier" class=3D"">&nbsp; &nbsp=
; explicit foo();</font></div><div><font face=3D"Courier" class=3D"">};</fo=
nt></div><div><font face=3D"Courier" class=3D""><br class=3D""></font></div=
><div><font face=3D"Courier" class=3D"">foo test(void *x) {</font></div><di=
v><font face=3D"Courier" class=3D"">&nbsp; &nbsp; implicit {</font></div><d=
iv><font face=3D"Courier" class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; foo *pf =
=3D x;</font></div><div><font face=3D"Courier" class=3D"">&nbsp; &nbsp; &nb=
sp; &nbsp; double *pd =3D pf;</font></div><div><font face=3D"Courier" class=
=3D"">&nbsp; &nbsp; &nbsp; &nbsp; short s{ *pd };</font></div><div><font fa=
ce=3D"Courier" class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; return {}; // per N40=
74</font></div><div><font face=3D"Courier" class=3D"">&nbsp; &nbsp; }</font=
></div><div><font face=3D"Courier" class=3D"">}</font></div></div><br class=
=3D""><div 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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--Apple-Mail=_C9BC76D8-EC69-4EE0-A796-C7E073CC8346--

.


Author: Michael Boyko <mboyko2000@gmail.com>
Date: Wed, 20 May 2015 09:32:19 -0700 (PDT)
Raw View
------=_Part_1860_845629486.1432139539387
Content-Type: multipart/alternative;
 boundary="----=_Part_1861_447995356.1432139539387"

------=_Part_1861_447995356.1432139539387
Content-Type: text/plain; charset=UTF-8

I tried to hit a couple of these in my examples, but I am shooting from the
hip here.

On Wednesday, May 20, 2015 at 11:24:27 AM UTC-5, Patrice Roy wrote:
>
> Before going for something like this, there would be a need for some
> clarifications:
>
>
>    - would there be an impact on constructors within an explicit block,
>    e.g. making all implicit construction explicit within the block?
>    - what would happen if an explicit function calls a non-explicit
>    function? Would the impact be transitive? Would there be an error?
>
> No. The same function would behave differently depending where it was
called from? I'd say no error. thoughts?

>
>    - can one overload on the explicit-ness of a function?
>
> No. I had an example that made it an error to place it on trailing end of
a function declaration but not the definition. Like noexcept. This is why I
wasn't so sure about the explicit for the function params (placed before
the function).

>
>    - how does it interact with virtual functions?
>
>

>
>    - what happens if someone has the funny idea to mark main() as
>    explicit?
>
>
> That would be a start if we want to weigh in the pros and cons of such a
> proposal.
>
> Cheers!
>
> 2015-05-20 12:11 GMT-04:00 Michael Boyko <mboyk...@gmail.com <javascript:>
> >:
>
>> An explicit block would be a way to write code where implicit conversions
>> would not be generated. For example:
>>
>> void fn(double d) {...}
>>
>> void test()
>> {
>>    int i = 1;
>>    double d = 2.0;
>>    auto p = make_unique<int>(0);
>>
>>    explicit {
>>       d = i; //error
>>       fn(i); //error
>>       fn(d); //fn's body does not inherit explicit
>>       bool b = p;
>>    }
>> }
>>
>> void test2() explicit; //error for declaration
>>
>> //some shorthand ways to declar explicit for blocks
>> void test2() explicit //ok for definition
>> {
>>    if (condition) explicit {
>>    }
>> }
>>
>> Maybe (but not as sure on this one) also for functions as follows:
>> explicit void fn(double d) //this explicit applies to function params
>> not the body
>> {
>> }
>>
>> void test()
>> {
>>    int i = 1;
>>    fn(i); //error
>> }
>>
>>
>>  --
>>
>> ---
>> 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_1861_447995356.1432139539387
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I tried to hit a couple of these in my examples, but I am =
shooting from the hip here.<br><br>On Wednesday, May 20, 2015 at 11:24:27 A=
M UTC-5, Patrice Roy wrote:<blockquote class=3D"gmail_quote" style=3D"margi=
n: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 2=
04); border-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr"><d=
iv><div><div><div><div>Before going for something like this, there would be=
 a need for some clarifications:<br><br></div><ul><li>would there be an imp=
act on constructors within an explicit block, e.g. making all implicit cons=
truction explicit within the block?</li><li>what would happen if an explici=
t function calls a non-explicit function? Would the impact be transitive? W=
ould there be an error?</li></ul></div></div></div></div></div></blockquote=
><div>No.&nbsp;The same function would behave differently depending where i=
t was called from? I'd say no error. thoughts?&nbsp;</div><blockquote class=
=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; bor=
der-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-sty=
le: solid;"><div dir=3D"ltr"><div><div><div><div><ul><li>can one overload o=
n the explicit-ness of a function?</li></ul></div></div></div></div></div><=
/blockquote><div>No. I had&nbsp;an example that&nbsp;made it an error to pl=
ace it on trailing end&nbsp;of a function declaration but not the definitio=
n.&nbsp;Like noexcept. This is why I wasn't so sure about the&nbsp;explicit=
 for the function params (placed before the function).</div><blockquote cla=
ss=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; b=
order-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-s=
tyle: solid;"><div dir=3D"ltr"><div><div><div><div><ul><li>how does it inte=
ract with virtual functions?</li></ul></div></div></div></div></div></block=
quote><div>&nbsp;</div><blockquote class=3D"gmail_quote" style=3D"margin: 0=
px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204);=
 border-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr"><div><=
div><div><div><ul><li>what happens if someone has the funny idea to mark ma=
in() as explicit?</li></ul></div></div><br></div>That would be a start if w=
e want to weigh in the pros and cons of such a proposal.<br><br></div>Cheer=
s!<br></div><div><br><div class=3D"gmail_quote">2015-05-20 12:11 GMT-04:00 =
Michael Boyko <span dir=3D"ltr">&lt;<a onmousedown=3D"this.href=3D'javascri=
pt:';return true;" onclick=3D"this.href=3D'javascript:';return true;" href=
=3D"javascript:" target=3D"_blank" rel=3D"nofollow" gdf-obfuscated-mailto=
=3D"LJ6BOUv_xy8J">mboyk...@gmail.com</a>&gt;</span>:<br><blockquote class=
=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; bor=
der-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-sty=
le: solid;"><div dir=3D"ltr"><div>An explicit block would be a way to write=
 code where implicit conversions would not be generated. For example:</div>=
<div><br></div><div style=3D"border: 1px solid rgb(187, 187, 187); border-i=
mage: none; background-color: rgb(250, 250, 250);"><code><div><span style=
=3D"color: rgb(0, 0, 136);">void</span><span style=3D"color: rgb(0, 0, 0);"=
> fn</span><span style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"=
color: rgb(0, 0, 136);">double</span><span style=3D"color: rgb(0, 0, 0);"> =
d</span><span style=3D"color: rgb(102, 102, 0);">)</span><span style=3D"col=
or: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">{...}</=
span><span style=3D"color: rgb(0, 0, 0);"><br><br></span><span style=3D"col=
or: rgb(0, 0, 136);">void</span><span style=3D"color: rgb(0, 0, 0);"> test<=
/span><span style=3D"color: rgb(102, 102, 0);">()</span><span style=3D"colo=
r: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 102, 0);">{</sp=
an><span style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp;</span><span style=
=3D"color: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(0, 0, 0);">=
 i </span><span style=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D=
"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102, 102);">1</=
span><span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color:=
 rgb(0, 0, 0);"><br>&nbsp; &nbsp;</span><span style=3D"color: rgb(0, 0, 136=
);">double</span><span style=3D"color: rgb(0, 0, 0);"> d </span><span style=
=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, 0, 0);=
"> </span><span style=3D"color: rgb(0, 102, 102);">2.0</span><span style=3D=
"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br=
>&nbsp; &nbsp;</span><span style=3D"color: rgb(0, 0, 136);">auto</span><spa=
n style=3D"color: rgb(0, 0, 0);"> p </span><span style=3D"color: rgb(102, 1=
02, 0);">=3D</span><span style=3D"color: rgb(0, 0, 0);"> make_unique</span>=
<span style=3D"color: rgb(0, 136, 0);">&lt;int&gt;</span><span style=3D"col=
or: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 102, 102);">0</=
span><span style=3D"color: rgb(102, 102, 0);">);</span><span style=3D"color=
: rgb(0, 0, 0);"><br><br>&nbsp; &nbsp;</span><span style=3D"color: rgb(0, 0=
, 136);">explicit</span><span style=3D"color: rgb(0, 0, 0);"> </span><span =
style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, =
0);"><br>&nbsp; &nbsp; &nbsp; d </span><span style=3D"color: rgb(102, 102, =
0);">=3D</span><span style=3D"color: rgb(0, 0, 0);"> i</span><span style=3D=
"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"> </=
span><span style=3D"color: rgb(136, 0, 0);">//error</span><span style=3D"co=
lor: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; fn</span><span style=3D"color:=
 rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">i</span><s=
pan style=3D"color: rgb(102, 102, 0);">);</span><span style=3D"color: rgb(0=
, 0, 0);"> </span><span style=3D"color: rgb(136, 0, 0);">//error</span><spa=
n style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; fn</span><span st=
yle=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0)=
;">d</span><span style=3D"color: rgb(102, 102, 0);">);</span><span style=3D=
"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(136, 0, 0);">//fn'=
s body does not inherit explicit</span><span style=3D"color: rgb(0, 0, 0);"=
><br>&nbsp; &nbsp; &nbsp; </span><span style=3D"color: rgb(0, 0, 136);">boo=
l</span><span style=3D"color: rgb(0, 0, 0);"> b </span><span style=3D"color=
: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, 0, 0);"> p</spa=
n><span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rg=
b(0, 0, 0);"><br>&nbsp; &nbsp;</span><span style=3D"color: rgb(102, 102, 0)=
;">}</span><span style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"c=
olor: rgb(102, 102, 0);">}</span><span style=3D"color: rgb(0, 0, 0);"><br><=
br></span><span style=3D"color: rgb(0, 0, 136);">void</span><span style=3D"=
color: rgb(0, 0, 0);"> test2</span><span style=3D"color: rgb(102, 102, 0);"=
>()</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color=
: rgb(0, 0, 136);">explicit</span><span style=3D"color: rgb(102, 102, 0);">=
;</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: =
rgb(136, 0, 0);">//error for declaration</span><span style=3D"color: rgb(0,=
 0, 0);"><br><br></span><span style=3D"color: rgb(136, 0, 0);">//some short=
hand ways to declar explicit for blocks</span><span style=3D"color: rgb(0, =
0, 0);"><br></span><span style=3D"color: rgb(0, 0, 136);">void</span><span =
style=3D"color: rgb(0, 0, 0);"> test2</span><span style=3D"color: rgb(102, =
102, 0);">()</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(0, 0, 136);">explicit</span><span style=3D"color: rgb(0, 0, =
0);"> </span><span style=3D"color: rgb(136, 0, 0);">//ok for definition</sp=
an><span style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rg=
b(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &n=
bsp;</span><span style=3D"color: rgb(0, 0, 136);">if</span><span style=3D"c=
olor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">(</sp=
an><span style=3D"color: rgb(0, 0, 0);">condition</span><span style=3D"colo=
r: rgb(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"> </span>=
<span style=3D"color: rgb(0, 0, 136);">explicit</span><span style=3D"color:=
 rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">{</span><s=
pan style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp;</span><span style=3D"c=
olor: rgb(102, 102, 0);">}</span><span style=3D"color: rgb(0, 0, 0);"><br><=
/span><span style=3D"color: rgb(102, 102, 0);">}</span><span style=3D"color=
: rgb(0, 0, 0);"><br></span></div></code></div><div><br></div><div>Maybe (b=
ut not as sure on this one) also for functions as follows:</div><div style=
=3D"border: 1px solid rgb(187, 187, 187); border-image: none; background-co=
lor: rgb(250, 250, 250);"><code><div><span style=3D"color: rgb(0, 0, 136);"=
>explicit</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D=
"color: rgb(0, 0, 136);">void</span><span style=3D"color: rgb(0, 0, 0);"> f=
n</span><span style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"col=
or: rgb(0, 0, 136);">double</span><span style=3D"color: rgb(0, 0, 0);"> d</=
span><span style=3D"color: rgb(102, 102, 0);">)</span><span style=3D"color:=
 rgb(0, 0, 0);"> </span><span style=3D"color: rgb(136, 0, 0);">//this expli=
cit applies to function params not the body</span><span style=3D"color: rgb=
(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 102, 0);">{</span><sp=
an style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102,=
 102, 0);">}</span><span style=3D"color: rgb(0, 0, 0);"><br><br></span><spa=
n style=3D"color: rgb(0, 0, 136);">void</span><span style=3D"color: rgb(0, =
0, 0);"> test</span><span style=3D"color: rgb(102, 102, 0);">()</span><span=
 style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 1=
02, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp;</sp=
an><span style=3D"color: rgb(0, 0, 136);">int</span><span style=3D"color: r=
gb(0, 0, 0);"> i </span><span style=3D"color: rgb(102, 102, 0);">=3D</span>=
<span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 1=
02, 102);">1</span><span style=3D"color: rgb(102, 102, 0);">;</span><span s=
tyle=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp;fn</span><span style=3D"colo=
r: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">i</span>=
<span style=3D"color: rgb(102, 102, 0);">);</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(136, 0, 0);">//error</span><s=
pan style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102=
, 102, 0);">}</span><span><font color=3D"#888888"><span style=3D"color: rgb=
(0, 0, 0);"><br></span></font></span></div></code></div><span><font color=
=3D"#888888"><div><br></div><div><br></div></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 onmousedown=3D"this.href=3D'javascript:';return true;" onclick=
=3D"this.href=3D'javascript:';return true;" href=3D"javascript:" target=3D"=
_blank" rel=3D"nofollow" gdf-obfuscated-mailto=3D"LJ6BOUv_xy8J">std-proposa=
l...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a onmousedown=3D"this.href=3D'javascr=
ipt:';return true;" onclick=3D"this.href=3D'javascript:';return true;" href=
=3D"javascript:" target=3D"_blank" rel=3D"nofollow" gdf-obfuscated-mailto=
=3D"LJ6BOUv_xy8J">std-pr...@isocpp.org</a>.<br>
Visit this group at <a onmousedown=3D"this.href=3D'http://groups.google.com=
/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"this.href=3D'h=
ttp://groups.google.com/a/isocpp.org/group/std-proposals/';return true;" hr=
ef=3D"http://groups.google.com/a/isocpp.org/group/std-proposals/" target=3D=
"_blank" rel=3D"nofollow">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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1861_447995356.1432139539387--
------=_Part_1860_845629486.1432139539387--

.


Author: =?UTF-8?Q?Klaim_=2D_Jo=C3=ABl_Lamotte?= <mjklaim@gmail.com>
Date: Wed, 20 May 2015 20:01:46 +0200
Raw View
--f46d0444ef416dbbe205168738d7
Content-Type: text/plain; charset=UTF-8

On Wed, May 20, 2015 at 6:11 PM, Michael Boyko <mboyko2000@gmail.com> wrote:

> An explicit block would be a way to write code where implicit conversions
> would not be generated. For example:
>
> void fn(double d) {...}
>
> void test()
> {
>    int i = 1;
>    double d = 2.0;
>    auto p = make_unique<int>(0);
>
>    explicit {
>       d = i; //error
>       fn(i); //error
>       fn(d); //fn's body does not inherit explicit
>       bool b = p;
>    }
> }
>
> void test2() explicit; //error for declaration
>
> //some shorthand ways to declar explicit for blocks
> void test2() explicit //ok for definition
> {
>    if (condition) explicit {
>    }
> }
>
> Maybe (but not as sure on this one) also for functions as follows:
> explicit void fn(double d) //this explicit applies to function params not
> the body
> {
> }
>
> void test()
> {
>    int i = 1;
>    fn(i); //error
> }
>
>

I have thought of similar features before, both for explicit conversion and
const-ness.
I believe that a scoped or unscoped directive  would be far better because
it would make possible to
force const-ness or explicit-ness to a whole file.
For example, let's say that we are using the "using" directive:

// somefile.cpp

#include <blahblah>

using explict; // Any converting instruction after this point in the
current scope
                    // follows explicit casting rules by default.
using const; // Any object defined after this point in the current scope
                   //is const by default.

void foo(Object& object, double k) // args are not objects defined here, so
object is not a const ref
{
    Object w = object.bar(); // w is const
    int u = k; // error
}


I'm assuming here that if these using were in a class, only members of the
class would be affected.
If they were in a function definition, only code inside the function body
would be affected.

Of course:

 1. it would require a way to specify when to allow implicit casts;
 2. it would require a way to specify that an object is not const -
mutable?;
 3. Having a namespace-scoped using directive in a header would be as
problematic as currently,
     but I believe that it would trigger obvious enough errors to be
detected early and continue
     to be considered bad practice.

--

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

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

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Wed, May 20, 2015 at 6:11 PM, Michael Boyko <span dir=3D"ltr">&lt;<a=
 href=3D"mailto:mboyko2000@gmail.com" target=3D"_blank">mboyko2000@gmail.co=
m</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">=
<div>An explicit block would be a way to write code where implicit conversi=
ons would not be generated. For example:</div><div><br></div><div style=3D"=
border:1px solid rgb(187,187,187);background-color:rgb(250,250,250)"><code>=
<div><span style=3D"color:rgb(0,0,136)">void</span><span style=3D"color:rgb=
(0,0,0)"> fn</span><span style=3D"color:rgb(102,102,0)">(</span><span style=
=3D"color:rgb(0,0,136)">double</span><span style=3D"color:rgb(0,0,0)"> d</s=
pan><span style=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(0=
,0,0)"> </span><span style=3D"color:rgb(102,102,0)">{...}</span><span style=
=3D"color:rgb(0,0,0)"><br><br></span><span style=3D"color:rgb(0,0,136)">voi=
d</span><span style=3D"color:rgb(0,0,0)"> test</span><span style=3D"color:r=
gb(102,102,0)">()</span><span style=3D"color:rgb(0,0,0)"><br></span><span s=
tyle=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>=
=C2=A0 =C2=A0</span><span style=3D"color:rgb(0,0,136)">int</span><span styl=
e=3D"color:rgb(0,0,0)"> i </span><span style=3D"color:rgb(102,102,0)">=3D</=
span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,10=
2,102)">1</span><span style=3D"color:rgb(102,102,0)">;</span><span style=3D=
"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0</span><span style=3D"color:rgb(0,0,136=
)">double</span><span style=3D"color:rgb(0,0,0)"> d </span><span style=3D"c=
olor:rgb(102,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> </span><sp=
an style=3D"color:rgb(0,102,102)">2.0</span><span style=3D"color:rgb(102,10=
2,0)">;</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0</span><spa=
n style=3D"color:rgb(0,0,136)">auto</span><span style=3D"color:rgb(0,0,0)">=
 p </span><span style=3D"color:rgb(102,102,0)">=3D</span><span style=3D"col=
or:rgb(0,0,0)"> make_unique</span><span style=3D"color:rgb(0,136,0)">&lt;in=
t&gt;</span><span style=3D"color:rgb(102,102,0)">(</span><span style=3D"col=
or:rgb(0,102,102)">0</span><span style=3D"color:rgb(102,102,0)">);</span><s=
pan style=3D"color:rgb(0,0,0)"><br><br>=C2=A0 =C2=A0</span><span style=3D"c=
olor:rgb(0,0,136)">explicit</span><span style=3D"color:rgb(0,0,0)"> </span>=
<span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0=
)"><br>=C2=A0 =C2=A0 =C2=A0 d </span><span style=3D"color:rgb(102,102,0)">=
=3D</span><span style=3D"color:rgb(0,0,0)"> i</span><span style=3D"color:rg=
b(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(136,0,0)">//error</span><span style=3D"color:rgb(0,0,0)"><br>=
=C2=A0 =C2=A0 =C2=A0 fn</span><span style=3D"color:rgb(102,102,0)">(</span>=
<span style=3D"color:rgb(0,0,0)">i</span><span style=3D"color:rgb(102,102,0=
)">);</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:r=
gb(136,0,0)">//error</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=
=A0 =C2=A0 fn</span><span style=3D"color:rgb(102,102,0)">(</span><span styl=
e=3D"color:rgb(0,0,0)">d</span><span style=3D"color:rgb(102,102,0)">);</spa=
n><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0,0=
)">//fn&#39;s body does not inherit explicit</span><span style=3D"color:rgb=
(0,0,0)"><br>=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)"=
>bool</span><span style=3D"color:rgb(0,0,0)"> b </span><span style=3D"color=
:rgb(102,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> p</span><span =
style=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br=
>=C2=A0 =C2=A0</span><span style=3D"color:rgb(102,102,0)">}</span><span sty=
le=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(102,102,0)">}</=
span><span style=3D"color:rgb(0,0,0)"><br><br></span><span style=3D"color:r=
gb(0,0,136)">void</span><span style=3D"color:rgb(0,0,0)"> test2</span><span=
 style=3D"color:rgb(102,102,0)">()</span><span style=3D"color:rgb(0,0,0)"> =
</span><span style=3D"color:rgb(0,0,136)">explicit</span><span style=3D"col=
or:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"> </span><span s=
tyle=3D"color:rgb(136,0,0)">//error for declaration</span><span style=3D"co=
lor:rgb(0,0,0)"><br><br></span><span style=3D"color:rgb(136,0,0)">//some sh=
orthand ways to declar explicit for blocks</span><span style=3D"color:rgb(0=
,0,0)"><br></span><span style=3D"color:rgb(0,0,136)">void</span><span style=
=3D"color:rgb(0,0,0)"> test2</span><span style=3D"color:rgb(102,102,0)">()<=
/span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0=
,136)">explicit</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(136,0,0)">//ok for definition</span><span style=3D"color:rgb(=
0,0,0)"><br></span><span style=3D"color:rgb(102,102,0)">{</span><span style=
=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0</span><span style=3D"color:rgb(0,0,=
136)">if</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"colo=
r:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">condition</span>=
<span style=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(0,0,0=
)"> </span><span style=3D"color:rgb(0,0,136)">explicit</span><span style=3D=
"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">{</span><sp=
an style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0</span><span style=3D"color:=
rgb(102,102,0)">}</span><span style=3D"color:rgb(0,0,0)"><br></span><span s=
tyle=3D"color:rgb(102,102,0)">}</span><span style=3D"color:rgb(0,0,0)"><br>=
</span></div></code></div><div><br></div><div>Maybe (but not as sure on thi=
s one) also for functions as follows:</div><div style=3D"border:1px solid r=
gb(187,187,187);background-color:rgb(250,250,250)"><code><div><span style=
=3D"color:rgb(0,0,136)">explicit</span><span style=3D"color:rgb(0,0,0)"> </=
span><span style=3D"color:rgb(0,0,136)">void</span><span style=3D"color:rgb=
(0,0,0)"> fn</span><span style=3D"color:rgb(102,102,0)">(</span><span style=
=3D"color:rgb(0,0,136)">double</span><span style=3D"color:rgb(0,0,0)"> d</s=
pan><span style=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(0=
,0,0)"> </span><span style=3D"color:rgb(136,0,0)">//this explicit applies t=
o function params not the body</span><span style=3D"color:rgb(0,0,0)"><br><=
/span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb=
(0,0,0)"><br></span><span style=3D"color:rgb(102,102,0)">}</span><span styl=
e=3D"color:rgb(0,0,0)"><br><br></span><span style=3D"color:rgb(0,0,136)">vo=
id</span><span style=3D"color:rgb(0,0,0)"> test</span><span style=3D"color:=
rgb(102,102,0)">()</span><span style=3D"color:rgb(0,0,0)"><br></span><span =
style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br=
>=C2=A0 =C2=A0</span><span style=3D"color:rgb(0,0,136)">int</span><span sty=
le=3D"color:rgb(0,0,0)"> i </span><span style=3D"color:rgb(102,102,0)">=3D<=
/span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,1=
02,102)">1</span><span style=3D"color:rgb(102,102,0)">;</span><span style=
=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0fn</span><span style=3D"color:rgb(10=
2,102,0)">(</span><span style=3D"color:rgb(0,0,0)">i</span><span style=3D"c=
olor:rgb(102,102,0)">);</span><span style=3D"color:rgb(0,0,0)"> </span><spa=
n style=3D"color:rgb(136,0,0)">//error</span><span style=3D"color:rgb(0,0,0=
)"><br></span><span style=3D"color:rgb(102,102,0)">}</span><span class=3D"H=
OEnZb"><font color=3D"#888888"><span style=3D"color:rgb(0,0,0)"><br></span>=
</font></span></div></code></div><span class=3D"HOEnZb"><font color=3D"#888=
888"><div><br></div></font></span></div></blockquote><div><br></div><div><b=
r></div><div>I have thought of similar features before, both for explicit c=
onversion and const-ness.</div><div>I believe that a scoped or unscoped dir=
ective =C2=A0would be far better because it would make possible to=C2=A0</d=
iv><div>force const-ness or explicit-ness to a whole file.</div><div>For ex=
ample, let&#39;s say that we are using the &quot;using&quot; directive:</di=
v><div><br></div><div>// somefile.cpp</div><div><br></div><div>#include &lt=
;blahblah&gt;</div><div><br></div><div>using explict; // Any converting ins=
truction after this point in the current scope</div><div>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // follows explicit ca=
sting rules by default.</div><div>using const; // Any object defined after =
this point in the current scope=C2=A0</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0//is const by default.</div><div>=
<br></div><div>void foo(Object&amp; object, double k) // args are not objec=
ts defined here, so object is not a const ref</div><div>{</div><div>=C2=A0 =
=C2=A0 Object w =3D object.bar(); // w is const</div><div>=C2=A0 =C2=A0 int=
 u =3D k; // error</div><div>}</div><div><br></div><div><br></div><div>I&#3=
9;m assuming here that if these using were in a class, only members of the =
class would be affected.</div><div>If they were in a function definition, o=
nly code inside the function body would be affected.</div><div><br></div><d=
iv>Of course:</div><div><br></div><div>=C2=A01. it would require a way to s=
pecify when to allow implicit casts;</div><div>=C2=A02. it would require a =
way to specify that an object is not const - mutable?;</div><div>=C2=A03. H=
aving a namespace-scoped using directive in a header would be as problemati=
c as currently,</div><div>=C2=A0 =C2=A0 =C2=A0but I believe that it would t=
rigger obvious enough errors to be detected early and continue=C2=A0</div><=
div>=C2=A0 =C2=A0 =C2=A0to be considered bad practice.</div><div><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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--f46d0444ef416dbbe205168738d7--

.


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Thu, 21 May 2015 12:34:04 +0100
Raw View
Please, keep the explicit qualifier within the body of a function, and
not within the function header=E2=80=94this is a function implementation
restriction, and does not affect the way the function is used (unless
I have totally misunderstood the OP).


On 5/20/15, Klaim - Jo=C3=ABl Lamotte <mjklaim@gmail.com> wrote:
> On Wed, May 20, 2015 at 6:11 PM, Michael Boyko <mboyko2000@gmail.com>
> wrote:
>
>> An explicit block would be a way to write code where implicit conversion=
s
>> would not be generated. For example:
>>
>> void fn(double d) {...}
>>
>> void test()
>> {
>>    int i =3D 1;
>>    double d =3D 2.0;
>>    auto p =3D make_unique<int>(0);
>>
>>    explicit {
>>       d =3D i; //error
>>       fn(i); //error
>>       fn(d); //fn's body does not inherit explicit
>>       bool b =3D p;
>>    }
>> }
>>
>> void test2() explicit; //error for declaration
>>
>> //some shorthand ways to declar explicit for blocks
>> void test2() explicit //ok for definition
>> {
>>    if (condition) explicit {
>>    }
>> }
>>
>> Maybe (but not as sure on this one) also for functions as follows:
>> explicit void fn(double d) //this explicit applies to function params no=
t
>> the body
>> {
>> }
>>
>> void test()
>> {
>>    int i =3D 1;
>>    fn(i); //error
>> }
>>
>>
>
> I have thought of similar features before, both for explicit conversion a=
nd
> const-ness.
> I believe that a scoped or unscoped directive  would be far better becaus=
e
> it would make possible to
> force const-ness or explicit-ness to a whole file.
> For example, let's say that we are using the "using" directive:
>
> // somefile.cpp
>
> #include <blahblah>
>
> using explict; // Any converting instruction after this point in the
> current scope
>                     // follows explicit casting rules by default.
> using const; // Any object defined after this point in the current scope
>                    //is const by default.
>
> void foo(Object& object, double k) // args are not objects defined here, =
so
> object is not a const ref
> {
>     Object w =3D object.bar(); // w is const
>     int u =3D k; // error
> }
>
>
> I'm assuming here that if these using were in a class, only members of th=
e
> class would be affected.
> If they were in a function definition, only code inside the function body
> would be affected.
>
> Of course:
>
>  1. it would require a way to specify when to allow implicit casts;
>  2. it would require a way to specify that an object is not const -
> mutable?;
>  3. Having a namespace-scoped using directive in a header would be as
> problematic as currently,
>      but I believe that it would trigger obvious enough errors to be
> detected early and continue
>      to be considered bad practice.
>
> --
>
> ---
> 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/.

.


Author: Michael Boyko <mboyko2000@gmail.com>
Date: Thu, 21 May 2015 05:55:17 -0700 (PDT)
Raw View
------=_Part_2683_959857789.1432212917985
Content-Type: multipart/alternative;
 boundary="----=_Part_2684_432703459.1432212917985"

------=_Part_2684_432703459.1432212917985
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Thursday, May 21, 2015 at 6:34:05 AM UTC-5, Douglas Boffey wrote:
>
> Please, keep the explicit qualifier within the body of a function, and=20
> not within the function header=E2=80=94this is a function implementation=
=20
> restriction, and does not affect the way the function is used (unless=20
> I have totally misunderstood the OP).=20
>
>
Correct. My intention is that it is an implementation detail of a function=
=20
and is not part of the function signature. One would not be able to=20
overload based on if a function is explicit or not. I only pointed out a=20
shorthand way of specifying explicit function blocks (like a function try=
=20
block). For example:

void fn() explicit {
}


would be identical to:

void fn() {
   explicit {
   }
}

 Basically this follows the function try block style:

void fn() try {
} catch (...) {
}


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

<div dir=3D"ltr"><br><br>On Thursday, May 21, 2015 at 6:34:05 AM UTC-5, Dou=
glas Boffey wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0p=
x 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); bord=
er-left-width: 1px; border-left-style: solid;">Please, keep the explicit qu=
alifier within the body of a function, and
<br>not within the function header=E2=80=94this is a function implementatio=
n
<br>restriction, and does not affect the way the function is used (unless
<br>I have totally misunderstood the OP).
<br><br></blockquote><div><br></div><div>Correct. My intention is that&nbsp=
;it is an implementation detail of a function and is not part of the functi=
on signature. One would not be able to overload&nbsp;based on if a function=
 is&nbsp;explicit or not.&nbsp;I&nbsp;only pointed out a shorthand way of&n=
bsp;specifying explicit function blocks (like a function try block). For&nb=
sp;example:</div><div><br></div><div class=3D"prettyprint" style=3D"border:=
 1px solid rgb(187, 187, 187); border-image: none; -ms-word-wrap: break-wor=
d; background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div =
class=3D"subprettyprint"><span class=3D"styled-by-prettify" style=3D"color:=
 rgb(0, 0, 136);">void</span><span class=3D"styled-by-prettify" style=3D"co=
lor: rgb(0, 0, 0);"> fn</span><span class=3D"styled-by-prettify" style=3D"c=
olor: rgb(102, 102, 0);">()</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 136);">explicit</span><span class=3D"styled-by-prettif=
y" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(102, 102, 0);">{</span><span class=3D"styled-by-prett=
ify" style=3D"color: rgb(0, 0, 0);"><br></span><span class=3D"styled-by-pre=
ttify" style=3D"color: rgb(102, 102, 0);">}</span></div></code></div><div><=
br></div><div><br></div><div>would be identical to:</div><div><br></div><di=
v class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); bord=
er-image: none; -ms-word-wrap: break-word; background-color: rgb(250, 250, =
250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span clas=
s=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">void</span><span =
class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> fn</span><span=
 class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">()</span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><s=
pan class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">{</span=
><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbs=
p; &nbsp;</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0=
, 136);">explicit</span><span class=3D"styled-by-prettify" style=3D"color: =
rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: r=
gb(102, 102, 0);">{</span><span class=3D"styled-by-prettify" style=3D"color=
: rgb(0, 0, 0);"><br>&nbsp; &nbsp;</span><span class=3D"styled-by-prettify"=
 style=3D"color: rgb(102, 102, 0);">}</span><span class=3D"styled-by-pretti=
fy" style=3D"color: rgb(0, 0, 0);"><br></span><span class=3D"styled-by-pret=
tify" style=3D"color: rgb(102, 102, 0);">}</span></div></code></div><div><b=
r></div><div>&nbsp;Basically this follows the function try block style:</di=
v><div><br></div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(=
187, 187, 187); border-image: none; -ms-word-wrap: break-word; background-c=
olor: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subpre=
ttyprint"><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136)=
;">void</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, =
0);"> fn</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, =
102, 0);">()</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0=
, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(0,=
 0, 136);">try</span><span class=3D"styled-by-prettify" style=3D"color: rgb=
(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(=
102, 102, 0);">{</span><span class=3D"styled-by-prettify" style=3D"color: r=
gb(0, 0, 0);"><br></span><span class=3D"styled-by-prettify" style=3D"color:=
 rgb(102, 102, 0);">}</span><span class=3D"styled-by-prettify" style=3D"col=
or: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"colo=
r: rgb(0, 0, 136);">catch</span><span class=3D"styled-by-prettify" style=3D=
"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"=
color: rgb(102, 102, 0);">(...)</span><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" sty=
le=3D"color: rgb(102, 102, 0);">{</span><span class=3D"styled-by-prettify" =
style=3D"color: rgb(0, 0, 0);"><br></span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(102, 102, 0);">}</span></div></code></div><div><br></=
div><div><br></div><div>&nbsp;</div></div>

<p></p>

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

------=_Part_2684_432703459.1432212917985--
------=_Part_2683_959857789.1432212917985--

.


Author: Igor Baidiuk <target.san@gmail.com>
Date: Thu, 21 May 2015 11:14:12 -0700 (PDT)
Raw View
------=_Part_12_1446499127.1432232052924
Content-Type: multipart/alternative;
 boundary="----=_Part_13_1795943449.1432232052924"

------=_Part_13_1795943449.1432232052924
Content-Type: text/plain; charset=UTF-8

Sorry if I missed something, but what problem does this solve? Is this
problem so common? Can't it be solved by other means?

On Wednesday, May 20, 2015 at 7:11:23 PM UTC+3, Michael Boyko wrote:
>
> An explicit block would be a way to write code where implicit conversions
> would not be generated. For example:
>
> void fn(double d) {...}
>
> void test()
> {
>    int i = 1;
>    double d = 2.0;
>    auto p = make_unique<int>(0);
>
>    explicit {
>       d = i; //error
>       fn(i); //error
>       fn(d); //fn's body does not inherit explicit
>       bool b = p;
>    }
> }
>
> void test2() explicit; //error for declaration
>
> //some shorthand ways to declar explicit for blocks
> void test2() explicit //ok for definition
> {
>    if (condition) explicit {
>    }
> }
>
> Maybe (but not as sure on this one) also for functions as follows:
> explicit void fn(double d) //this explicit applies to function params not
> the body
> {
> }
>
> void test()
> {
>    int i = 1;
>    fn(i); //error
> }
>
>
>

--

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

<div dir=3D"ltr">Sorry if I missed something, but what problem does this so=
lve? Is this problem so common? Can't it be solved by other means?<br><br>O=
n Wednesday, May 20, 2015 at 7:11:23 PM UTC+3, Michael Boyko wrote:<blockqu=
ote 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>An explicit bloc=
k would be a way to write code where implicit conversions would not be gene=
rated. For example:</div><div><br></div><div style=3D"border:1px solid rgb(=
187,187,187);background-color:rgb(250,250,250)"><code><div><span style=3D"c=
olor:rgb(0,0,136)">void</span><span style=3D"color:rgb(0,0,0)"> fn</span><s=
pan style=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,136=
)">double</span><span style=3D"color:rgb(0,0,0)"> d</span><span style=3D"co=
lor:rgb(102,102,0)">)</span><span style=3D"color:rgb(0,0,0)"> </span><span =
style=3D"color:rgb(102,102,0)">{...}</span><span style=3D"color:rgb(0,0,0)"=
><br><br></span><span style=3D"color:rgb(0,0,136)">void</span><span style=
=3D"color:rgb(0,0,0)"> test</span><span style=3D"color:rgb(102,102,0)">()</=
span><span style=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(1=
02,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>&nbsp; &nbsp;</span=
><span style=3D"color:rgb(0,0,136)">int</span><span style=3D"color:rgb(0,0,=
0)"> i </span><span style=3D"color:rgb(102,102,0)">=3D</span><span style=3D=
"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,102,102)">1</span><sp=
an style=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)">=
<br>&nbsp; &nbsp;</span><span style=3D"color:rgb(0,0,136)">double</span><sp=
an style=3D"color:rgb(0,0,0)"> d </span><span style=3D"color:rgb(102,102,0)=
">=3D</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:r=
gb(0,102,102)">2.0</span><span style=3D"color:rgb(102,102,0)">;</span><span=
 style=3D"color:rgb(0,0,0)"><br>&nbsp; &nbsp;</span><span style=3D"color:rg=
b(0,0,136)">auto</span><span style=3D"color:rgb(0,0,0)"> p </span><span sty=
le=3D"color:rgb(102,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> mak=
e_unique</span><span style=3D"color:rgb(0,136,0)">&lt;int&gt;</span><span s=
tyle=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,102,102)">=
0</span><span style=3D"color:rgb(102,102,0)">);</span><span style=3D"color:=
rgb(0,0,0)"><br><br>&nbsp; &nbsp;</span><span style=3D"color:rgb(0,0,136)">=
explicit</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"colo=
r:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>&nbsp; &nbsp=
; &nbsp; d </span><span style=3D"color:rgb(102,102,0)">=3D</span><span styl=
e=3D"color:rgb(0,0,0)"> i</span><span style=3D"color:rgb(102,102,0)">;</spa=
n><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0,0=
)">//error</span><span style=3D"color:rgb(0,0,0)"><br>&nbsp; &nbsp; &nbsp; =
fn</span><span style=3D"color:rgb(102,102,0)">(</span><span style=3D"color:=
rgb(0,0,0)">i</span><span style=3D"color:rgb(102,102,0)">);</span><span sty=
le=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0,0)">//error<=
/span><span style=3D"color:rgb(0,0,0)"><br>&nbsp; &nbsp; &nbsp; fn</span><s=
pan style=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)"=
>d</span><span style=3D"color:rgb(102,102,0)">);</span><span style=3D"color=
:rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0,0)">//fn's body does no=
t inherit explicit</span><span style=3D"color:rgb(0,0,0)"><br>&nbsp; &nbsp;=
 &nbsp; </span><span style=3D"color:rgb(0,0,136)">bool</span><span style=3D=
"color:rgb(0,0,0)"> b </span><span style=3D"color:rgb(102,102,0)">=3D</span=
><span style=3D"color:rgb(0,0,0)"> p</span><span style=3D"color:rgb(102,102=
,0)">;</span><span style=3D"color:rgb(0,0,0)"><br>&nbsp; &nbsp;</span><span=
 style=3D"color:rgb(102,102,0)">}</span><span style=3D"color:rgb(0,0,0)"><b=
r></span><span style=3D"color:rgb(102,102,0)">}</span><span style=3D"color:=
rgb(0,0,0)"><br><br></span><span style=3D"color:rgb(0,0,136)">void</span><s=
pan style=3D"color:rgb(0,0,0)"> test2</span><span style=3D"color:rgb(102,10=
2,0)">()</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"colo=
r:rgb(0,0,136)">explicit</span><span style=3D"color:rgb(102,102,0)">;</span=
><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0,0)=
">//error for declaration</span><span style=3D"color:rgb(0,0,0)"><br><br></=
span><span style=3D"color:rgb(136,0,0)">//some shorthand ways to declar exp=
licit for blocks</span><span style=3D"color:rgb(0,0,0)"><br></span><span st=
yle=3D"color:rgb(0,0,136)">void</span><span style=3D"color:rgb(0,0,0)"> tes=
t2</span><span style=3D"color:rgb(102,102,0)">()</span><span style=3D"color=
:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">explicit</span><spa=
n style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0,0)">//o=
k for definition</span><span style=3D"color:rgb(0,0,0)"><br></span><span st=
yle=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>&=
nbsp; &nbsp;</span><span style=3D"color:rgb(0,0,136)">if</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">(</span>=
<span style=3D"color:rgb(0,0,0)">condition</span><span style=3D"color:rgb(1=
02,102,0)">)</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"=
color:rgb(0,0,136)">explicit</span><span style=3D"color:rgb(0,0,0)"> </span=
><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,=
0)"><br>&nbsp; &nbsp;</span><span style=3D"color:rgb(102,102,0)">}</span><s=
pan style=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(102,102,=
0)">}</span><span style=3D"color:rgb(0,0,0)"><br></span></div></code></div>=
<div><br></div><div>Maybe (but not as sure on this one) also for functions =
as follows:</div><div style=3D"border:1px solid rgb(187,187,187);background=
-color:rgb(250,250,250)"><code><div><span style=3D"color:rgb(0,0,136)">expl=
icit</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rg=
b(0,0,136)">void</span><span style=3D"color:rgb(0,0,0)"> fn</span><span sty=
le=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,136)">doub=
le</span><span style=3D"color:rgb(0,0,0)"> d</span><span style=3D"color:rgb=
(102,102,0)">)</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(136,0,0)">//this explicit applies to function params not the =
body</span><span style=3D"color:rgb(0,0,0)"><br></span><span style=3D"color=
:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br></span><span =
style=3D"color:rgb(102,102,0)">}</span><span style=3D"color:rgb(0,0,0)"><br=
><br></span><span style=3D"color:rgb(0,0,136)">void</span><span style=3D"co=
lor:rgb(0,0,0)"> test</span><span style=3D"color:rgb(102,102,0)">()</span><=
span style=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(102,102=
,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>&nbsp; &nbsp;</span><span=
 style=3D"color:rgb(0,0,136)">int</span><span style=3D"color:rgb(0,0,0)"> i=
 </span><span style=3D"color:rgb(102,102,0)">=3D</span><span style=3D"color=
:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,102,102)">1</span><span sty=
le=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br>&n=
bsp; &nbsp;fn</span><span style=3D"color:rgb(102,102,0)">(</span><span styl=
e=3D"color:rgb(0,0,0)">i</span><span style=3D"color:rgb(102,102,0)">);</spa=
n><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0,0=
)">//error</span><span style=3D"color:rgb(0,0,0)"><br></span><span style=3D=
"color:rgb(102,102,0)">}</span><span style=3D"color:rgb(0,0,0)"><br></span>=
</div></code></div><div><br></div><div><br></div></div></blockquote></div>

<p></p>

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

------=_Part_13_1795943449.1432232052924--
------=_Part_12_1446499127.1432232052924--

.


Author: Michael Boyko <mboyko2000@gmail.com>
Date: Thu, 21 May 2015 13:04:04 -0700 (PDT)
Raw View
------=_Part_194_269916214.1432238644654
Content-Type: multipart/alternative;
 boundary="----=_Part_195_996346234.1432238644654"

------=_Part_195_996346234.1432238644654
Content-Type: text/plain; charset=UTF-8



On Thursday, May 21, 2015 at 1:14:12 PM UTC-5, Igor Baidiuk wrote:
>
> Sorry if I missed something, but what problem does this solve? Is this
> problem so common? Can't it be solved by other means?
>
>>
>>
I'll point out my personal experience. I've been bit by bugs caused by
implicit conversions generally related to overloaded
function resolution. I'm sure we all have been bit by a bug caused by
narrowing conversions. This would be a tool to control some of these issues.

--

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

<div dir=3D"ltr"><br><br>On Thursday, May 21, 2015 at 1:14:12 PM UTC-5, Igo=
r Baidiuk wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px =
0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border=
-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr">Sorry if I mi=
ssed something, but what problem does this solve? Is this problem so common=
? Can't it be solved by other means?<br><blockquote class=3D"gmail_quote" s=
tyle=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rg=
b(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><div d=
ir=3D"ltr"><div><br></div></div></blockquote></div></blockquote><div><br></=
div><div>I'll point out my personal experience. I've been bit by bugs cause=
d by implicit conversions generally related to overloaded function&nbsp;res=
olution.&nbsp;I'm sure we all have been bit by a bug caused by narrowing co=
nversions. This would be a tool to control some of these issues.</div></div=
>

<p></p>

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

------=_Part_195_996346234.1432238644654--
------=_Part_194_269916214.1432238644654--

.


Author: David Krauss <potswa@mac.com>
Date: Fri, 22 May 2015 10:03:27 +0800
Raw View
--Apple-Mail=_0CEC1D9B-C824-4840-B3E0-BF24BC381DB6
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9305=E2=80=9322, at 4:04 AM, Michael Boyko <mboyko2000@gmai=
l.com> wrote:
>=20
> I'll point out my personal experience. I've been bit by bugs caused by im=
plicit conversions generally related to overloaded function resolution.=20

Make user-defined conversions explicit unless implicitness is necessary.

Any necessary implicit conversions would render the explicit block useless.=
 Therefore it would only be useful to perpetuate interfaces that are broken=
..

> I'm sure we all have been bit by a bug caused by narrowing conversions.

Use braces to control narrowing conversions.

long a =3D x;
int b {a}; // Error

It even works in function arguments:

void f( int );
f({ 5.0 }); // OK
f({ 5.2 }); // Error

If this is unpalatable, at least use -Wnarrowing.

--=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=_0CEC1D9B-C824-4840-B3E0-BF24BC381DB6
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=9305=
=E2=80=9322, at 4:04 AM, Michael Boyko &lt;<a href=3D"mailto:mboyko2000@gma=
il.com" class=3D"">mboyko2000@gmail.com</a>&gt; wrote:</div><br class=3D"Ap=
ple-interchange-newline"><div class=3D""><div dir=3D"ltr" class=3D"">I'll p=
oint out my personal experience. I've been bit by bugs caused by implicit c=
onversions generally related to overloaded function&nbsp;resolution.&nbsp;<=
/div></div></blockquote><div><br class=3D""></div><div>Make user-defined co=
nversions explicit unless implicitness is necessary.</div><div><br class=3D=
""></div><div>Any necessary implicit conversions would render the <font fac=
e=3D"Courier" class=3D"">explicit</font> block useless. Therefore it would =
only be useful to perpetuate interfaces that are broken.</div><div><br clas=
s=3D""></div><blockquote type=3D"cite" class=3D""><div class=3D""><div dir=
=3D"ltr" class=3D""><div class=3D"">I'm sure we all have been bit by a bug =
caused by narrowing conversions.</div></div></div></blockquote><div><br cla=
ss=3D""></div><div>Use braces to control narrowing conversions.</div><div><=
br class=3D""></div><div><font face=3D"Courier" class=3D"">long a =3D x;</f=
ont></div><div><font face=3D"Courier" class=3D"">int b {a}; // Error</font>=
</div><div><br class=3D""></div><div>It even works in function arguments:</=
div><div><br class=3D""></div><div><font face=3D"Courier" class=3D"">void f=
( int );<br class=3D"">f({ 5.0 }); // OK<br class=3D"">f({ 5.2 }); // Error=
</font><br class=3D""></div><div><font face=3D"Courier" class=3D""><br clas=
s=3D""></font></div><div>If this is unpalatable, at least use <font face=3D=
"Courier" class=3D"">-Wnarrowing</font>.</div></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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--Apple-Mail=_0CEC1D9B-C824-4840-B3E0-BF24BC381DB6--

.


Author: David Krauss <potswa@mac.com>
Date: Fri, 22 May 2015 10:45:24 +0800
Raw View
--Apple-Mail=_8B5C248C-7FAD-4161-91F9-AC14D066B714
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9305=E2=80=9322, at 10:03 AM, David Krauss <potswa@mac.com>=
 wrote:
>=20
> f({ 5.0 }); // OK

Oops, this is an error. I was thinking of the exemption for exact represent=
ation, but that doesn=E2=80=99t apply to floating-integral conversions.

f({ 5L }) would be OK.

--=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=_8B5C248C-7FAD-4161-91F9-AC14D066B714
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=9305=
=E2=80=9322, at 10:03 AM, David Krauss &lt;<a href=3D"mailto:potswa@mac.com=
" class=3D"">potswa@mac.com</a>&gt; wrote:</div><br class=3D"Apple-intercha=
nge-newline"><div class=3D""><span style=3D"font-family: Courier; font-size=
: 12px; font-style: normal; font-variant: normal; font-weight: normal; lett=
er-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; float: none; display: in=
line !important;" class=3D"">f({ 5.0 }); // OK</span><br class=3D"" style=
=3D"font-family: Courier; 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-w=
idth: 0px;"></div></blockquote></div><br class=3D""><div class=3D"">Oops, t=
his is an error. I was thinking of the exemption for exact representation, =
but that doesn=E2=80=99t apply to floating-integral conversions.</div><div =
class=3D""><br class=3D""></div><div class=3D""><font face=3D"Courier" clas=
s=3D"">f({ 5L })</font> would be OK.</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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--Apple-Mail=_8B5C248C-7FAD-4161-91F9-AC14D066B714--

.


Author: Michael Boyko <mboyko2000@gmail.com>
Date: Fri, 22 May 2015 07:38:34 -0700 (PDT)
Raw View
------=_Part_111_1223806017.1432305514874
Content-Type: multipart/alternative;
 boundary="----=_Part_112_2056840400.1432305514874"

------=_Part_112_2056840400.1432305514874
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Thursday, May 21, 2015 at 9:45:34 PM UTC-5, David Krauss wrote:
>
>
> On 2015=E2=80=9305=E2=80=9322, at 10:03 AM, David Krauss <pot...@mac.com =
<javascript:>>=20
> wrote:
>
> f({ 5.0 }); // OK
>
>
> Oops, this is an error. I was thinking of the exemption for exact=20
> representation, but that doesn=E2=80=99t apply to floating-integral conve=
rsions.
>
> f({ 5L }) would be OK.
>

Good advice for sure. But throw in some messy template functions and=20
classes and now you don't even know if the type has a conversion operator=
=20
or not. Maybe concepts will help in those cases - not sure. Just seem like=
=20
it would be nice to not generate implicit conversions in some places.
=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_112_2056840400.1432305514874
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Thursday, May 21, 2015 at 9:45:34 PM UTC-5, Dav=
id Krauss wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px =
0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border=
-left-width: 1px; border-left-style: solid;"><div style=3D"-ms-word-wrap: b=
reak-word;"><br><div><blockquote type=3D"cite"><div>On 2015=E2=80=9305=E2=
=80=9322, at 10:03 AM, David Krauss &lt;<a onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;" h=
ref=3D"javascript:" target=3D"_blank" rel=3D"nofollow" gdf-obfuscated-mailt=
o=3D"35g50sU_FXAJ">pot...@mac.com</a>&gt; wrote:</div><br><div><span style=
=3D"font: 12px/normal Courier; text-transform: none; text-indent: 0px; lett=
er-spacing: normal; word-spacing: 0px; float: none; display: inline !import=
ant; white-space: normal; font-size-adjust: none; font-stretch: normal;">f(=
{ 5.0 }); // OK</span><br style=3D"font: 12px/normal Courier; text-transfor=
m: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white=
-space: normal; font-size-adjust: none; font-stretch: normal;"></div></bloc=
kquote></div><br><div>Oops, this is an error. I was thinking of the exempti=
on for exact representation, but that doesn=E2=80=99t apply to floating-int=
egral conversions.</div><div><br></div><div><font face=3D"Courier">f({ 5L }=
)</font> would be OK.</div></div></blockquote><div><br></div><div>Good advi=
ce for sure. But throw in some messy template functions and classes&nbsp;an=
d now you don't even know if the type has a conversion operator or not.&nbs=
p;Maybe concepts will help in those cases - not sure. Just seem like it wou=
ld be&nbsp;nice to&nbsp;not generate&nbsp;implicit conversions in some plac=
es.</div><div>&nbsp;</div></div>

<p></p>

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

------=_Part_112_2056840400.1432305514874--
------=_Part_111_1223806017.1432305514874--

.