Topic: Private default function arguments and Private


Author: NDos Dannyu <ndospark320@naver.com>
Date: Mon, 30 Jan 2017 23:36:25 -0800 (PST)
Raw View
------=_Part_6651_1360511367.1485848185713
Content-Type: multipart/alternative;
 boundary="----=_Part_6652_948459534.1485848185714"

------=_Part_6652_948459534.1485848185714
Content-Type: text/plain; charset=UTF-8

*#1. Private default function arguments*
This should be convenient for recursive functions. For example from C++
Reference:
(*conststr* is literal string type.)

constexpr std::size_t <http://en.cppreference.com/w/cpp/types/size_t> countlower(conststr s, std::size_t <http://en.cppreference.com/w/cpp/types/size_t> n = 0,
                                             std::size_t <http://en.cppreference.com/w/cpp/types/size_t> c = 0){
    return n == s.size()? c :
           'a' <= s[n] && s[n] <= 'z'? countlower(s, n + 1, c + 1) :
                                       countlower(s, n + 1, c);}


Not calling this function with the default function arguments would be a
nonsense. Furthermore, the type of *&countlower* would be expected to be *size::size_t
(*)(conststr)*, judging by its interface, but it is not.

So what if only *countlower* could not call itself with the default
function arguments? The syntax for this would be:

constexpr std::size_t <http://en.cppreference.com/w/cpp/types/size_t> countlower(conststr s, private std::size_t <http://en.cppreference.com/w/cpp/types/size_t> n = 0,
                                             private std::size_t <http://en.cppreference.com/w/cpp/types/size_t> c = 0){
    return n == s.size()? c :
           'a' <= s[n] && s[n] <= 'z'? countlower(s, n + 1, c + 1) :
                                       countlower(s, n + 1, c);}


In other words, *countlower* is the only one that knows the presence of *n* and
*c*. And so the type of *&countlower* would be *size::size_t (*)(conststr)*.

This should also be convenient for SFINAE:

template<int I> void div(private char(*)[I % 2 == 0] = 0) {
    // this overload is selected when I is even}template<int I> void div(private char(*)[I % 2 == 1] = 0) {
    // this overload is selected  when I is odd}


*#2. Private** default template arguments*

Likewise, the class/function/variable template must be the only one that
knows the presence of their private default template arguments. For example:

template<class T,
 typename = std::enable_if_t<std::is_array <http://en.cppreference.com/w/cpp/types/is_array><T>::value> >void destroy(T* t){
    for(std::size_t <http://en.cppreference.com/w/cpp/types/size_t> i = 0; i < std::extent <http://en.cppreference.com/w/cpp/types/extent><T>::value; ++i) {
        destroy((*t)[i]);
    }}


Explicitly not calling this function with the default template argument
will bypass SFINAE. It must be private.

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/8a0fd64c-6e8a-4e31-a334-d55bd1811a49%40isocpp.org.

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

<div dir=3D"ltr"><b>#1. Private default function arguments</b><div>This sho=
uld be convenient for recursive functions. For example from C++ Reference:<=
/div><div>(<b>conststr</b> is literal string type.)</div><div><pre class=3D=
"de1" style=3D"border-style: none; border-color: white; color: rgb(0, 0, 0)=
; background: none rgb(249, 249, 249); line-height: 1.2em; border-radius: 5=
px; width: 55em; overflow: auto; font-stretch: normal; font-size: 12.8px; v=
ertical-align: top;"><span class=3D"kw4" style=3D"color: rgb(0, 0, 255);">c=
onstexpr</span> <a href=3D"http://en.cppreference.com/w/cpp/types/size_t" s=
tyle=3D"color: rgb(0, 48, 128); background: none;"><span class=3D"kw100">st=
d::<span class=3D"me2">size_t</span></span></a> countlower<span class=3D"br=
0" style=3D"color: rgb(0, 128, 0);">(</span>conststr s, <a href=3D"http://e=
n.cppreference.com/w/cpp/types/size_t" style=3D"color: rgb(0, 48, 128); bac=
kground: none;"><span class=3D"kw100">std::<span class=3D"me2">size_t</span=
></span></a> n <span class=3D"sy1" style=3D"color: rgb(0, 0, 128);">=3D</sp=
an> <span class=3D"nu0" style=3D"color: rgb(0, 0, 128);">0</span>,
                                             <a href=3D"http://en.cpprefere=
nce.com/w/cpp/types/size_t" style=3D"color: rgb(0, 48, 128); background: no=
ne;"><span class=3D"kw100">std::<span class=3D"me2">size_t</span></span></a=
> c <span class=3D"sy1" style=3D"color: rgb(0, 0, 128);">=3D</span> <span c=
lass=3D"nu0" style=3D"color: rgb(0, 0, 128);">0</span><span class=3D"br0" s=
tyle=3D"color: rgb(0, 128, 0);">)</span>
<span class=3D"br0" style=3D"color: rgb(0, 128, 0);">{</span>
    <span class=3D"kw1" style=3D"color: rgb(0, 0, 221);">return</span> n <s=
pan class=3D"sy1" style=3D"color: rgb(0, 0, 128);">=3D=3D</span> s.<span cl=
ass=3D"me1">size</span><span class=3D"br0" style=3D"color: rgb(0, 128, 0);"=
>(</span><span class=3D"br0" style=3D"color: rgb(0, 128, 0);">)</span><span=
 class=3D"sy4" style=3D"color: rgb(0, 128, 128);">?</span> c <span class=3D=
"sy4" style=3D"color: rgb(0, 128, 128);">:</span>
           <span class=3D"st0" style=3D"color: rgb(0, 128, 0);">&#39;a&#39;=
</span> <span class=3D"sy1" style=3D"color: rgb(0, 0, 128);">&lt;=3D</span>=
 s<span class=3D"br0" style=3D"color: rgb(0, 128, 0);">[</span>n<span class=
=3D"br0" style=3D"color: rgb(0, 128, 0);">]</span> <span class=3D"sy3" styl=
e=3D"color: rgb(0, 0, 64);">&amp;&amp;</span> s<span class=3D"br0" style=3D=
"color: rgb(0, 128, 0);">[</span>n<span class=3D"br0" style=3D"color: rgb(0=
, 128, 0);">]</span> <span class=3D"sy1" style=3D"color: rgb(0, 0, 128);">&=
lt;=3D</span> <span class=3D"st0" style=3D"color: rgb(0, 128, 0);">&#39;z&#=
39;</span><span class=3D"sy4" style=3D"color: rgb(0, 128, 128);">?</span> c=
ountlower<span class=3D"br0" style=3D"color: rgb(0, 128, 0);">(</span>s, n =
<span class=3D"sy2" style=3D"color: rgb(0, 0, 64);">+</span> <span class=3D=
"nu0" style=3D"color: rgb(0, 0, 128);">1</span>, c <span class=3D"sy2" styl=
e=3D"color: rgb(0, 0, 64);">+</span> <span class=3D"nu0" style=3D"color: rg=
b(0, 0, 128);">1</span><span class=3D"br0" style=3D"color: rgb(0, 128, 0);"=
>)</span> <span class=3D"sy4" style=3D"color: rgb(0, 128, 128);">:</span>
                                       countlower<span class=3D"br0" style=
=3D"color: rgb(0, 128, 0);">(</span>s, n <span class=3D"sy2" style=3D"color=
: rgb(0, 0, 64);">+</span> <span class=3D"nu0" style=3D"color: rgb(0, 0, 12=
8);">1</span>, c<span class=3D"br0" style=3D"color: rgb(0, 128, 0);">)</spa=
n><span class=3D"sy4" style=3D"color: rgb(0, 128, 128);">;</span>
<span class=3D"br0" style=3D"color: rgb(0, 128, 0);">}</span></pre><br clas=
s=3D"Apple-interchange-newline">Not calling this function with the default =
function arguments would be a nonsense. Furthermore, the type of <b>&amp;co=
untlower</b>=C2=A0would be expected to be <b>size::size_t (*)(conststr)</b>=
, judging by its interface, but it is not.</div><div><br></div><div>So what=
 if only=C2=A0<b>countlower</b>=C2=A0could not call itself with the default=
 function arguments? The syntax for this would be:</div><div><pre class=3D"=
de1" style=3D"border-style: none; border-color: white; background: none rgb=
(249, 249, 249); line-height: 1.2em; border-radius: 5px; width: 55em; overf=
low: auto; font-stretch: normal; font-size: 12.8px; vertical-align: top;"><=
span style=3D"color: rgb(0, 0, 0);"><span class=3D"kw4" style=3D"color: rgb=
(0, 0, 255);">constexpr</span> <a href=3D"http://en.cppreference.com/w/cpp/=
types/size_t" style=3D"color: rgb(0, 48, 128); background: none;"><span cla=
ss=3D"kw100">std::<span class=3D"me2">size_t</span></span></a> countlower<s=
pan class=3D"br0" style=3D"color: rgb(0, 128, 0);">(</span>conststr s, </sp=
an><font color=3D"#0000ff">private</font><font color=3D"#000000"> </font><a=
 href=3D"http://en.cppreference.com/w/cpp/types/size_t" style=3D"color: rgb=
(0, 48, 128); background: none;"><span class=3D"kw100">std::<span class=3D"=
me2">size_t</span></span></a><font color=3D"#000000"> n </font><span class=
=3D"sy1" style=3D"color: rgb(0, 0, 128);">=3D</span><font color=3D"#000000"=
> </font><span class=3D"nu0" style=3D"color: rgb(0, 0, 128);">0</span><font=
 color=3D"#000000">,
                                             </font><font color=3D"#0000ff"=
>private</font><font color=3D"#000000"> </font><a href=3D"http://en.cpprefe=
rence.com/w/cpp/types/size_t" style=3D"color: rgb(0, 48, 128); background: =
none;"><span class=3D"kw100">std::<span class=3D"me2">size_t</span></span><=
/a><font color=3D"#000000"> c </font><span class=3D"sy1" style=3D"color: rg=
b(0, 0, 128);">=3D</span><font color=3D"#000000"> </font><span class=3D"nu0=
" style=3D"color: rgb(0, 0, 128);">0</span><span class=3D"br0" style=3D"col=
or: rgb(0, 128, 0);">)</span><font color=3D"#000000">
</font><span class=3D"br0" style=3D"color: rgb(0, 128, 0);">{</span><font c=
olor=3D"#000000">
    </font><span class=3D"kw1" style=3D"color: rgb(0, 0, 221);">return</spa=
n><font color=3D"#000000"> n </font><span class=3D"sy1" style=3D"color: rgb=
(0, 0, 128);">=3D=3D</span><font color=3D"#000000"> s.</font><span class=3D=
"me1" style=3D"color: rgb(0, 0, 0);">size</span><span class=3D"br0" style=
=3D"color: rgb(0, 128, 0);">(</span><span class=3D"br0" style=3D"color: rgb=
(0, 128, 0);">)</span><span class=3D"sy4" style=3D"color: rgb(0, 128, 128);=
">?</span><font color=3D"#000000"> c </font><span class=3D"sy4" style=3D"co=
lor: rgb(0, 128, 128);">:</span><font color=3D"#000000">
           </font><span class=3D"st0" style=3D"color: rgb(0, 128, 0);">&#39=
;a&#39;</span><font color=3D"#000000"> </font><span class=3D"sy1" style=3D"=
color: rgb(0, 0, 128);">&lt;=3D</span><font color=3D"#000000"> s</font><spa=
n class=3D"br0" style=3D"color: rgb(0, 128, 0);">[</span><font color=3D"#00=
0000">n</font><span class=3D"br0" style=3D"color: rgb(0, 128, 0);">]</span>=
<font color=3D"#000000"> </font><span class=3D"sy3" style=3D"color: rgb(0, =
0, 64);">&amp;&amp;</span><font color=3D"#000000"> s</font><span class=3D"b=
r0" style=3D"color: rgb(0, 128, 0);">[</span><font color=3D"#000000">n</fon=
t><span class=3D"br0" style=3D"color: rgb(0, 128, 0);">]</span><font color=
=3D"#000000"> </font><span class=3D"sy1" style=3D"color: rgb(0, 0, 128);">&=
lt;=3D</span><font color=3D"#000000"> </font><span class=3D"st0" style=3D"c=
olor: rgb(0, 128, 0);">&#39;z&#39;</span><span class=3D"sy4" style=3D"color=
: rgb(0, 128, 128);">?</span><font color=3D"#000000"> countlower</font><spa=
n class=3D"br0" style=3D"color: rgb(0, 128, 0);">(</span><font color=3D"#00=
0000">s, n </font><span class=3D"sy2" style=3D"color: rgb(0, 0, 64);">+</sp=
an><font color=3D"#000000"> </font><span class=3D"nu0" style=3D"color: rgb(=
0, 0, 128);">1</span><font color=3D"#000000">, c </font><span class=3D"sy2"=
 style=3D"color: rgb(0, 0, 64);">+</span><font color=3D"#000000"> </font><s=
pan class=3D"nu0" style=3D"color: rgb(0, 0, 128);">1</span><span class=3D"b=
r0" style=3D"color: rgb(0, 128, 0);">)</span><font color=3D"#000000"> </fon=
t><span class=3D"sy4" style=3D"color: rgb(0, 128, 128);">:</span><font colo=
r=3D"#000000">
                                       countlower</font><span class=3D"br0"=
 style=3D"color: rgb(0, 128, 0);">(</span><font color=3D"#000000">s, n </fo=
nt><span class=3D"sy2" style=3D"color: rgb(0, 0, 64);">+</span><font color=
=3D"#000000"> </font><span class=3D"nu0" style=3D"color: rgb(0, 0, 128);">1=
</span><font color=3D"#000000">, c</font><span class=3D"br0" style=3D"color=
: rgb(0, 128, 0);">)</span><span class=3D"sy4" style=3D"color: rgb(0, 128, =
128);">;</span><font color=3D"#000000">
</font><span class=3D"br0" style=3D"color: rgb(0, 128, 0);">}</span></pre><=
br class=3D"Apple-interchange-newline">In other words, <b>countlower</b>=C2=
=A0is the only one that knows the presence of <b>n</b>=C2=A0and <b>c</b>. A=
nd so the type of <b>&amp;countlower</b>=C2=A0would be=C2=A0<b>size::size_t=
 (*)(conststr)</b>.</div><div><br></div><div>This should also be convenient=
 for SFINAE:</div><div><pre class=3D"de1" style=3D"border-style: none; bord=
er-color: white; color: rgb(0, 0, 0); background: none rgb(249, 249, 249); =
line-height: 1.2em; border-radius: 5px; width: 55em; overflow: auto; font-s=
tretch: normal; font-size: 12.8px; vertical-align: top;"><span class=3D"kw1=
" style=3D"color: rgb(0, 0, 221);">template</span><span class=3D"sy1" style=
=3D"color: rgb(0, 0, 128);">&lt;</span><span class=3D"kw4" style=3D"color: =
rgb(0, 0, 255);">int</span> I<span class=3D"sy1" style=3D"color: rgb(0, 0, =
128);">&gt;</span> <span class=3D"kw4" style=3D"color: rgb(0, 0, 255);">voi=
d</span> div<span class=3D"br0" style=3D"color: rgb(0, 128, 0);">(</span><s=
pan class=3D"kw4" style=3D"color: rgb(0, 0, 255);">private char</span><span=
 class=3D"br0" style=3D"color: rgb(0, 128, 0);">(</span><span class=3D"sy2"=
 style=3D"color: rgb(0, 0, 64);">*</span><span class=3D"br0" style=3D"color=
: rgb(0, 128, 0);">)</span><span class=3D"br0" style=3D"color: rgb(0, 128, =
0);">[</span>I <span class=3D"sy2" style=3D"color: rgb(0, 0, 64);">%</span>=
 <span class=3D"nu0" style=3D"color: rgb(0, 0, 128);">2</span> <span class=
=3D"sy1" style=3D"color: rgb(0, 0, 128);">=3D=3D</span> <span class=3D"nu0"=
 style=3D"color: rgb(0, 0, 128);">0</span><span class=3D"br0" style=3D"colo=
r: rgb(0, 128, 0);">]</span> <span class=3D"sy1" style=3D"color: rgb(0, 0, =
128);">=3D</span> <span class=3D"nu0" style=3D"color: rgb(0, 0, 128);">0</s=
pan><span class=3D"br0" style=3D"color: rgb(0, 128, 0);">)</span> <span cla=
ss=3D"br0" style=3D"color: rgb(0, 128, 0);">{</span>
    <span class=3D"co1" style=3D"color: rgb(144, 144, 144);">// this overlo=
ad is selected when I is even</span>
<span class=3D"br0" style=3D"color: rgb(0, 128, 0);">}</span>
<span class=3D"kw1" style=3D"color: rgb(0, 0, 221);">template</span><span c=
lass=3D"sy1" style=3D"color: rgb(0, 0, 128);">&lt;</span><span class=3D"kw4=
" style=3D"color: rgb(0, 0, 255);">int</span> I<span class=3D"sy1" style=3D=
"color: rgb(0, 0, 128);">&gt;</span> <span class=3D"kw4" style=3D"color: rg=
b(0, 0, 255);">void</span> div<span class=3D"br0" style=3D"color: rgb(0, 12=
8, 0);">(</span><span class=3D"kw4" style=3D"color: rgb(0, 0, 255);">privat=
e char</span><span class=3D"br0" style=3D"color: rgb(0, 128, 0);">(</span><=
span class=3D"sy2" style=3D"color: rgb(0, 0, 64);">*</span><span class=3D"b=
r0" style=3D"color: rgb(0, 128, 0);">)</span><span class=3D"br0" style=3D"c=
olor: rgb(0, 128, 0);">[</span>I <span class=3D"sy2" style=3D"color: rgb(0,=
 0, 64);">%</span> <span class=3D"nu0" style=3D"color: rgb(0, 0, 128);">2</=
span> <span class=3D"sy1" style=3D"color: rgb(0, 0, 128);">=3D=3D</span> <s=
pan class=3D"nu0" style=3D"color: rgb(0, 0, 128);">1</span><span class=3D"b=
r0" style=3D"color: rgb(0, 128, 0);">]</span> <span class=3D"sy1" style=3D"=
color: rgb(0, 0, 128);">=3D</span> <span class=3D"nu0" style=3D"color: rgb(=
0, 0, 128);">0</span><span class=3D"br0" style=3D"color: rgb(0, 128, 0);">)=
</span> <span class=3D"br0" style=3D"color: rgb(0, 128, 0);">{</span>
    <span class=3D"co1" style=3D"color: rgb(144, 144, 144);">// this overlo=
ad is selected  when I is odd</span>
<span class=3D"br0" style=3D"color: rgb(0, 128, 0);">}</span></pre></div><d=
iv><b><br></b></div><div><b>#2. Private</b><b>=C2=A0default template argume=
nts</b></div><div><b><br></b></div><div>Likewise, the class/function/variab=
le template must be the only one that knows the presence of their private d=
efault template arguments. For example:</div><div><pre class=3D"de1" style=
=3D"border-style: none; border-color: white; color: rgb(0, 0, 0); backgroun=
d: none rgb(249, 249, 249); line-height: 1.2em; border-radius: 5px; width: =
55em; overflow: auto; font-stretch: normal; font-size: 12.8px; vertical-ali=
gn: top;"><span class=3D"kw1" style=3D"color: rgb(0, 0, 221);">template</sp=
an><span class=3D"sy1" style=3D"color: rgb(0, 0, 128);">&lt;</span><span cl=
ass=3D"kw1" style=3D"color: rgb(0, 0, 221);">class</span> T,
 <span class=3D"kw1" style=3D"color: rgb(0, 0, 221);">typename</span> <span=
 class=3D"sy1" style=3D"color: rgb(0, 0, 128);">=3D</span> std<span class=
=3D"sy4" style=3D"color: rgb(0, 128, 128);">::</span><span class=3D"me2">en=
able_if_t</span><span class=3D"sy1" style=3D"color: rgb(0, 0, 128);">&lt;</=
span><a href=3D"http://en.cppreference.com/w/cpp/types/is_array" style=3D"c=
olor: rgb(0, 48, 128); background: none;"><span class=3D"kw460">std::<span =
class=3D"me2">is_array</span></span></a><span class=3D"sy1" style=3D"color:=
 rgb(0, 0, 128);">&lt;</span>T<span class=3D"sy1" style=3D"color: rgb(0, 0,=
 128);">&gt;</span><span class=3D"sy4" style=3D"color: rgb(0, 128, 128);">:=
:</span><span class=3D"me2">value</span><span class=3D"sy1" style=3D"color:=
 rgb(0, 0, 128);">&gt;</span> <span class=3D"sy1" style=3D"color: rgb(0, 0,=
 128);">&gt;</span>
<span class=3D"kw4" style=3D"color: rgb(0, 0, 255);">void</span> destroy<sp=
an class=3D"br0" style=3D"color: rgb(0, 128, 0);">(</span>T<span class=3D"s=
y2" style=3D"color: rgb(0, 0, 64);">*</span> t<span class=3D"br0" style=3D"=
color: rgb(0, 128, 0);">)</span>
<span class=3D"br0" style=3D"color: rgb(0, 128, 0);">{</span>
    <span class=3D"kw1" style=3D"color: rgb(0, 0, 221);">for</span><span cl=
ass=3D"br0" style=3D"color: rgb(0, 128, 0);">(</span><a href=3D"http://en.c=
ppreference.com/w/cpp/types/size_t" style=3D"color: rgb(0, 48, 128); backgr=
ound: none;"><span class=3D"kw100">std::<span class=3D"me2">size_t</span></=
span></a> i <span class=3D"sy1" style=3D"color: rgb(0, 0, 128);">=3D</span>=
 <span class=3D"nu0" style=3D"color: rgb(0, 0, 128);">0</span><span class=
=3D"sy4" style=3D"color: rgb(0, 128, 128);">;</span> i <span class=3D"sy1" =
style=3D"color: rgb(0, 0, 128);">&lt;</span> <a href=3D"http://en.cpprefere=
nce.com/w/cpp/types/extent" style=3D"color: rgb(0, 48, 128); background: no=
ne;"><span class=3D"kw586">std::<span class=3D"me2">extent</span></span></a=
><span class=3D"sy1" style=3D"color: rgb(0, 0, 128);">&lt;</span>T<span cla=
ss=3D"sy1" style=3D"color: rgb(0, 0, 128);">&gt;</span><span class=3D"sy4" =
style=3D"color: rgb(0, 128, 128);">::</span><span class=3D"me2">value</span=
><span class=3D"sy4" style=3D"color: rgb(0, 128, 128);">;</span> <span clas=
s=3D"sy2" style=3D"color: rgb(0, 0, 64);">++</span>i<span class=3D"br0" sty=
le=3D"color: rgb(0, 128, 0);">)</span> <span class=3D"br0" style=3D"color: =
rgb(0, 128, 0);">{</span>
        destroy<span class=3D"br0" style=3D"color: rgb(0, 128, 0);">(</span=
><span class=3D"br0" style=3D"color: rgb(0, 128, 0);">(</span><span class=
=3D"sy2" style=3D"color: rgb(0, 0, 64);">*</span>t<span class=3D"br0" style=
=3D"color: rgb(0, 128, 0);">)</span><span class=3D"br0" style=3D"color: rgb=
(0, 128, 0);">[</span>i<span class=3D"br0" style=3D"color: rgb(0, 128, 0);"=
>]</span><span class=3D"br0" style=3D"color: rgb(0, 128, 0);">)</span><span=
 class=3D"sy4" style=3D"color: rgb(0, 128, 128);">;</span>
    <span class=3D"br0" style=3D"color: rgb(0, 128, 0);">}</span>
<span class=3D"br0" style=3D"color: rgb(0, 128, 0);">}</span></pre><br clas=
s=3D"Apple-interchange-newline">Explicitly not calling this function with t=
he default template argument will bypass SFINAE. It must be private.</div><=
/div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/8a0fd64c-6e8a-4e31-a334-d55bd1811a49%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/8a0fd64c-6e8a-4e31-a334-d55bd1811a49=
%40isocpp.org</a>.<br />

------=_Part_6652_948459534.1485848185714--

------=_Part_6651_1360511367.1485848185713--

.


Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Date: Tue, 31 Jan 2017 17:07:52 -0800 (PST)
Raw View
------=_Part_7715_826680393.1485911273039
Content-Type: multipart/alternative;
 boundary="----=_Part_7716_2111352149.1485911273040"

------=_Part_7716_2111352149.1485911273040
Content-Type: text/plain; charset=UTF-8

On Monday, January 30, 2017 at 11:36:26 PM UTC-8, NDos Dannyu wrote:
>
> *#1. Private default function arguments*
> This should be convenient for recursive functions. For example from C++
> Reference:
> (*conststr* is literal string type.)
>
> constexpr std::size_t <http://en.cppreference.com/w/cpp/types/size_t> countlower(conststr s, std::size_t <http://en.cppreference.com/w/cpp/types/size_t> n = 0,
>                                              std::size_t <http://en.cppreference.com/w/cpp/types/size_t> c = 0){
>     return n == s.size()? c :
>            'a' <= s[n] && s[n] <= 'z'? countlower(s, n + 1, c + 1) :
>                                        countlower(s, n + 1, c);}
>
>
> Not calling this function with the default function arguments would be a
> nonsense. Furthermore, the type of *&countlower* would be expected to be *size::size_t
> (*)(conststr)*, judging by its interface, but it is not.
>
> So what if only *countlower* could not call itself with the default
> function arguments? The syntax for this would be:
>
> constexpr std::size_t <http://en.cppreference.com/w/cpp/types/size_t> countlower(conststr s, private std::size_t <http://en.cppreference.com/w/cpp/types/size_t> n = 0,
>                                              private std::size_t <http://en.cppreference.com/w/cpp/types/size_t> c = 0){
>     return n == s.size()? c :
>            'a' <= s[n] && s[n] <= 'z'? countlower(s, n + 1, c + 1) :
>                                        countlower(s, n + 1, c);}
>
>
> In other words, *countlower* is the only one that knows the presence of
> *n* and *c*. And so the type of *&countlower* would be *size::size_t
> (*)(conststr)*.
>

What would you envision the calling convention looking like for this
function countlower? Consider that it needs to be callable either with one
parameter (from itself or not-itself) or with three parameters (from within
itself). What would the assembly code for such an entity look like, on at
least one major platform?

Look at how it's currently done for functions with defaulted parameter
values. Consider how your proposal fits into the current ecosystem.

Next, consider the following refactor:

void f(some args) {
    if (some-control-flow) {
        do_some_things();
        f(some other args);
    }
}

==>

void f(some args) {
    if (some-control-flow) {
        factored_out_block(some other args);
    }

}
void factored_out_block(some other args) {
    do_some_things();
    f(some other args);
}

If I understand you correctly, this refactoring would not be a valid
transformation anymore, if f were a function with "private" arguments,
because factored_out_block would not be able to call f with those arguments
anymore.
This is not a new problem; we have the same problem today with friend
functions. But (at least in my experience) the workaround for friend
functions is "never use friend functions in any codebase ever." friend is
just a really bad idea except in very specific arcane circumstances. Which
makes me suspect that the thing you're proposing ("private defaulted
arguments") would also end up being a really bad idea except in very
specific arcane circumstances; and thus it wouldn't be a good idea to
standardize it in general, even if you figured out how to deal with the
calling-convention problem above.



>
> This should also be convenient for SFINAE:
>
> template<int I> void div(private char(*)[I % 2 == 0] = 0) {
>     // this overload is selected when I is even}template<int I> void div(private char(*)[I % 2 == 1] = 0) {
>     // this overload is selected  when I is odd}
>
>
This seems like another *technically valid place* to use SFINAE, but I
don't see how it's *more convenient* (or more readable) than

template<int I> std::enable_if_t<I % 2 == 1> div() {
>     // this overload is selected  when I is odd}
>
>



> *#2. Private** default template arguments*
>
> Likewise, the class/function/variable template must be the only one that
> knows the presence of their private default template arguments. For example:
>
> template<class T,
>  typename = std::enable_if_t<std::is_array <http://en.cppreference.com/w/cpp/types/is_array><T>::value> >void destroy(T* t){
>     for(std::size_t <http://en.cppreference.com/w/cpp/types/size_t> i = 0; i < std::extent <http://en.cppreference.com/w/cpp/types/extent><T>::value; ++i) {
>         destroy((*t)[i]);
>     }}
>
>
> Explicitly not calling this function with the default template argument
> will bypass SFINAE. It must be private.
>

Again, you've got a problem here with the name-mangling of the
specializations of the destroy template. (Name-mangling is to compile-time
as calling convention is to run-time; anytime you have a problem with
calling convention at runtime, you probably have a similar problem with
name-mangling at compile time.)

Try writing up a simple test program that uses these features, and then
showing the assembly you'd expect to get from the compiler if your proposal
were implemented. I think you'll find the problems.

HTH,
Arthur

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/8cc272fb-b630-49af-9570-ebe5e4e0cf4e%40isocpp.org.

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

<div dir=3D"ltr">On Monday, January 30, 2017 at 11:36:26 PM UTC-8, NDos Dan=
nyu wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:=
 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><b>=
#1. Private default function arguments</b><div>This should be convenient fo=
r recursive functions. For example from C++ Reference:</div><div>(<b>consts=
tr</b> is literal string type.)</div><div><pre style=3D"border-style:none;b=
order-color:white;color:rgb(0,0,0);background:none rgb(249,249,249);line-he=
ight:1.2em;border-radius:5px;width:55em;overflow:auto;font-stretch:normal;f=
ont-size:12.8px;vertical-align:top"><span style=3D"color:rgb(0,0,255)">cons=
texpr</span> <a href=3D"http://en.cppreference.com/w/cpp/types/size_t" styl=
e=3D"color:rgb(0,48,128);background:none" target=3D"_blank" rel=3D"nofollow=
" onmousedown=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F=
%2Fen.cppreference.com%2Fw%2Fcpp%2Ftypes%2Fsize_t\x26sa\x3dD\x26sntz\x3d1\x=
26usg\x3dAFQjCNEl30cZ4rZGt7sM3Z_lkX2mz0UzOg&#39;;return true;" onclick=3D"t=
his.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference=
..com%2Fw%2Fcpp%2Ftypes%2Fsize_t\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEl3=
0cZ4rZGt7sM3Z_lkX2mz0UzOg&#39;;return true;"><span>std::<span>size_t</span>=
</span></a> countlower<span style=3D"color:rgb(0,128,0)">(</span>conststr s=
, <a href=3D"http://en.cppreference.com/w/cpp/types/size_t" style=3D"color:=
rgb(0,48,128);background:none" target=3D"_blank" rel=3D"nofollow" onmousedo=
wn=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppre=
ference.com%2Fw%2Fcpp%2Ftypes%2Fsize_t\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEl30cZ4rZGt7sM3Z_lkX2mz0UzOg&#39;;return true;" onclick=3D"this.href=3D=
&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2F=
cpp%2Ftypes%2Fsize_t\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEl30cZ4rZGt7sM=
3Z_lkX2mz0UzOg&#39;;return true;"><span>std::<span>size_t</span></span></a>=
 n <span style=3D"color:rgb(0,0,128)">=3D</span> <span style=3D"color:rgb(0=
,0,128)">0</span>,
                                             <a href=3D"http://en.cpprefere=
nce.com/w/cpp/types/size_t" style=3D"color:rgb(0,48,128);background:none" t=
arget=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://ww=
w.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Ftypes%2F=
size_t\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEl30cZ4rZGt7sM3Z_lkX2mz0UzOg=
&#39;;return true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q=
\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Ftypes%2Fsize_t\x26sa\x3dD\=
x26sntz\x3d1\x26usg\x3dAFQjCNEl30cZ4rZGt7sM3Z_lkX2mz0UzOg&#39;;return true;=
"><span>std::<span>size_t</span></span></a> c <span style=3D"color:rgb(0,0,=
128)">=3D</span> <span style=3D"color:rgb(0,0,128)">0</span><span style=3D"=
color:rgb(0,128,0)">)</span>
<span style=3D"color:rgb(0,128,0)">{</span>
    <span style=3D"color:rgb(0,0,221)">return</span> n <span style=3D"color=
:rgb(0,0,128)">=3D=3D</span> s.<span>size</span><span style=3D"color:rgb(0,=
128,0)">(</span><span style=3D"color:rgb(0,128,0)">)</span><span style=3D"c=
olor:rgb(0,128,128)">?</span> c <span style=3D"color:rgb(0,128,128)">:</spa=
n>
           <span style=3D"color:rgb(0,128,0)">&#39;a&#39;</span> <span styl=
e=3D"color:rgb(0,0,128)">&lt;=3D</span> s<span style=3D"color:rgb(0,128,0)"=
>[</span>n<span style=3D"color:rgb(0,128,0)">]</span> <span style=3D"color:=
rgb(0,0,64)">&amp;&amp;</span> s<span style=3D"color:rgb(0,128,0)">[</span>=
n<span style=3D"color:rgb(0,128,0)">]</span> <span style=3D"color:rgb(0,0,1=
28)">&lt;=3D</span> <span style=3D"color:rgb(0,128,0)">&#39;z&#39;</span><s=
pan style=3D"color:rgb(0,128,128)">?</span> countlower<span style=3D"color:=
rgb(0,128,0)">(</span>s, n <span style=3D"color:rgb(0,0,64)">+</span> <span=
 style=3D"color:rgb(0,0,128)">1</span>, c <span style=3D"color:rgb(0,0,64)"=
>+</span> <span style=3D"color:rgb(0,0,128)">1</span><span style=3D"color:r=
gb(0,128,0)">)</span> <span style=3D"color:rgb(0,128,128)">:</span>
                                       countlower<span style=3D"color:rgb(0=
,128,0)">(</span>s, n <span style=3D"color:rgb(0,0,64)">+</span> <span styl=
e=3D"color:rgb(0,0,128)">1</span>, c<span style=3D"color:rgb(0,128,0)">)</s=
pan><span style=3D"color:rgb(0,128,128)">;</span>
<span style=3D"color:rgb(0,128,0)">}</span></pre><br>Not calling this funct=
ion with the default function arguments would be a nonsense. Furthermore, t=
he type of <b>&amp;countlower</b>=C2=A0would be expected to be <b>size::siz=
e_t (*)(conststr)</b>, judging by its interface, but it is not.</div><div><=
br></div><div>So what if only=C2=A0<b>countlower</b>=C2=A0could not call it=
self with the default function arguments? The syntax for this would be:</di=
v><div><pre style=3D"border-style:none;border-color:white;background:none r=
gb(249,249,249);line-height:1.2em;border-radius:5px;width:55em;overflow:aut=
o;font-stretch:normal;font-size:12.8px;vertical-align:top"><span style=3D"c=
olor:rgb(0,0,0)"><span style=3D"color:rgb(0,0,255)">constexpr</span> <a hre=
f=3D"http://en.cppreference.com/w/cpp/types/size_t" style=3D"color:rgb(0,48=
,128);background:none" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"th=
is.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.=
com%2Fw%2Fcpp%2Ftypes%2Fsize_t\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEl30=
cZ4rZGt7sM3Z_lkX2mz0UzOg&#39;;return true;" onclick=3D"this.href=3D&#39;htt=
p://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fty=
pes%2Fsize_t\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEl30cZ4rZGt7sM3Z_lkX2m=
z0UzOg&#39;;return true;"><span>std::<span>size_t</span></span></a> countlo=
wer<span style=3D"color:rgb(0,128,0)">(</span>conststr s, </span><font colo=
r=3D"#0000ff">private</font><font color=3D"#000000"> </font><a href=3D"http=
://en.cppreference.com/w/cpp/types/size_t" style=3D"color:rgb(0,48,128);bac=
kground:none" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=
=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw=
%2Fcpp%2Ftypes%2Fsize_t\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEl30cZ4rZGt=
7sM3Z_lkX2mz0UzOg&#39;;return true;" onclick=3D"this.href=3D&#39;http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Ftypes%2Fs=
ize_t\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEl30cZ4rZGt7sM3Z_lkX2mz0UzOg&=
#39;;return true;"><span>std::<span>size_t</span></span></a><font color=3D"=
#000000"> n </font><span style=3D"color:rgb(0,0,128)">=3D</span><font color=
=3D"#000000"> </font><span style=3D"color:rgb(0,0,128)">0</span><font color=
=3D"#000000">,
                                             </font><font color=3D"#0000ff"=
>private</font><font color=3D"#000000"> </font><a href=3D"http://en.cpprefe=
rence.com/w/cpp/types/size_t" style=3D"color:rgb(0,48,128);background:none"=
 target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://=
www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Ftypes%=
2Fsize_t\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEl30cZ4rZGt7sM3Z_lkX2mz0Uz=
Og&#39;;return true;" onclick=3D"this.href=3D&#39;http://www.google.com/url=
?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Ftypes%2Fsize_t\x26sa\x3d=
D\x26sntz\x3d1\x26usg\x3dAFQjCNEl30cZ4rZGt7sM3Z_lkX2mz0UzOg&#39;;return tru=
e;"><span>std::<span>size_t</span></span></a><font color=3D"#000000"> c </f=
ont><span style=3D"color:rgb(0,0,128)">=3D</span><font color=3D"#000000"> <=
/font><span style=3D"color:rgb(0,0,128)">0</span><span style=3D"color:rgb(0=
,128,0)">)</span><font color=3D"#000000">
</font><span style=3D"color:rgb(0,128,0)">{</span><font color=3D"#000000">
    </font><span style=3D"color:rgb(0,0,221)">return</span><font color=3D"#=
000000"> n </font><span style=3D"color:rgb(0,0,128)">=3D=3D</span><font col=
or=3D"#000000"> s.</font><span style=3D"color:rgb(0,0,0)">size</span><span =
style=3D"color:rgb(0,128,0)">(</span><span style=3D"color:rgb(0,128,0)">)</=
span><span style=3D"color:rgb(0,128,128)">?</span><font color=3D"#000000"> =
c </font><span style=3D"color:rgb(0,128,128)">:</span><font color=3D"#00000=
0">
           </font><span style=3D"color:rgb(0,128,0)">&#39;a&#39;</span><fon=
t color=3D"#000000"> </font><span style=3D"color:rgb(0,0,128)">&lt;=3D</spa=
n><font color=3D"#000000"> s</font><span style=3D"color:rgb(0,128,0)">[</sp=
an><font color=3D"#000000">n</font><span style=3D"color:rgb(0,128,0)">]</sp=
an><font color=3D"#000000"> </font><span style=3D"color:rgb(0,0,64)">&amp;&=
amp;</span><font color=3D"#000000"> s</font><span style=3D"color:rgb(0,128,=
0)">[</span><font color=3D"#000000">n</font><span style=3D"color:rgb(0,128,=
0)">]</span><font color=3D"#000000"> </font><span style=3D"color:rgb(0,0,12=
8)">&lt;=3D</span><font color=3D"#000000"> </font><span style=3D"color:rgb(=
0,128,0)">&#39;z&#39;</span><span style=3D"color:rgb(0,128,128)">?</span><f=
ont color=3D"#000000"> countlower</font><span style=3D"color:rgb(0,128,0)">=
(</span><font color=3D"#000000">s, n </font><span style=3D"color:rgb(0,0,64=
)">+</span><font color=3D"#000000"> </font><span style=3D"color:rgb(0,0,128=
)">1</span><font color=3D"#000000">, c </font><span style=3D"color:rgb(0,0,=
64)">+</span><font color=3D"#000000"> </font><span style=3D"color:rgb(0,0,1=
28)">1</span><span style=3D"color:rgb(0,128,0)">)</span><font color=3D"#000=
000"> </font><span style=3D"color:rgb(0,128,128)">:</span><font color=3D"#0=
00000">
                                       countlower</font><span style=3D"colo=
r:rgb(0,128,0)">(</span><font color=3D"#000000">s, n </font><span style=3D"=
color:rgb(0,0,64)">+</span><font color=3D"#000000"> </font><span style=3D"c=
olor:rgb(0,0,128)">1</span><font color=3D"#000000">, c</font><span style=3D=
"color:rgb(0,128,0)">)</span><span style=3D"color:rgb(0,128,128)">;</span><=
font color=3D"#000000">
</font><span style=3D"color:rgb(0,128,0)">}</span></pre><br>In other words,=
 <b>countlower</b>=C2=A0is the only one that knows the presence of <b>n</b>=
=C2=A0and <b>c</b>. And so the type of <b>&amp;countlower</b>=C2=A0would be=
=C2=A0<b>size::size_t (*)(conststr)</b>.</div></div></blockquote><div><br><=
/div><div>What would you envision the calling convention looking like for t=
his function <font face=3D"courier new, monospace">countlower</font>? Consi=
der that it needs to be callable either with one parameter (from itself or =
not-itself) or with three parameters (from within itself). What would the a=
ssembly code for such an entity look like, on at least one major platform?<=
/div><div><br></div><div>Look at how it&#39;s currently done for functions =
with defaulted parameter values. Consider how your proposal fits into the c=
urrent ecosystem.</div><div><br></div><div>Next, consider the following ref=
actor:</div><div><br></div><div class=3D"prettyprint" style=3D"background-c=
olor: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-wrap: =
break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> f</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">some args</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">if</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">some</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">-</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">control</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">flow</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 do_some_things</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 f</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">some other args</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br><br></span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">=3D=3D&gt;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> f</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>some args</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">if</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">some</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">-</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">control</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">-</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">flow</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 factored_out_block</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">some other args</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> factored_out_block</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">some other args</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 do_some_things</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 f</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">some other args</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span></div></code></div><div><br>If I under=
stand you correctly, this refactoring would not be a valid transformation a=
nymore, if <font face=3D"courier new, monospace">f</font> were a function w=
ith &quot;private&quot; arguments, because <font face=3D"courier new, monos=
pace">factored_out_block</font> would not be able to call <font face=3D"cou=
rier new, monospace">f</font> with those arguments anymore.</div><div>This =
is not a new problem; we have the same problem today with <font face=3D"cou=
rier new, monospace">friend</font> functions. But (at least in my experienc=
e) the workaround for <font face=3D"courier new, monospace">friend</font> f=
unctions is &quot;never use <font face=3D"courier new, monospace">friend</f=
ont> functions in any codebase ever.&quot; <font face=3D"courier new, monos=
pace">friend</font> is just a really bad idea except in very specific arcan=
e circumstances. Which makes me suspect that the thing you&#39;re proposing=
 (&quot;private defaulted arguments&quot;) would also end up being a really=
 bad idea except in very specific arcane circumstances; and thus it wouldn&=
#39;t be a good idea to standardize it in general, even if you figured out =
how to deal with the calling-convention problem above.</div><div><br></div>=
<div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr"><div><br></div><div>This should also be convenient for SFINAE:</div><di=
v><pre style=3D"border-style:none;border-color:white;color:rgb(0,0,0);backg=
round:none rgb(249,249,249);line-height:1.2em;border-radius:5px;width:55em;=
overflow:auto;font-stretch:normal;font-size:12.8px;vertical-align:top"><spa=
n style=3D"color:rgb(0,0,221)">template</span><span style=3D"color:rgb(0,0,=
128)">&lt;</span><span style=3D"color:rgb(0,0,255)">int</span> I<span style=
=3D"color:rgb(0,0,128)">&gt;</span> <span style=3D"color:rgb(0,0,255)">void=
</span> div<span style=3D"color:rgb(0,128,0)">(</span><span style=3D"color:=
rgb(0,0,255)">private char</span><span style=3D"color:rgb(0,128,0)">(</span=
><span style=3D"color:rgb(0,0,64)">*</span><span style=3D"color:rgb(0,128,0=
)">)</span><span style=3D"color:rgb(0,128,0)">[</span>I <span style=3D"colo=
r:rgb(0,0,64)">%</span> <span style=3D"color:rgb(0,0,128)">2</span> <span s=
tyle=3D"color:rgb(0,0,128)">=3D=3D</span> <span style=3D"color:rgb(0,0,128)=
">0</span><span style=3D"color:rgb(0,128,0)">]</span> <span style=3D"color:=
rgb(0,0,128)">=3D</span> <span style=3D"color:rgb(0,0,128)">0</span><span s=
tyle=3D"color:rgb(0,128,0)">)</span> <span style=3D"color:rgb(0,128,0)">{</=
span>
    <span style=3D"color:rgb(144,144,144)">// this overload is selected whe=
n I is even</span>
<span style=3D"color:rgb(0,128,0)">}</span>
<span style=3D"color:rgb(0,0,221)">template</span><span style=3D"color:rgb(=
0,0,128)">&lt;</span><span style=3D"color:rgb(0,0,255)">int</span> I<span s=
tyle=3D"color:rgb(0,0,128)">&gt;</span> <span style=3D"color:rgb(0,0,255)">=
void</span> div<span style=3D"color:rgb(0,128,0)">(</span><span style=3D"co=
lor:rgb(0,0,255)">private char</span><span style=3D"color:rgb(0,128,0)">(</=
span><span style=3D"color:rgb(0,0,64)">*</span><span style=3D"color:rgb(0,1=
28,0)">)</span><span style=3D"color:rgb(0,128,0)">[</span>I <span style=3D"=
color:rgb(0,0,64)">%</span> <span style=3D"color:rgb(0,0,128)">2</span> <sp=
an style=3D"color:rgb(0,0,128)">=3D=3D</span> <span style=3D"color:rgb(0,0,=
128)">1</span><span style=3D"color:rgb(0,128,0)">]</span> <span style=3D"co=
lor:rgb(0,0,128)">=3D</span> <span style=3D"color:rgb(0,0,128)">0</span><sp=
an style=3D"color:rgb(0,128,0)">)</span> <span style=3D"color:rgb(0,128,0)"=
>{</span>
    <span style=3D"color:rgb(144,144,144)">// this overload is selected  wh=
en I is odd</span>
<span style=3D"color:rgb(0,128,0)">}</span></pre></div></div></blockquote><=
div><br></div><div>This seems like another <i>technically valid place</i> t=
o use SFINAE, but I don&#39;t see how it&#39;s <i>more convenient</i> (or m=
ore readable) than</div><div><br></div><blockquote class=3D"gmail_quote" st=
yle=3D"margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color=
: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div di=
r=3D"ltr"><pre style=3D"border-style: none; border-color: white; color: rgb=
(0, 0, 0); background-image: none; background-color: rgb(249, 249, 249); li=
ne-height: 1.2em; border-top-left-radius: 5px; border-top-right-radius: 5px=
; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; width: 5=
5em; overflow: auto; font-size: 12.8px; vertical-align: top;"><span style=
=3D"color: rgb(0, 0, 221);">template</span><span style=3D"color: rgb(0, 0, =
128);">&lt;</span><span style=3D"color: rgb(0, 0, 255);">int</span> I<span =
style=3D"color: rgb(0, 0, 128);">&gt;</span> std::enable_if_t&lt;I % 2 =3D=
=3D 1&gt; div<span style=3D"color: rgb(0, 128, 0);">(</span><span style=3D"=
color: rgb(0, 128, 0);">)</span> <span style=3D"color: rgb(0, 128, 0);">{</=
span>
    <span style=3D"color: rgb(144, 144, 144);">// this overload is selected=
  when I is odd</span>
<span style=3D"color: rgb(0, 128, 0);">}</span></pre></div></blockquote><di=
v>=C2=A0 =C2=A0=C2=A0</div><div><br></div><div><br></div><blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><div dir=3D"ltr"><div><b><br></b></div><div><b>=
#2. Private</b><b>=C2=A0default template arguments</b></div><div><b><br></b=
></div><div>Likewise, the class/function/variable template must be the only=
 one that knows the presence of their private default template arguments. F=
or example:</div><div><pre style=3D"border-style:none;border-color:white;co=
lor:rgb(0,0,0);background:none rgb(249,249,249);line-height:1.2em;border-ra=
dius:5px;width:55em;overflow:auto;font-stretch:normal;font-size:12.8px;vert=
ical-align:top"><span style=3D"color:rgb(0,0,221)">template</span><span sty=
le=3D"color:rgb(0,0,128)">&lt;</span><span style=3D"color:rgb(0,0,221)">cla=
ss</span> T,
 <span style=3D"color:rgb(0,0,221)">typename</span> <span style=3D"color:rg=
b(0,0,128)">=3D</span> std<span style=3D"color:rgb(0,128,128)">::</span><sp=
an>enable_if_t</span><span style=3D"color:rgb(0,0,128)">&lt;</span><a href=
=3D"http://en.cppreference.com/w/cpp/types/is_array" style=3D"color:rgb(0,4=
8,128);background:none" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"t=
his.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference=
..com%2Fw%2Fcpp%2Ftypes%2Fis_array\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE=
Q8R-HvuPwnm9pOnBlPtGHHYVcqw&#39;;return true;" onclick=3D"this.href=3D&#39;=
http://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2=
Ftypes%2Fis_array\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEQ8R-HvuPwnm9pOnB=
lPtGHHYVcqw&#39;;return true;"><span>std::<span>is_array</span></span></a><=
span style=3D"color:rgb(0,0,128)"><wbr>&lt;</span>T<span style=3D"color:rgb=
(0,0,128)">&gt;</span><span style=3D"color:rgb(0,128,128)">::</span><span>v=
alue</span><span style=3D"color:rgb(0,0,128)">&gt;</span> <span style=3D"co=
lor:rgb(0,0,128)">&gt;</span>
<span style=3D"color:rgb(0,0,255)">void</span> destroy<span style=3D"color:=
rgb(0,128,0)">(</span>T<span style=3D"color:rgb(0,0,64)">*</span> t<span st=
yle=3D"color:rgb(0,128,0)">)</span>
<span style=3D"color:rgb(0,128,0)">{</span>
    <span style=3D"color:rgb(0,0,221)">for</span><span style=3D"color:rgb(0=
,128,0)">(</span><a href=3D"http://en.cppreference.com/w/cpp/types/size_t" =
style=3D"color:rgb(0,48,128);background:none" target=3D"_blank" rel=3D"nofo=
llow" onmousedown=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3=
A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Ftypes%2Fsize_t\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEl30cZ4rZGt7sM3Z_lkX2mz0UzOg&#39;;return true;" onclick=
=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cpprefe=
rence.com%2Fw%2Fcpp%2Ftypes%2Fsize_t\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQj=
CNEl30cZ4rZGt7sM3Z_lkX2mz0UzOg&#39;;return true;"><span>std::<span>size_t</=
span></span></a> i <span style=3D"color:rgb(0,0,128)">=3D</span> <span styl=
e=3D"color:rgb(0,0,128)">0</span><span style=3D"color:rgb(0,128,128)">;</sp=
an> i <span style=3D"color:rgb(0,0,128)">&lt;</span> <a href=3D"http://en.c=
ppreference.com/w/cpp/types/extent" style=3D"color:rgb(0,48,128);background=
:none" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;h=
ttp://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2F=
types%2Fextent\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGwiv7J1aKUv2TrV87sBR=
gRi1UgJw&#39;;return true;" onclick=3D"this.href=3D&#39;http://www.google.c=
om/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Ftypes%2Fextent\x26=
sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGwiv7J1aKUv2TrV87sBRgRi1UgJw&#39;;retu=
rn true;"><span>std::<span>extent</span></span></a><span style=3D"color:rgb=
(0,0,128)">&lt;</span>T<span style=3D"color:rgb(0,0,128)">&gt;</span><span =
style=3D"color:rgb(0,128,128)">::</span><span>value</span><span style=3D"co=
lor:rgb(0,128,128)">;</span> <span style=3D"color:rgb(0,0,64)">++</span>i<s=
pan style=3D"color:rgb(0,128,0)">)</span> <span style=3D"color:rgb(0,128,0)=
">{</span>
        destroy<span style=3D"color:rgb(0,128,0)">(</span><span style=3D"co=
lor:rgb(0,128,0)">(</span><span style=3D"color:rgb(0,0,64)">*</span>t<span =
style=3D"color:rgb(0,128,0)">)</span><span style=3D"color:rgb(0,128,0)">[</=
span>i<span style=3D"color:rgb(0,128,0)">]</span><span style=3D"color:rgb(0=
,128,0)">)</span><span style=3D"color:rgb(0,128,128)">;</span>
    <span style=3D"color:rgb(0,128,0)">}</span>
<span style=3D"color:rgb(0,128,0)">}</span></pre><br>Explicitly not calling=
 this function with the default template argument will bypass SFINAE. It mu=
st be private.</div></div></blockquote><div><br></div><div>Again, you&#39;v=
e got a problem here with the name-mangling of the specializations of the <=
font face=3D"courier new, monospace">destroy</font> template. (Name-manglin=
g is to compile-time as calling convention is to run-time; anytime you have=
 a problem with calling convention at runtime, you probably have a similar =
problem with name-mangling at compile time.)</div><div><br></div><div>Try w=
riting up a simple test program that uses these features, and then showing =
the assembly you&#39;d expect to get from the compiler if your proposal wer=
e implemented. I think you&#39;ll find the problems.</div><div><br></div><d=
iv>HTH,</div><div>Arthur</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/8cc272fb-b630-49af-9570-ebe5e4e0cf4e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/8cc272fb-b630-49af-9570-ebe5e4e0cf4e=
%40isocpp.org</a>.<br />

------=_Part_7716_2111352149.1485911273040--

------=_Part_7715_826680393.1485911273039--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Tue, 31 Jan 2017 18:25:03 -0800 (PST)
Raw View
------=_Part_2579_966169935.1485915903580
Content-Type: multipart/alternative;
 boundary="----=_Part_2580_31494993.1485915903580"

------=_Part_2580_31494993.1485915903580
Content-Type: text/plain; charset=UTF-8

On Tuesday, January 31, 2017 at 8:07:53 PM UTC-5, Arthur O'Dwyer wrote:
>
> On Monday, January 30, 2017 at 11:36:26 PM UTC-8, NDos Dannyu wrote:
>>
>> So what if only *countlower* could not call itself with the default
>> function arguments? The syntax for this would be:
>>
>> constexpr std::size_t <http://en.cppreference.com/w/cpp/types/size_t> countlower(conststr s, private std::size_t <http://en.cppreference.com/w/cpp/types/size_t> n = 0,
>>                                              private std::size_t <http://en.cppreference.com/w/cpp/types/size_t> c = 0){
>>     return n == s.size()? c :
>>            'a' <= s[n] && s[n] <= 'z'? countlower(s, n + 1, c + 1) :
>>                                        countlower(s, n + 1, c);}
>>
>>
>> In other words, *countlower* is the only one that knows the presence of
>> *n* and *c*. And so the type of *&countlower* would be *size::size_t
>> (*)(conststr)*.
>>
>
> What would you envision the calling convention looking like for this
> function countlower? Consider that it needs to be callable either with
> one parameter (from itself or not-itself) or with three parameters (from
> within itself). What would the assembly code for such an entity look like,
> on at least one major platform?
>

It would look like it does now. It's a function of 3 parameters.

This isn't an ABI thing. It isn't creating variations of the function. It's
simply saying that if you try to fill in those parameters with
user-provided values, and you aren't this function, you get a compile error.

Granted, I think it's not worthy of being a language feature. It's just not
useful enough to bother with.


> Look at how it's currently done for functions with defaulted parameter
> values. Consider how your proposal fits into the current ecosystem.
>
> Next, consider the following refactor:
>
> void f(some args) {
>     if (some-control-flow) {
>         do_some_things();
>         f(some other args);
>     }
> }
>
> ==>
>
> void f(some args) {
>     if (some-control-flow) {
>         factored_out_block(some other args);
>     }
>
> }
> void factored_out_block(some other args) {
>     do_some_things();
>     f(some other args);
> }
>
> If I understand you correctly, this refactoring would not be a valid
> transformation anymore, if f were a function with "private" arguments,
> because factored_out_block would not be able to call f with those
> arguments anymore.
> This is not a new problem; we have the same problem today with friend
> functions. But (at least in my experience) the workaround for friend
> functions is "never use friend functions in any codebase ever." friend is
> just a really bad idea except in very specific arcane circumstances. Which
> makes me suspect that the thing you're proposing ("private defaulted
> arguments") would also end up being a really bad idea except in very
> specific arcane circumstances; and thus it wouldn't be a good idea to
> standardize it in general, even if you figured out how to deal with the
> calling-convention problem above.
>
>
>
>>
>> This should also be convenient for SFINAE:
>>
>> template<int I> void div(private char(*)[I % 2 == 0] = 0) {
>>     // this overload is selected when I is even}template<int I> void div(private char(*)[I % 2 == 1] = 0) {
>>     // this overload is selected  when I is odd}
>>
>>
> This seems like another *technically valid place* to use SFINAE, but I
> don't see how it's *more convenient* (or more readable) than
>
> template<int I> std::enable_if_t<I % 2 == 1> div() {
>>     // this overload is selected  when I is odd}
>>
>>
>

Or:

template<int I> requires I % 2 == 1
  void div() {...}

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4af1627a-8e66-483b-89c1-2395391193df%40isocpp.org.

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

<div dir=3D"ltr">On Tuesday, January 31, 2017 at 8:07:53 PM UTC-5, Arthur O=
&#39;Dwyer wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr">On Monday, January 30, 2017 at 11:36:26 PM UTC-8, NDos Dannyu wrote:<bl=
ockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-l=
eft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div></div><div>So wh=
at if only=C2=A0<b>countlower</b>=C2=A0could not call itself with the defau=
lt function arguments? The syntax for this would be:</div><div><pre style=
=3D"border-style:none;border-color:white;background:none rgb(249,249,249);l=
ine-height:1.2em;border-radius:5px;width:55em;overflow:auto;font-stretch:no=
rmal;font-size:12.8px;vertical-align:top"><span style=3D"color:rgb(0,0,0)">=
<span style=3D"color:rgb(0,0,255)">constexpr</span> <a href=3D"http://en.cp=
preference.com/w/cpp/types/size_t" style=3D"color:rgb(0,48,128);background:=
none" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D&#39;ht=
tp://www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Ft=
ypes%2Fsize_t\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEl30cZ4rZGt7sM3Z_lkX2=
mz0UzOg&#39;;return true;" onclick=3D"this.href=3D&#39;http://www.google.co=
m/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Ftypes%2Fsize_t\x26s=
a\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEl30cZ4rZGt7sM3Z_lkX2mz0UzOg&#39;;retur=
n true;"><span>std::<span>size_t</span></span></a> countlower<span style=3D=
"color:rgb(0,128,0)">(</span>conststr s, </span><font color=3D"#0000ff">pri=
vate</font><font color=3D"#000000"> </font><a href=3D"http://en.cppreferenc=
e.com/w/cpp/types/size_t" style=3D"color:rgb(0,48,128);background:none" rel=
=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D&#39;http://www.=
google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Ftypes%2Fsi=
ze_t\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEl30cZ4rZGt7sM3Z_lkX2mz0UzOg&#=
39;;return true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\x=
3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Ftypes%2Fsize_t\x26sa\x3dD\x2=
6sntz\x3d1\x26usg\x3dAFQjCNEl30cZ4rZGt7sM3Z_lkX2mz0UzOg&#39;;return true;">=
<span>std::<span>size_t</span></span></a><font color=3D"#000000"> n </font>=
<span style=3D"color:rgb(0,0,128)">=3D</span><font color=3D"#000000"> </fon=
t><span style=3D"color:rgb(0,0,128)">0</span><font color=3D"#000000">,
                                             </font><font color=3D"#0000ff"=
>private</font><font color=3D"#000000"> </font><a href=3D"http://en.cpprefe=
rence.com/w/cpp/types/size_t" style=3D"color:rgb(0,48,128);background:none"=
 rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D&#39;http://=
www.google.com/url?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Ftypes%=
2Fsize_t\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEl30cZ4rZGt7sM3Z_lkX2mz0Uz=
Og&#39;;return true;" onclick=3D"this.href=3D&#39;http://www.google.com/url=
?q\x3dhttp%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Ftypes%2Fsize_t\x26sa\x3d=
D\x26sntz\x3d1\x26usg\x3dAFQjCNEl30cZ4rZGt7sM3Z_lkX2mz0UzOg&#39;;return tru=
e;"><span>std::<span>size_t</span></span></a><font color=3D"#000000"> c </f=
ont><span style=3D"color:rgb(0,0,128)">=3D</span><font color=3D"#000000"> <=
/font><span style=3D"color:rgb(0,0,128)">0</span><span style=3D"color:rgb(0=
,128,0)">)</span><font color=3D"#000000">
</font><span style=3D"color:rgb(0,128,0)">{</span><font color=3D"#000000">
    </font><span style=3D"color:rgb(0,0,221)">return</span><font color=3D"#=
000000"> n </font><span style=3D"color:rgb(0,0,128)">=3D=3D</span><font col=
or=3D"#000000"> s.</font><span style=3D"color:rgb(0,0,0)">size</span><span =
style=3D"color:rgb(0,128,0)">(</span><span style=3D"color:rgb(0,128,0)">)</=
span><span style=3D"color:rgb(0,128,128)">?</span><font color=3D"#000000"> =
c </font><span style=3D"color:rgb(0,128,128)">:</span><font color=3D"#00000=
0">
           </font><span style=3D"color:rgb(0,128,0)">&#39;a&#39;</span><fon=
t color=3D"#000000"> </font><span style=3D"color:rgb(0,0,128)">&lt;=3D</spa=
n><font color=3D"#000000"> s</font><span style=3D"color:rgb(0,128,0)">[</sp=
an><font color=3D"#000000">n</font><span style=3D"color:rgb(0,128,0)">]</sp=
an><font color=3D"#000000"> </font><span style=3D"color:rgb(0,0,64)">&amp;&=
amp;</span><font color=3D"#000000"> s</font><span style=3D"color:rgb(0,128,=
0)">[</span><font color=3D"#000000">n</font><span style=3D"color:rgb(0,128,=
0)">]</span><font color=3D"#000000"> </font><span style=3D"color:rgb(0,0,12=
8)">&lt;=3D</span><font color=3D"#000000"> </font><span style=3D"color:rgb(=
0,128,0)">&#39;z&#39;</span><span style=3D"color:rgb(0,128,128)">?</span><f=
ont color=3D"#000000"> countlower</font><span style=3D"color:rgb(0,128,0)">=
(</span><font color=3D"#000000">s, n </font><span style=3D"color:rgb(0,0,64=
)">+</span><font color=3D"#000000"> </font><span style=3D"color:rgb(0,0,128=
)">1</span><font color=3D"#000000">, c </font><span style=3D"color:rgb(0,0,=
64)">+</span><font color=3D"#000000"> </font><span style=3D"color:rgb(0,0,1=
28)">1</span><span style=3D"color:rgb(0,128,0)">)</span><font color=3D"#000=
000"> </font><span style=3D"color:rgb(0,128,128)">:</span><font color=3D"#0=
00000">
                                       countlower</font><span style=3D"colo=
r:rgb(0,128,0)">(</span><font color=3D"#000000">s, n </font><span style=3D"=
color:rgb(0,0,64)">+</span><font color=3D"#000000"> </font><span style=3D"c=
olor:rgb(0,0,128)">1</span><font color=3D"#000000">, c</font><span style=3D=
"color:rgb(0,128,0)">)</span><span style=3D"color:rgb(0,128,128)">;</span><=
font color=3D"#000000">
</font><span style=3D"color:rgb(0,128,0)">}</span></pre><br>In other words,=
 <b>countlower</b>=C2=A0is the only one that knows the presence of <b>n</b>=
=C2=A0and <b>c</b>. And so the type of <b>&amp;countlower</b>=C2=A0would be=
=C2=A0<b>size::size_t (*)(conststr)</b>.</div></div></blockquote><div><br><=
/div><div>What would you envision the calling convention looking like for t=
his function <font face=3D"courier new, monospace">countlower</font>? Consi=
der that it needs to be callable either with one parameter (from itself or =
not-itself) or with three parameters (from within itself). What would the a=
ssembly code for such an entity look like, on at least one major platform?<=
/div></div></blockquote><div><br>It would look like it does now. It&#39;s a=
 function of 3 parameters.<br><br>This isn&#39;t an ABI thing. It isn&#39;t=
 creating variations of the function. It&#39;s simply saying that if you tr=
y to fill in those parameters with user-provided values, and you aren&#39;t=
 this function, you get a compile error.<br><br>Granted, I think it&#39;s n=
ot worthy of being a language feature. It&#39;s just not useful enough to b=
other with.<br>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margi=
n: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><di=
v dir=3D"ltr"><div></div><div>Look at how it&#39;s currently done for funct=
ions with defaulted parameter values. Consider how your proposal fits into =
the current ecosystem.</div><div><br></div><div>Next, consider the followin=
g refactor:</div><div><br></div><div style=3D"background-color:rgb(250,250,=
250);border:1px solid rgb(187,187,187);word-wrap:break-word"><code><div><sp=
an style=3D"color:#008">void</span><span style=3D"color:#000"> f</span><spa=
n style=3D"color:#660">(</span><span style=3D"color:#000">some args</span><=
span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 <=
/span><span style=3D"color:#008">if</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#660">(</span><span style=3D"color:#000">some</span>=
<span style=3D"color:#660">-</span><span style=3D"color:#000">control</span=
><span style=3D"color:#660">-</span><span style=3D"color:#000">flow</span><=
span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 do_some_things</span><span style=3D"color:#660">();</span><sp=
an style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 f</span><span style=
=3D"color:#660">(</span><span style=3D"color:#000">some other args</span><s=
pan style=3D"color:#660">);</span><span style=3D"color:#000"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color:#660">}</span><span style=3D"color:#000"><b=
r></span><span style=3D"color:#660">}</span><span style=3D"color:#000"><br>=
<br></span><span style=3D"color:#660">=3D=3D&gt;</span><span style=3D"color=
:#000"><br><br></span><span style=3D"color:#008">void</span><span style=3D"=
color:#000"> f</span><span style=3D"color:#660">(</span><span style=3D"colo=
r:#000">some args</span><span style=3D"color:#660">)</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#660">{</span><span style=3D"color:=
#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">if</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">some</span><span style=3D"color:#660">-</span><span style=
=3D"color:#000">control</span><span style=3D"color:#660">-</span><span styl=
e=3D"color:#000">flow</span><span style=3D"color:#660">)</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">{</span><span style=3D"c=
olor:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 factored_out_block</span><span s=
tyle=3D"color:#660">(</span><span style=3D"color:#000">some other args</spa=
n><span style=3D"color:#660">);</span><span style=3D"color:#000"><br>=C2=A0=
 =C2=A0 </span><span style=3D"color:#660">}</span><span style=3D"color:#000=
"><br><br></span><span style=3D"color:#660">}</span><span style=3D"color:#0=
00"><br></span><span style=3D"color:#008">void</span><span style=3D"color:#=
000"> factored_out_block</span><span style=3D"color:#660">(</span><span sty=
le=3D"color:#000">some other args</span><span style=3D"color:#660">)</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#660">{</span><span=
 style=3D"color:#000"><br>=C2=A0 =C2=A0 do_some_things</span><span style=3D=
"color:#660">();</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 f</span=
><span style=3D"color:#660">(</span><span style=3D"color:#000">some other a=
rgs</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><b=
r></span><span style=3D"color:#660">}</span><span style=3D"color:#000"><br>=
</span></div></code></div><div><br>If I understand you correctly, this refa=
ctoring would not be a valid transformation anymore, if <font face=3D"couri=
er new, monospace">f</font> were a function with &quot;private&quot; argume=
nts, because <font face=3D"courier new, monospace">factored_out_block</font=
> would not be able to call <font face=3D"courier new, monospace">f</font> =
with those arguments anymore.</div><div>This is not a new problem; we have =
the same problem today with <font face=3D"courier new, monospace">friend</f=
ont> functions. But (at least in my experience) the workaround for <font fa=
ce=3D"courier new, monospace">friend</font> functions is &quot;never use <f=
ont face=3D"courier new, monospace">friend</font> functions in any codebase=
 ever.&quot; <font face=3D"courier new, monospace">friend</font> is just a =
really bad idea except in very specific arcane circumstances. Which makes m=
e suspect that the thing you&#39;re proposing (&quot;private defaulted argu=
ments&quot;) would also end up being a really bad idea except in very speci=
fic arcane circumstances; and thus it wouldn&#39;t be a good idea to standa=
rdize it in general, even if you figured out how to deal with the calling-c=
onvention problem above.</div><div><br></div><div>=C2=A0</div><blockquote c=
lass=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #c=
cc solid;padding-left:1ex"><div dir=3D"ltr"><div><br></div><div>This should=
 also be convenient for SFINAE:</div><div><pre style=3D"border-style:none;b=
order-color:white;color:rgb(0,0,0);background:none rgb(249,249,249);line-he=
ight:1.2em;border-radius:5px;width:55em;overflow:auto;font-stretch:normal;f=
ont-size:12.8px;vertical-align:top"><span style=3D"color:rgb(0,0,221)">temp=
late</span><span style=3D"color:rgb(0,0,128)">&lt;</span><span style=3D"col=
or:rgb(0,0,255)">int</span> I<span style=3D"color:rgb(0,0,128)">&gt;</span>=
 <span style=3D"color:rgb(0,0,255)">void</span> div<span style=3D"color:rgb=
(0,128,0)">(</span><span style=3D"color:rgb(0,0,255)">private char</span><s=
pan style=3D"color:rgb(0,128,0)">(</span><span style=3D"color:rgb(0,0,64)">=
*</span><span style=3D"color:rgb(0,128,0)">)</span><span style=3D"color:rgb=
(0,128,0)">[</span>I <span style=3D"color:rgb(0,0,64)">%</span> <span style=
=3D"color:rgb(0,0,128)">2</span> <span style=3D"color:rgb(0,0,128)">=3D=3D<=
/span> <span style=3D"color:rgb(0,0,128)">0</span><span style=3D"color:rgb(=
0,128,0)">]</span> <span style=3D"color:rgb(0,0,128)">=3D</span> <span styl=
e=3D"color:rgb(0,0,128)">0</span><span style=3D"color:rgb(0,128,0)">)</span=
> <span style=3D"color:rgb(0,128,0)">{</span>
    <span style=3D"color:rgb(144,144,144)">// this overload is selected whe=
n I is even</span>
<span style=3D"color:rgb(0,128,0)">}</span>
<span style=3D"color:rgb(0,0,221)">template</span><span style=3D"color:rgb(=
0,0,128)">&lt;</span><span style=3D"color:rgb(0,0,255)">int</span> I<span s=
tyle=3D"color:rgb(0,0,128)">&gt;</span> <span style=3D"color:rgb(0,0,255)">=
void</span> div<span style=3D"color:rgb(0,128,0)">(</span><span style=3D"co=
lor:rgb(0,0,255)">private char</span><span style=3D"color:rgb(0,128,0)">(</=
span><span style=3D"color:rgb(0,0,64)">*</span><span style=3D"color:rgb(0,1=
28,0)">)</span><span style=3D"color:rgb(0,128,0)">[</span>I <span style=3D"=
color:rgb(0,0,64)">%</span> <span style=3D"color:rgb(0,0,128)">2</span> <sp=
an style=3D"color:rgb(0,0,128)">=3D=3D</span> <span style=3D"color:rgb(0,0,=
128)">1</span><span style=3D"color:rgb(0,128,0)">]</span> <span style=3D"co=
lor:rgb(0,0,128)">=3D</span> <span style=3D"color:rgb(0,0,128)">0</span><sp=
an style=3D"color:rgb(0,128,0)">)</span> <span style=3D"color:rgb(0,128,0)"=
>{</span>
    <span style=3D"color:rgb(144,144,144)">// this overload is selected  wh=
en I is odd</span>
<span style=3D"color:rgb(0,128,0)">}</span></pre></div></div></blockquote><=
div><br></div><div>This seems like another <i>technically valid place</i> t=
o use SFINAE, but I don&#39;t see how it&#39;s <i>more convenient</i> (or m=
ore readable) than</div><div><br></div><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb=
(204,204,204);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr"><p=
re style=3D"border-style:none;border-color:white;color:rgb(0,0,0);backgroun=
d-image:none;background-color:rgb(249,249,249);line-height:1.2em;border-top=
-left-radius:5px;border-top-right-radius:5px;border-bottom-right-radius:5px=
;border-bottom-left-radius:5px;width:55em;overflow:auto;font-size:12.8px;ve=
rtical-align:top"><span style=3D"color:rgb(0,0,221)">template</span><span s=
tyle=3D"color:rgb(0,0,128)">&lt;</span><span style=3D"color:rgb(0,0,255)">i=
nt</span> I<span style=3D"color:rgb(0,0,128)">&gt;</span> std::enable_if_t&=
lt;I % 2 =3D=3D 1&gt; div<span style=3D"color:rgb(0,128,0)">(</span><span s=
tyle=3D"color:rgb(0,128,0)">)</span> <span style=3D"color:rgb(0,128,0)">{</=
span>
    <span style=3D"color:rgb(144,144,144)">// this overload is selected  wh=
en I is odd</span>
<span style=3D"color:rgb(0,128,0)">}</span></pre></div></blockquote><div>=
=C2=A0 =C2=A0=C2=A0</div></div></blockquote><div><br>Or:<br><br><div style=
=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187);=
 border-style: solid; border-width: 1px; overflow-wrap: break-word;" class=
=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint">=
<span style=3D"color: #008;" class=3D"styled-by-prettify">template</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> I</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> requires I </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">%</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">2</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #066;" class=3D"styled-by-prettify">1</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">void</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> div</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{...}</span></div></code></div><br></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/4af1627a-8e66-483b-89c1-2395391193df%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/4af1627a-8e66-483b-89c1-2395391193df=
%40isocpp.org</a>.<br />

------=_Part_2580_31494993.1485915903580--

------=_Part_2579_966169935.1485915903580--

.


Author: NDos Dannyu <ndospark320@naver.com>
Date: Tue, 31 Jan 2017 21:01:00 -0800 (PST)
Raw View
------=_Part_6926_1159012008.1485925261011
Content-Type: multipart/alternative;
 boundary="----=_Part_6927_500556445.1485925261011"

------=_Part_6927_500556445.1485925261011
Content-Type: text/plain; charset=UTF-8

I'm not suggesting to add new library features, but core language features.
And I took examples from C++ Reference.
For more practical example, which is my implementation of std::optional,
named *NDos::optional*:
*namespace NDos {*
*    template <class T> class optional {*
*    private:*
*        unsigned char place[sizeof(T)];*
*        bool hasvalue;*
*    public:*
*        /* ... */*
*        template <class E = T>
optional(std::enable_if_t<!std::is_copy_constructible<E>::value, const
optional&>) = delete;*
*        template <class E = T>
optional(std::enable_if_t<std::is_copy_constructible<E>::value, const
optional&> other) : hasvalue(other) {*
*            if ((bool)other)*
*                new(place) T(*other);*
*        }*
*        /* ... */*
*    };*
*    /* ... */*
*}*

The copy constructor of NDos::optional has default template parameter, for
use of SFINAE. If I specify an argument for them, (Say, *NDos::optional<int>::optional<std::mutex>(/*something
to be copied*/)* ?) It will bypass SFINAE.

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4b02d3db-2d04-4753-a5b2-1830bcaab1f1%40isocpp.org.

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

<div dir=3D"ltr">I&#39;m not suggesting to add new library features, but co=
re language features. And I took examples from C++ Reference.<div>For more =
practical example, which is my implementation of std::optional, named <b>ND=
os::optional</b>:</div><div><b>namespace NDos {</b></div><div><div><b>=C2=
=A0 =C2=A0 template &lt;class T&gt; class optional {</b></div><div><b>=C2=
=A0 =C2=A0 private:</b></div><div><b>=C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned c=
har place[sizeof(T)];</b></div><div><b>=C2=A0 =C2=A0 =C2=A0 =C2=A0 bool has=
value;</b></div><div><b>=C2=A0 =C2=A0 public:</b></div><div><b>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 /* ... */</b></div><div><b>=C2=A0 =C2=A0 =C2=A0 =C2=A0 te=
mplate &lt;class E =3D T&gt; optional(std::enable_if_t&lt;!std::is_copy_con=
structible&lt;E&gt;::value, const optional&amp;&gt;) =3D delete;</b></div><=
div><b>=C2=A0 =C2=A0 =C2=A0 =C2=A0 template &lt;class E =3D T&gt; optional(=
std::enable_if_t&lt;std::is_copy_constructible&lt;E&gt;::value, const optio=
nal&amp;&gt; other) : hasvalue(other) {</b></div><div><b>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 if ((bool)other)</b></div><div><b>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 new(place) T(*other);</b></div><d=
iv><b>=C2=A0 =C2=A0 =C2=A0 =C2=A0 }</b></div></div><div><b>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 /* ... */</b></div><div><b>=C2=A0 =C2=A0 };</b></div><div><b>=
=C2=A0 =C2=A0 /* ... */</b></div><div><b>}</b></div><div><br></div><div>The=
 copy constructor of NDos::optional has default template parameter, for use=
 of SFINAE. If I specify an argument for them, (Say, <b>NDos::optional&lt;i=
nt&gt;::optional&lt;std::mutex&gt;(/*something to be copied*/)</b>=C2=A0?) =
It will bypass SFINAE.</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/4b02d3db-2d04-4753-a5b2-1830bcaab1f1%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/4b02d3db-2d04-4753-a5b2-1830bcaab1f1=
%40isocpp.org</a>.<br />

------=_Part_6927_500556445.1485925261011--

------=_Part_6926_1159012008.1485925261011--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Wed, 1 Feb 2017 06:48:22 -0800 (PST)
Raw View
------=_Part_2751_974644612.1485960502713
Content-Type: multipart/alternative;
 boundary="----=_Part_2752_1866397067.1485960502713"

------=_Part_2752_1866397067.1485960502713
Content-Type: text/plain; charset=UTF-8

On Wednesday, February 1, 2017 at 12:01:01 AM UTC-5, Dannyu NDos wrote:
>
> I'm not suggesting to add new library features, but core language
> features. And I took examples from C++ Reference.
> For more practical example, which is my implementation of std::optional,
> named *NDos::optional*:
> *namespace NDos {*
> *    template <class T> class optional {*
> *    private:*
> *        unsigned char place[sizeof(T)];*
> *        bool hasvalue;*
> *    public:*
> *        /* ... */*
> *        template <class E = T>
> optional(std::enable_if_t<!std::is_copy_constructible<E>::value, const
> optional&>) = delete;*
> *        template <class E = T>
> optional(std::enable_if_t<std::is_copy_constructible<E>::value, const
> optional&> other) : hasvalue(other) {*
> *            if ((bool)other)*
> *                new(place) T(*other);*
> *        }*
> *        /* ... */*
> *    };*
> *    /* ... */*
> *}*
>
> The copy constructor of NDos::optional has default template parameter, for
> use of SFINAE. If I specify an argument for them, (Say, *NDos::optional<int>::optional<std::mutex>(/*something
> to be copied*/)* ?) It will bypass SFINAE.
>

And when we have concepts, we won't be using SFINAE for this kind of
nonsense anymore. So who cases?

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2c9bce78-30bf-4caa-b92a-592dc702fa3d%40isocpp.org.

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

<div dir=3D"ltr">On Wednesday, February 1, 2017 at 12:01:01 AM UTC-5, Danny=
u NDos wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
I&#39;m not suggesting to add new library features, but core language featu=
res. And I took examples from C++ Reference.<div>For more practical example=
, which is my implementation of std::optional, named <b>NDos::optional</b>:=
</div><div><b>namespace NDos {</b></div><div><div><b>=C2=A0 =C2=A0 template=
 &lt;class T&gt; class optional {</b></div><div><b>=C2=A0 =C2=A0 private:</=
b></div><div><b>=C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned char place[sizeof(T)];=
</b></div><div><b>=C2=A0 =C2=A0 =C2=A0 =C2=A0 bool hasvalue;</b></div><div>=
<b>=C2=A0 =C2=A0 public:</b></div><div><b>=C2=A0 =C2=A0 =C2=A0 =C2=A0 /* ..=
.. */</b></div><div><b>=C2=A0 =C2=A0 =C2=A0 =C2=A0 template &lt;class E =3D =
T&gt; optional(std::enable_if_t&lt;!<wbr>std::is_copy_constructible&lt;E&gt=
;:<wbr>:value, const optional&amp;&gt;) =3D delete;</b></div><div><b>=C2=A0=
 =C2=A0 =C2=A0 =C2=A0 template &lt;class E =3D T&gt; optional(std::enable_i=
f_t&lt;std:<wbr>:is_copy_constructible&lt;E&gt;::<wbr>value, const optional=
&amp;&gt; other) : hasvalue(other) {</b></div><div><b>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 if ((bool)other)</b></div><div><b>=C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 new(place) T(*other);</b></div><div><b>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }</b></div></div><div><b>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 /* ... */</b></div><div><b>=C2=A0 =C2=A0 };</b></div><div><b>=C2=A0 =
=C2=A0 /* ... */</b></div><div><b>}</b></div><div><br></div><div>The copy c=
onstructor of NDos::optional has default template parameter, for use of SFI=
NAE. If I specify an argument for them, (Say, <b>NDos::optional&lt;int&gt;:=
:optional&lt;<wbr>std::mutex&gt;(/*something to be copied*/)</b>=C2=A0?) It=
 will bypass SFINAE.</div></div></blockquote><div><br>And when we have conc=
epts, we won&#39;t be using SFINAE for this kind of nonsense anymore. So wh=
o cases? <br></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2c9bce78-30bf-4caa-b92a-592dc702fa3d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/2c9bce78-30bf-4caa-b92a-592dc702fa3d=
%40isocpp.org</a>.<br />

------=_Part_2752_1866397067.1485960502713--

------=_Part_2751_974644612.1485960502713--

.


Author: Dannyu NDos <ndospark320@naver.com>
Date: Wed, 1 Feb 2017 06:51:37 -0800 (PST)
Raw View
------=_Part_8636_1847680299.1485960697716
Content-Type: multipart/alternative;
 boundary="----=_Part_8637_989742782.1485960697716"

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



2017=EB=85=84 2=EC=9B=94 1=EC=9D=BC =EC=88=98=EC=9A=94=EC=9D=BC =EC=98=A4=
=ED=9B=84 11=EC=8B=9C 48=EB=B6=84 22=EC=B4=88 UTC+9, Nicol Bolas =EB=8B=98=
=EC=9D=98 =EB=A7=90:
>
> And when we have concepts, we won't be using SFINAE for this kind of=20
> nonsense anymore. So who cases?=20
>
But the Concept TS is still not a part of C++17! :(=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/27260936-8949-41b7-915b-585061920e10%40isocpp.or=
g.

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

<div dir=3D"ltr"><br><br>2017=EB=85=84 2=EC=9B=94 1=EC=9D=BC =EC=88=98=EC=
=9A=94=EC=9D=BC =EC=98=A4=ED=9B=84 11=EC=8B=9C 48=EB=B6=84 22=EC=B4=88 UTC+=
9, Nicol Bolas =EB=8B=98=EC=9D=98 =EB=A7=90:<blockquote class=3D"gmail_quot=
e" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;paddin=
g-left: 1ex;"><div dir=3D"ltr"><div>And when we have concepts, we won&#39;t=
 be using SFINAE for this kind of nonsense anymore. So who cases? <br></div=
></div></blockquote><div>But the Concept TS is still not a part of C++17! :=
(=C2=A0</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/27260936-8949-41b7-915b-585061920e10%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/27260936-8949-41b7-915b-585061920e10=
%40isocpp.org</a>.<br />

------=_Part_8637_989742782.1485960697716--

------=_Part_8636_1847680299.1485960697716--

.


Author: Dannyu NDos <ndospark320@naver.com>
Date: Wed, 1 Feb 2017 07:08:42 -0800 (PST)
Raw View
------=_Part_8668_296030816.1485961722925
Content-Type: multipart/alternative;
 boundary="----=_Part_8669_618876412.1485961722925"

------=_Part_8669_618876412.1485961722925
Content-Type: text/plain; charset=UTF-8

OK, I'll just wait for the concept then... I'm withdrawing this discussion.

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/125dd847-5765-49cd-9cdb-6f1ed9598b12%40isocpp.org.

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

<div dir=3D"ltr">OK, I&#39;ll just wait for the concept then... I&#39;m wit=
hdrawing this discussion.</div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/125dd847-5765-49cd-9cdb-6f1ed9598b12%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/125dd847-5765-49cd-9cdb-6f1ed9598b12=
%40isocpp.org</a>.<br />

------=_Part_8669_618876412.1485961722925--

------=_Part_8668_296030816.1485961722925--

.


Author: Dannyu NDos <ndospark320@naver.com>
Date: Wed, 1 Feb 2017 07:09:09 -0800 (PST)
Raw View
------=_Part_8872_898877103.1485961749717
Content-Type: multipart/alternative;
 boundary="----=_Part_8873_1619797270.1485961749717"

------=_Part_8873_1619797270.1485961749717
Content-Type: text/plain; charset=UTF-8

OK, I'll just wait for the concept then... I'm withdrawing this proposal.

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0fb9846b-2a94-4440-a0f1-c7d94b0e3ee8%40isocpp.org.

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

<div dir=3D"ltr">OK, I&#39;ll just wait for the concept then... I&#39;m wit=
hdrawing this proposal.<br></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/0fb9846b-2a94-4440-a0f1-c7d94b0e3ee8%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0fb9846b-2a94-4440-a0f1-c7d94b0e3ee8=
%40isocpp.org</a>.<br />

------=_Part_8873_1619797270.1485961749717--

------=_Part_8872_898877103.1485961749717--

.