Topic: Suggestion for banning arrays as parameters and


Author: sasho648 <sasho648@mail.bg>
Date: Sun, 23 Nov 2014 15:16:16 -0800 (PST)
Raw View
------=_Part_521_1125618746.1416784576670
Content-Type: multipart/alternative;
 boundary="----=_Part_522_1090817599.1416784576670"

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

My first suggestion is banning function params to be declared as arrays=20
because their real meaning isn't tolerated - being an actual arrays but=20
instead they are always converted to pointers. This is confusing and most=
=20
of the time imposes unwanted behavior. Better tell the user that you can't=
=20
implement a feature rather than giving him another totally different. My=20
suggestion is already applied when returning arrays from a function -=20
instead of implicitly casting to a pointer type, the compiler shows us an=
=20
error message.=20

NOTE: The wanted behavior is that when you declare an param as array - the=
=20
argument passed to it will be copied, instead of just referred, by using a=
=20
pointer.=20

So this means changing 8.3.5/5 from this:

After determining the type of each parameter, any parameter of type =E2=80=
=9Carray=20
of T=E2=80=9D or =E2=80=9Cfunction returning T=E2=80=9D is adjusted to be =
=E2=80=9Cpointer to T=E2=80=9D or=20
=E2=80=9Cpointer to function returning T,=E2=80=9D respectively.

To something like this:

After determining the type of each parameter, any parameter of type=20
=E2=80=9Cfunction returning T=E2=80=9D is adjusted to be =E2=80=9Cpointer t=
o function returning T=E2=80=9D.=20
Parameters of type =E2=80=9Carray of T=E2=80=9D are not allowed.

I understand that this could break some compatibility in old code so that's=
=20
way I suggest compilers (if this idea is green-lighted) still accept this=
=20
conversion for some-time but warn about it.

My second suggestion is allowing the creation of temporary, uninitialized a=
rrays.=20
This will be needed if you want to implement a function returning pseudo=20
arrays. It will looks something like this (this one will add the elements=
=20
of two arrays and return the result as a 'rvalue' reference to a temporary=
=20
which will actually be an unnamed variable in the calling scope, assigned=
=20
as a default argument):

template<size_t szArr, typename typeArrs>
auto fnAdd2ArrayElements(const typeArrs (&arr_0)[szArr], const typeArrs (&
arr_1)[szArr], typeArrs (&&result)[szArr] =3D {} /*a temporary=20
'ZERO-initialized' array*/) -> typeArrs (&&)[szArr]
{
    for(size_t i(0); i < szArr; ++i)
        result[i] =3D arr_0[i] + arr_1[i];


    return move(result);
}

The above function will compile fine but the temporary used will be always=
=20
zero-initialized which is a performance cost. My suggestion is to add a new=
=20
way for initializing aggregates (or specially arrays) which will create=20
them uninitialized. Something like this:

T *array()*

And then my function declared above will looks something like this:

template<typename T, size_t sz> using idArr =3D T [sz];


template<size_t szArr, typename typeArrs>
auto fnAdd2ArrayElements(const typeArrs (&arr_0)[szArr], const typeArrs (&
arr_1)[szArr], typeArrs (&&result)[szArr] =3D idArr<typeArrs, szArr> () /*a=
=20
temporary 'uninitialized' array*/) -> typeArrs (&&)[szArr]
{
    //for(size_t i(0); i < szArr; ++i)
        //result[i] =3D arr_0[i] + arr_1[i];


    return move(result);
}

I used for reference in the initializing aggregates - this=20
<http://en.cppreference.com/w/cpp/language/aggregate_initialization>.

Also my question about arrays in stack overflow - here=20
<http://stackoverflow.com/questions/27092082/why-iso-c-forbids-returning-ar=
rays>&=20
here=20
<http://stackoverflow.com/questions/27094506/why-array-arguments-are-always=
-converted-implicitly-to-pointers-instead-of-being?noredirect=3D1#comment42=
696315_27094506> (the=20
second one is shitty rated for unknown reasons).=20

--=20

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

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

<div dir=3D"ltr">My first suggestion is banning function params to be decla=
red as arrays because their real meaning isn't tolerated - being an actual =
arrays but instead they are always converted to pointers. This is confusing=
 and most of the time imposes unwanted behavior. Better tell the user that =
you can't implement a feature rather than giving him another totally differ=
ent. My suggestion is already applied when returning arrays from a function=
 - instead of implicitly casting to a pointer type, the compiler shows us a=
n error message.&nbsp;<div><br></div><div>NOTE: The wanted behavior is that=
 when you declare an param as array - the argument passed to it will be cop=
ied, instead of just referred, by using a pointer.&nbsp;</div><div><br></di=
v><div>So this means changing&nbsp;<span style=3D"color: rgb(0, 0, 0); font=
-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14=
px; line-height: 17.8048000335693px;">8.3.5/5 from this:</span></div><div><=
span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', '=
DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.8048000335693px;=
"><br></span></div><div><span style=3D"color: rgb(0, 0, 0); font-family: Ar=
ial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-he=
ight: 17.8048000335693px; background-color: rgb(238, 238, 238);">After dete=
rmining the type of each parameter, any parameter of type =E2=80=9Carray of=
 T=E2=80=9D or =E2=80=9Cfunction returning T=E2=80=9D is adjusted to be =E2=
=80=9Cpointer to T=E2=80=9D or =E2=80=9Cpointer to function returning T,=E2=
=80=9D respectively.</span><span style=3D"color: rgb(0, 0, 0); font-family:=
 Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line=
-height: 17.8048000335693px;"><br></span></div><div><span style=3D"color: r=
gb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-ser=
if; font-size: 14px; line-height: 17.8048000335693px; background-color: rgb=
(238, 238, 238);"><br></span></div><div><span style=3D"color: rgb(0, 0, 0);=
 font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-siz=
e: 14px; line-height: 17.8048000335693px;">To something like this:</span><b=
r></div><div><span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liber=
ation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.80=
48000335693px;"><br></span></div><div><span style=3D"color: rgb(0, 0, 0); f=
ont-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size:=
 14px; line-height: 17.8048000335693px; background-color: rgb(238, 238, 238=
);">After determining the type of each parameter, any parameter of type =E2=
=80=9Cfunction returning T=E2=80=9D is adjusted to be =E2=80=9Cpointer to f=
unction returning T=E2=80=9D. Parameters of type&nbsp;</span><span style=3D=
"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans',=
 sans-serif; font-size: 14px; line-height: 17.8048000335693px; background-c=
olor: rgb(238, 238, 238);">=E2=80=9Carray of T=E2=80=9D are not allowed.</s=
pan><span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation San=
s', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.80480003356=
93px;"><br></span></div><div><span style=3D"color: rgb(0, 0, 0); font-famil=
y: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; li=
ne-height: 17.8048000335693px; background-color: rgb(238, 238, 238);"><br><=
/span></div><div><font color=3D"#000000" face=3D"Arial, Liberation Sans, De=
jaVu Sans, sans-serif"><span style=3D"font-size: 14px; line-height: 17.8048=
000335693px;">I understand that this could break some&nbsp;compatibility&nb=
sp;in old code so that's way I suggest compilers (if this idea is green-lig=
hted) still accept this conversion for some-time but warn about it.</span><=
/font><br></div><div><font color=3D"#000000" face=3D"Arial, Liberation Sans=
, DejaVu Sans, sans-serif"><span style=3D"font-size: 14px; line-height: 17.=
8048000335693px;"><br></span></font></div><div><font color=3D"#000000" face=
=3D"Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style=3D"font-si=
ze: 14px; line-height: 17.8048000335693px;">My second suggestion is allowin=
g the creation of temporary</span></font><span style=3D"color: rgb(0, 0, 0)=
; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-si=
ze: 14px; line-height: 17.8048000335693px;">,&nbsp;uninitialized</span><fon=
t color=3D"#000000" face=3D"Arial, Liberation Sans, DejaVu Sans, sans-serif=
"><span style=3D"font-size: 14px; line-height: 17.8048000335693px;">&nbsp;a=
rrays. This will be needed if you want to implement a function returning ps=
eudo arrays. It will looks something like this (this one will add the eleme=
nts of two arrays and return the result as a 'rvalue' reference to a tempor=
ary which will actually be an unnamed variable in the calling scope, assign=
ed as a default argument):</span></font></div><div><br><div class=3D"pretty=
print" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word=
; background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div c=
lass=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">template</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">s=
ize_t szArr</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> typeArrs</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> fnAdd2ArrayElements</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> typeArrs </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(&amp;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">arr_0</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)[</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">szArr</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">],</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">const<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> typeArrs <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">(&amp;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">arr_1</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">)[</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">szArr</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">],</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> typeArrs </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(&amp;&amp;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">result</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">)[</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">szArr</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">]</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><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: #800;" class=3D"styled-by-prettify">/*a temporary 'ZERO-initialized'=
 array*/</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">-&gt;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> typeArrs </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(&amp;&amp;)[</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">szArr</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">]</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">for</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">size_t i</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-by-prett=
ify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> i </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> szArr</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">i</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>&nbsp; &nbsp; &nbsp; &nbsp; result</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">[</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">i</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">]</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> arr_0</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">i</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">]</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">+</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> arr_1</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">i</span><span style=3D"color: #660;" class=3D"styled-by-prettify">];</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>&n=
bsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">return</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> m=
ove</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">result</span><sp=
an 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"co=
lor: #660;" class=3D"styled-by-prettify">}</span></div></code></div><div><f=
ont color=3D"#000000" face=3D"Arial, Liberation Sans, DejaVu Sans, sans-ser=
if"><span style=3D"font-size: 14px; line-height: 17.8048000335693px;"><br><=
/span></font></div></div><div><font color=3D"#000000" face=3D"Arial, Libera=
tion Sans, DejaVu Sans, sans-serif"><span style=3D"font-size: 14px; line-he=
ight: 17.8048000335693px;">The above function will compile fine but the tem=
porary used will be always zero-initialized which is a performance cost. My=
 suggestion is to add a new way for&nbsp;initializing aggregates (or specia=
lly arrays) which will create them uninitialized. Something like this:<br><=
br></span></font><span class=3D"t-spar" style=3D"color: rgb(128, 128, 128);=
 font-style: italic; line-height: 1.1em; font-family: DejaVuSans, 'DejaVu S=
ans', arial, sans-serif;">T</span><span style=3D"color: rgb(0, 0, 0); font-=
family: DejaVuSans, 'DejaVu Sans', arial, sans-serif; line-height: 15.36000=
06103516px;">&nbsp;</span><font><i><font color=3D"#808080" face=3D"DejaVuSa=
ns, DejaVu Sans, arial, sans-serif"><span style=3D"line-height: 14.30000019=
07349px;">array</span></font><font color=3D"#000000" face=3D"DejaVuSansMono=
, DejaVu Sans Mono, courier, monospace"><span style=3D"line-height: 15.3600=
006103516px;"><b>()</b></span></font></i></font><font color=3D"#000000" fac=
e=3D"Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style=3D"font-s=
ize: 14px; line-height: 17.8048000335693px;"><br></span></font></div><div><=
font><i><font color=3D"#000000" face=3D"DejaVuSansMono, DejaVu Sans Mono, c=
ourier, monospace"><span style=3D"line-height: 15.3600006103516px;"><b><br>=
</b></span></font></i></font></div><div><font><span style=3D"color: rgb(0, =
0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; fo=
nt-size: 14px; line-height: 17.8048000335693px;">And then my function decla=
red above will looks something like this:</span><i><font color=3D"#000000" =
face=3D"DejaVuSansMono, DejaVu Sans Mono, courier, monospace"><span style=
=3D"line-height: 15.3600006103516px;"><b><br></b></span></font></i></font><=
/div><div><font><span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Li=
beration Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17=
..8048000335693px;"><br></span></font></div><div><div class=3D"prettyprint" =
style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; backg=
round-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D=
"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">=
template</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&l=
t;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">typename=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> size_t sz</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">using</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> idArr </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> T </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">sz</span><span style=3D"color: #660;" class=3D"styled-by-prettify">];</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br></=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">template</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">size_t szArr</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> typeArrs</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> fnAdd2ArrayElements</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">const</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> typeArrs </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">(&amp;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">arr_0</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">)[</span><span style=3D"color: #000;" class=3D"styled-by-prettify">szA=
rr</span><span style=3D"color: #660;" class=3D"styled-by-prettify">],</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> typeArrs </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(&amp;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">arr_1</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">)[</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">szArr</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">],</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> typeArrs </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">(&amp;&amp;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">result</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">)[</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">szArr</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>]</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> idArr</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">typeArrs</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> szArr</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&gt;</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-prettif=
y"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/*a te=
mporary 'uninitialized' array*/</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">-&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> t=
ypeArrs </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(&=
amp;&amp;)[</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>szArr</span><span style=3D"color: #660;" class=3D"styled-by-prettify">]</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><sp=
an style=3D"color: #800;" class=3D"styled-by-prettify">//for(size_t i(0); i=
 &lt; szArr; ++i)</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #800;" =
class=3D"styled-by-prettify">//result[i] =3D arr_0[i] + arr_1[i];</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>&nbsp; &=
nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">retu=
rn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> move</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">result</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></div></code></div><font color=
=3D"#000000" face=3D"Arial, Liberation Sans, DejaVu Sans, sans-serif" style=
=3D"font-size: 14px; line-height: 17.8048000335693px;"><div><br></div><div>=
I used for reference in the&nbsp;<span style=3D"line-height: 17.80480003356=
93px;">initializing aggregates - <a href=3D"http://en.cppreference.com/w/cp=
p/language/aggregate_initialization">this</a>.</span></div><div><span style=
=3D"line-height: 17.8048000335693px;"><br></span></div><div><span style=3D"=
line-height: 17.8048000335693px;">Also my question about arrays in stack ov=
erflow - <a href=3D"http://stackoverflow.com/questions/27092082/why-iso-c-f=
orbids-returning-arrays">here </a>&amp; <a href=3D"http://stackoverflow.com=
/questions/27094506/why-array-arguments-are-always-converted-implicitly-to-=
pointers-instead-of-being?noredirect=3D1#comment42696315_27094506">here</a>=
&nbsp;(the second one is shitty rated for unknown reasons).&nbsp;</span></d=
iv></font></div></div>

<p></p>

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

------=_Part_522_1090817599.1416784576670--
------=_Part_521_1125618746.1416784576670--

.


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Sun, 23 Nov 2014 23:46:07 +0000
Raw View
Regarding the first question: too many broken lines will result - no
chance of changing it, IMO.

On 11/23/14, sasho648 <sasho648@mail.bg> wrote:
> My first suggestion is banning function params to be declared as arrays
> because their real meaning isn't tolerated - being an actual arrays but
> instead they are always converted to pointers. This is confusing and most
> of the time imposes unwanted behavior. Better tell the user that you can'=
t
> implement a feature rather than giving him another totally different. My
> suggestion is already applied when returning arrays from a function -
> instead of implicitly casting to a pointer type, the compiler shows us an
> error message.
>
> NOTE: The wanted behavior is that when you declare an param as array - th=
e
> argument passed to it will be copied, instead of just referred, by using =
a
> pointer.
>
> So this means changing 8.3.5/5 from this:
>
> After determining the type of each parameter, any parameter of type =E2=
=80=9Carray
> of T=E2=80=9D or =E2=80=9Cfunction returning T=E2=80=9D is adjusted to be=
 =E2=80=9Cpointer to T=E2=80=9D or
> =E2=80=9Cpointer to function returning T,=E2=80=9D respectively.
>
> To something like this:
>
> After determining the type of each parameter, any parameter of type
> =E2=80=9Cfunction returning T=E2=80=9D is adjusted to be =E2=80=9Cpointer=
 to function returning T=E2=80=9D.
>
> Parameters of type =E2=80=9Carray of T=E2=80=9D are not allowed.
>
> I understand that this could break some compatibility in old code so that=
's
>
> way I suggest compilers (if this idea is green-lighted) still accept this
> conversion for some-time but warn about it.
>
> My second suggestion is allowing the creation of temporary, uninitialized
> arrays.
> This will be needed if you want to implement a function returning pseudo
> arrays. It will looks something like this (this one will add the elements
> of two arrays and return the result as a 'rvalue' reference to a temporar=
y
> which will actually be an unnamed variable in the calling scope, assigned
> as a default argument):
>
> template<size_t szArr, typename typeArrs>
> auto fnAdd2ArrayElements(const typeArrs (&arr_0)[szArr], const typeArrs (=
&
> arr_1)[szArr], typeArrs (&&result)[szArr] =3D {} /*a temporary
> 'ZERO-initialized' array*/) -> typeArrs (&&)[szArr]
> {
>     for(size_t i(0); i < szArr; ++i)
>         result[i] =3D arr_0[i] + arr_1[i];
>
>
>     return move(result);
> }
>
> The above function will compile fine but the temporary used will be alway=
s
> zero-initialized which is a performance cost. My suggestion is to add a n=
ew
>
> way for initializing aggregates (or specially arrays) which will create
> them uninitialized. Something like this:
>
> T *array()*
>
> And then my function declared above will looks something like this:
>
> template<typename T, size_t sz> using idArr =3D T [sz];
>
>
> template<size_t szArr, typename typeArrs>
> auto fnAdd2ArrayElements(const typeArrs (&arr_0)[szArr], const typeArrs (=
&
> arr_1)[szArr], typeArrs (&&result)[szArr] =3D idArr<typeArrs, szArr> () /=
*a
> temporary 'uninitialized' array*/) -> typeArrs (&&)[szArr]
> {
>     //for(size_t i(0); i < szArr; ++i)
>         //result[i] =3D arr_0[i] + arr_1[i];
>
>
>     return move(result);
> }
>
> I used for reference in the initializing aggregates - this
> <http://en.cppreference.com/w/cpp/language/aggregate_initialization>.
>
> Also my question about arrays in stack overflow - here
> <http://stackoverflow.com/questions/27092082/why-iso-c-forbids-returning-=
arrays>&
>
> here
> <http://stackoverflow.com/questions/27094506/why-array-arguments-are-alwa=
ys-converted-implicitly-to-pointers-instead-of-being?noredirect=3D1#comment=
42696315_27094506>
> (the
> second one is shitty rated for unknown reasons).
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>

--=20

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

.


Author: David Krauss <potswa@gmail.com>
Date: Mon, 24 Nov 2014 08:22:06 +0800
Raw View
--Apple-Mail=_727A35D0-3685-41B3-B6EC-FA7F9AE8296B
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


On 2014=E2=80=9311=E2=80=9324, at 7:46 AM, Douglas Boffey <douglas.boffey@g=
mail.com> wrote:

> Regarding the first question: too many broken lines will result - no
> chance of changing it, IMO.

Clang and GCC don=E2=80=99t even have a warning under -Wextra, perhaps none=
 implemented at all. Warnings are what one should look to for help avoiding=
 tricky language constructs.


On 2014=E2=80=9311=E2=80=9324, at 7:16 AM, sasho648 <sasho648@mail.bg> wrot=
e:

> My second suggestion is allowing the creation of temporary, uninitialized=
 arrays. This will be needed if you want to implement a function returning =
pseudo arrays.

If the array is ultimately filled, and it=E2=80=99s small enough to be reas=
onably passed on the stack, the zero-initialization will have negligible co=
st or quite likely be optimized out completely.

Passing C arrays even by reference should be avoided if possible. Really th=
ere are only a few edge cases where it=E2=80=99s necessary, otherwise use s=
td::array. You can create your own uninitialized array class from std::arra=
y by supplying a user-defined constructor.

template< typename t, std::size_t n >
struct uninitialized_array : std::array {
    uninitialized_array() {}
};

--=20

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

--Apple-Mail=_727A35D0-3685-41B3-B6EC-FA7F9AE8296B
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014=
=E2=80=9311=E2=80=9324, at 7:46 AM, Douglas Boffey &lt;<a href=3D"mailto:do=
uglas.boffey@gmail.com">douglas.boffey@gmail.com</a>&gt; wrote:</div><br cl=
ass=3D"Apple-interchange-newline"><blockquote type=3D"cite"><div style=3D"f=
ont-size: 12px; font-style: normal; font-variant: normal; font-weight: norm=
al; letter-spacing: normal; line-height: normal; orphans: auto; text-align:=
 start; text-indent: 0px; text-transform: none; white-space: normal; widows=
: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Regarding the f=
irst question: too many broken lines will result - no<br>chance of changing=
 it, IMO.<br></div></blockquote><div><br></div><div>Clang and GCC don=E2=80=
=99t even have a warning under -Wextra, perhaps none implemented at all. Wa=
rnings are what one should look to for help avoiding tricky language constr=
ucts.</div><div><br></div><div><br></div><div><div>On 2014=E2=80=9311=E2=80=
=9324, at 7:16 AM, sasho648 &lt;<a href=3D"mailto:sasho648@mail.bg">sasho64=
8@mail.bg</a>&gt; wrote:</div><br class=3D"Apple-interchange-newline"><bloc=
kquote type=3D"cite"><span style=3D"line-height: 17.8048000335693px;">My se=
cond suggestion is allowing the creation of temporary</span><span style=3D"=
line-height: 17.8048000335693px;">,&nbsp;uninitialized</span><span style=3D=
"line-height: 17.8048000335693px;">&nbsp;arrays. This will be needed if you=
 want to implement a function returning pseudo arrays.</span></blockquote><=
div><span style=3D"line-height: 17.8048000335693px;"><br></span></div><div>=
<span style=3D"line-height: 17.8048000335693px;">If the array is ultimately=
 filled</span><span style=3D"line-height: 17.8048000335693px;">, and it</sp=
an><span style=3D"line-height: 17px;">=E2=80=99</span><span style=3D"line-h=
eight: 17.8048000335693px;">s small enough to be reasonably&nbsp;</span><sp=
an style=3D"line-height: 17px;">passed on</span><span style=3D"line-height:=
 17.8048000335693px;">&nbsp;the stack, the zero-initialization will have ne=
gligible cost or quite likely be optimized out completely.</span></div><div=
><span style=3D"line-height: 17.8048000335693px;"><br></span></div><div><sp=
an style=3D"line-height: 17.8048000335693px;">Passing C arrays even by refe=
rence&nbsp;</span><span style=3D"line-height: 17px;">should</span><span sty=
le=3D"line-height: 17.8048000335693px;">&nbsp;be avoided if possible. Reall=
y there are only&nbsp;</span><span style=3D"line-height: 17px;">a few</span=
><span style=3D"line-height: 17.8048000335693px;">&nbsp;edge cases where it=
</span><span style=3D"line-height: 17px;">=E2=80=99</span><span style=3D"li=
ne-height: 17.8048000335693px;">s necessary, otherwise use <font face=3D"Co=
urier">std::array</font>. You can create your own uninitialized array class=
 from <font face=3D"Courier">std::array</font> by supplying a user-defined =
constructor.</span></div><div><span style=3D"line-height: 17.8048000335693p=
x;"><br></span></div><div><span style=3D"line-height: 17px;"><font face=3D"=
Courier">template&lt; typename t, std::size_t n &gt;</font></span></div><di=
v><span style=3D"line-height: 17px;"><font face=3D"Courier">struct uninitia=
lized_array : std::array {</font></span></div><div><span style=3D"line-heig=
ht: 17px;"><font face=3D"Courier">&nbsp; &nbsp; uninitialized_array() {}</f=
ont></span></div><div><span style=3D"line-height: 17px;"><font face=3D"Cour=
ier">};</font></span></div><div><br></div></div></div></body></html>

<p></p>

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

--Apple-Mail=_727A35D0-3685-41B3-B6EC-FA7F9AE8296B--

.


Author: sasho648 <sasho648@mail.bg>
Date: Mon, 24 Nov 2014 01:20:03 -0800 (PST)
Raw View
------=_Part_2481_406743378.1416820803789
Content-Type: multipart/alternative;
 boundary="----=_Part_2482_695505645.1416820803789"

------=_Part_2482_695505645.1416820803789
Content-Type: text/plain; charset=UTF-8

@David Krauss About passing arrays as reference - it could be a small issue
but the solution isn't so big to implement too. I mean - it will be only a
way to declare something like this:

T *array()*

And then use it like, if we have a function:




*void func(int (&&arg)[5]) { /*Do something*/ }*
 So we can then call it like:

func((int[5])());




Which will create a temporary unnamed & uninitialized array of 5 integers.
I believe this could be extended further to apply for other default complex
types like pointers. So we can then create a temporary pointer to function
for example like this:

bool fnDoSomethingAndAssignsArrayPointer(int (*&&arg)(int, int))
{
    /*Do something*/


    arg = func_addr; //assign arg some argument


    /*return*/
}

 And now if we don't care about the address stored we can write something
like this in the function call

fnDoSomethingAndAssignsArrayPointer((int (*)(int, int))());

 For now we could only specify a pointer value which will require a
unneeded copy initialization in the case.


About what @Douglas Boffey says that my first suggestion will break compatibility
- I already explained my solution for this problem. Compilers will at first
have the option to compile old code using this construct, but will display
a warning. You see - that the standard changes for better, doesn't means
compilers implement it at all.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

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

<div dir=3D"ltr"><span class=3D"_username" style=3D"white-space: nowrap;"><=
span class=3D"GBT-Y1EDJ-B">@David Krauss&nbsp;</span></span><span style=3D"=
color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', =
sans-serif; font-size: 14px; line-height: 17.8048000335693px;">About passin=
g arrays as reference - it could be a small issue but the solution isn't so=
 big to implement too. I mean - it will be only a way to declare something =
like this:<br></span><br><span style=3D"color: rgb(128, 128, 128); font-sty=
le: italic; line-height: 1.1em; font-family: DejaVuSans, 'DejaVu Sans', ari=
al, sans-serif;">T</span><span style=3D"color: rgb(0, 0, 0); font-family: D=
ejaVuSans, 'DejaVu Sans', arial, sans-serif; line-height: 15.3600006103516p=
x;">&nbsp;</span><i><font color=3D"#808080" face=3D"DejaVuSans, DejaVu Sans=
, arial, sans-serif"><span style=3D"line-height: 14.3000001907349px;">array=
</span></font><font color=3D"#000000" face=3D"DejaVuSansMono, DejaVu Sans M=
ono, courier, monospace"><span style=3D"line-height: 15.3600006103516px;"><=
b>()</b></span></font></i><br><div><i><font color=3D"#000000" face=3D"DejaV=
uSansMono, DejaVu Sans Mono, courier, monospace"><span style=3D"line-height=
: 15.3600006103516px;"><b><br></b></span></font></i></div><div><span style=
=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu San=
s', sans-serif; font-size: 14px; line-height: 17.8048000335693px;">And then=
 use it like, if we have a function:<br></span><i><font color=3D"#000000" f=
ace=3D"DejaVuSansMono, DejaVu Sans Mono, courier, monospace"><span style=3D=
"line-height: 15.3600006103516px;"><b><br><div class=3D"prettyprint" style=
=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background=
-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subp=
rettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">void<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> func</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(&amp;&amp;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">arg</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">)[</span><span style=3D"color: #066;" class=3D"=
styled-by-prettify">5</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">])</span><span style=3D"color: #000;" 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"> </span><span s=
tyle=3D"color: #800;" class=3D"styled-by-prettify">/*Do something*/</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></code></div>=
<br><br><br></b></span></font></i></div><div><span style=3D"color: rgb(0, 0=
, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; fon=
t-size: 14px; line-height: 17.8048000335693px;">&nbsp;So we can then call i=
t like:<br></span><i><font color=3D"#000000" face=3D"DejaVuSansMono, DejaVu=
 Sans Mono, courier, monospace"><span style=3D"line-height: 15.360000610351=
6px;"><b><br></b></span></font></i><i><font color=3D"#000000" face=3D"DejaV=
uSansMono, DejaVu Sans Mono, courier, monospace"><span style=3D"line-height=
: 15.3600006103516px;"><b></b></span></font></i></div><div class=3D"prettyp=
rint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word;=
 background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div cl=
ass=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">func</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
((</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span s=
tyle=3D"color: #066;" class=3D"styled-by-prettify">5</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">])());</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br><br><br></span></div></code></div=
><div><br><i><font color=3D"#000000" face=3D"DejaVuSansMono, DejaVu Sans Mo=
no, courier, monospace"><span style=3D"line-height: 15.3600006103516px;"><b=
><br></b></span></font></i></div><div><span style=3D"color: rgb(0, 0, 0); f=
ont-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size:=
 14px; line-height: 17.8048000335693px;">Which will create a temporary unna=
med &amp;&nbsp;</span><font color=3D"#000000" face=3D"Arial, Liberation San=
s, DejaVu Sans, sans-serif"><span style=3D"font-size: 14px; line-height: 17=
..8048000335693px;">uninitialized array of 5&nbsp;integers. I believe this c=
ould be extended&nbsp;further&nbsp;to apply for other default complex types=
 like pointers. So we can then create a temporary pointer to function for e=
xample like this:<br></span></font><font color=3D"#000000"><br><div class=
=3D"prettyprint" style=3D"font-family: DejaVuSansMono, 'DejaVu Sans Mono', =
courier, monospace; font-style: italic; font-weight: bold; border: 1px soli=
d rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250=
, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> fnDoSomethingAndAssignsArrayPo=
inter</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(*&amp;&amp;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">arg</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">)(</span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">int</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">int</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><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </s=
pan><span style=3D"color: #800;" class=3D"styled-by-prettify">/*Do somethin=
g*/</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br=
><br>&nbsp; &nbsp; arg </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> func_addr</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #800;" class=3D"styled-by-prettify">//assign arg=
 some argument</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br><br><br>&nbsp; &nbsp; </span><span style=3D"color: #800;" class=3D"=
styled-by-prettify">/*return*/</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">}</span></div></code></div><div style=3D"font-family: DejaVuS=
ansMono, 'DejaVu Sans Mono', courier, monospace; font-style: italic; font-w=
eight: bold;"><span style=3D"line-height: 15.3600006103516px;"><br></span><=
/div><div style=3D"font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier=
, monospace; font-style: italic; font-weight: bold;"><span style=3D"font-fa=
mily: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px;=
 font-style: normal; font-weight: normal; line-height: 17.8048000335693px;"=
>&nbsp;And now if we don't care about the address stored we can write somet=
hing like this in the function call</span></div><div style=3D"font-family: =
DejaVuSansMono, 'DejaVu Sans Mono', courier, monospace; font-style: italic;=
 font-weight: bold;"><span style=3D"font-family: Arial, 'Liberation Sans', =
'DejaVu Sans', sans-serif; font-size: 14px; font-style: normal; font-weight=
: normal; line-height: 17.8048000335693px;"><br></span></div></font><div><d=
iv class=3D"prettyprint" style=3D"color: rgb(0, 0, 0); border: 1px solid rg=
b(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 25=
0);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #000;" class=3D"styled-by-prettify">fnDoSomethingAndAssignsArray=
Pointer</span><span style=3D"color: #660;" class=3D"styled-by-prettify">((<=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(*)(</span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">int</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">))());</span></div></code></div><font face=3D"Arial, Liberation S=
ans, DejaVu Sans, sans-serif" style=3D"color: rgb(0, 0, 0);"><span style=3D=
"font-size: 14px; line-height: 17.8048000335693px;"><div><font face=3D"Aria=
l, Liberation Sans, DejaVu Sans, sans-serif"><span style=3D"font-size: 14px=
; line-height: 17.8048000335693px;"><br></span></font></div>&nbsp;For now w=
e could only specify a pointer value which will require a unneeded copy&nbs=
p;initialization&nbsp;in the case.<br></span></font><br><br><font color=3D"=
#000000">About what @</font><span class=3D"_username" style=3D"color: rgb(3=
4, 34, 34); white-space: nowrap;"><span class=3D"GBT-Y1EDJ-B g-hovercard" d=
ata-userid=3D"105548083684085355974" data-name=3D"Douglas Boffey">Douglas B=
offey</span></span><span style=3D"color: rgb(34, 34, 34); white-space: nowr=
ap;">&nbsp;says that my first suggestion will break&nbsp;</span><span style=
=3D"white-space: nowrap;">compatibility - I already explained my solution f=
or this problem. Compilers will at first have the option to compile old cod=
e using this construct, but will display a warning. You see - that the stan=
dard changes for better, doesn't means compilers implement it at all.</span=
></div></div></div>

<p></p>

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

------=_Part_2482_695505645.1416820803789--
------=_Part_2481_406743378.1416820803789--

.


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Mon, 24 Nov 2014 02:35:39 -0800 (PST)
Raw View
------=_Part_2503_463862289.1416825339334
Content-Type: multipart/alternative;
 boundary="----=_Part_2504_767852613.1416825339334"

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

Apologies for my rather brief posting earlier=E2=80=94my mobile allows a ma=
ximum=20
message size of 120 characters :(

On Monday, 24 November 2014 09:20:03 UTC, sasho648 wrote:

> @David Krauss About passing arrays as reference - it could be a small=20
> issue but the solution isn't so big to implement too. I mean - it will be=
=20
> only a way to declare something like this:
>
> T *array()*
>
> And then use it like, if we have a function:
>
>
>
>
> *void func(int (&&arg)[5]) { /*Do something*/ }*
>  So we can then call it like:
>
> func((int[5])());
>
>
>
>
> Which will create a temporary unnamed & uninitialized array of=20
> 5 integers. I believe this could be extended further to apply for other=
=20
> default complex types like pointers. So we can then create a temporary=20
> pointer to function for example like this:
>
> bool fnDoSomethingAndAssignsArrayPointer(int (*&&arg)(int, int))
> {
>     /*Do something*/
>
>
>     arg =3D func_addr; //assign arg some argument
>
>
>     /*return*/
> }
>
>  And now if we don't care about the address stored we can write something=
=20
> like this in the function call
>
> fnDoSomethingAndAssignsArrayPointer((int (*)(int, int))());
>
>  For now we could only specify a pointer value which will require a=20
> unneeded copy initialization in the case.
>
>
> About what @Douglas Boffey says that my first suggestion will break compa=
tibility=20
> - I already explained my solution for this problem. Compilers will at fir=
st=20
> have the option to compile old code using this construct, but will displa=
y=20
> a warning. You see - that the standard changes for better, doesn't means=
=20
> compilers implement it at all.
>
=20
I understand that parts of the language could be deprecated, and then used=
=20
differently, but that would be a last resort.  Suppose you have a library=
=20
that worked fine, only to find that a future version of C++ frowned upon=20
it, and eventually, it refused to compile.  Suppose that the library was=20
written for C, and continued to work fine for that, but became unusable for=
=20
C++.
=20
Besides, if a function was expecting a pointer to an array, wouldn=E2=80=99=
t a=20
declaration along the lines of:
=20
void foo(int bar[])

=20
be better than
=20
void foo(int *bar)
As David said, if you really wanted an array that doesn=E2=80=99t decay int=
o a=20
pointer at the slightest provocation, consider using std::array instead of=
=20
a C array.
=20

My second suggestion is allowing the creation of temporary, uninitialized=
=20
arrays. This will be needed if you want to implement a function returning=
=20
pseudo arrays. It will looks something like this (this one will add the=20
elements of two arrays and return the result as a 'rvalue' reference to a=
=20
temporary which will actually be an unnamed variable in the calling scope,=
=20
assigned as a default argument):

Regarding defaulting a formal parameter to an initialised array, which is=
=20
what your example seems to suggest, you would then have to, presumably,=20
pass a flag to the function to indicate whether the parameter was given,=20
and hence usable, or not.  This leads to fragile code.
=20
Not only that, the compiler would not be able to match the flag with=20
whether the data was usable or not, so couldn=E2=80=99t warn about using un=
defined=20
data.  Finally, if the data was not a POD, how could the compiler know=20
whether a destructor would need to be called or not?
=20
=20
=20

--=20

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

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

<div dir=3D"ltr"><div>Apologies for my rather brief posting earlier=E2=80=
=94my mobile allows a maximum message size of 120 characters :(</div><div><=
br>On Monday, 24 November 2014 09:20:03 UTC, sasho648  wrote:</div><blockqu=
ote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-colo=
r: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;" c=
lass=3D"gmail_quote"><div dir=3D"ltr"><span style=3D"white-space: nowrap;">=
<span>@David Krauss&nbsp;</span></span><span style=3D'color: rgb(0, 0, 0); =
line-height: 17.8px; font-family: Arial,"Liberation Sans","DejaVu Sans",san=
s-serif; font-size: 14px;'>About passing arrays as reference - it could be =
a small issue but the solution isn't so big to implement too. I mean - it w=
ill be only a way to declare something like this:<br></span><br><span style=
=3D'color: rgb(128, 128, 128); line-height: 1.1em; font-family: DejaVuSans,=
"DejaVu Sans",arial,sans-serif; font-style: italic;'>T</span><span style=3D=
'color: rgb(0, 0, 0); line-height: 15.36px; font-family: DejaVuSans,"DejaVu=
 Sans",arial,sans-serif;'>&nbsp;</span><i><font color=3D"#808080" face=3D"D=
ejaVuSans, DejaVu Sans, arial, sans-serif"><span style=3D"line-height: 14.3=
px;">array</span></font><font color=3D"#000000" face=3D"DejaVuSansMono, Dej=
aVu Sans Mono, courier, monospace"><span style=3D"line-height: 15.36px;"><b=
>()</b></span></font></i><br><div><i><font color=3D"#000000" face=3D"DejaVu=
SansMono, DejaVu Sans Mono, courier, monospace"><span style=3D"line-height:=
 15.36px;"><b><br></b></span></font></i></div><div><span style=3D'color: rg=
b(0, 0, 0); line-height: 17.8px; font-family: Arial,"Liberation Sans","Deja=
Vu Sans",sans-serif; font-size: 14px;'>And then use it like, if we have a f=
unction:<br></span><i><font color=3D"#000000" face=3D"DejaVuSansMono, DejaV=
u Sans Mono, courier, monospace"><span style=3D"line-height: 15.36px;"><b><=
br><div style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-wor=
d; background-color: rgb(250, 250, 250);"><code><div><span style=3D"color: =
rgb(0, 0, 136);">void</span><span style=3D"color: rgb(0, 0, 0);"> func</spa=
n><span style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rg=
b(0, 0, 136);">int</span><span style=3D"color: rgb(0, 0, 0);"> </span><span=
 style=3D"color: rgb(102, 102, 0);">(&amp;&amp;</span><span style=3D"color:=
 rgb(0, 0, 0);">arg</span><span style=3D"color: rgb(102, 102, 0);">)[</span=
><span style=3D"color: rgb(0, 102, 102);">5</span><span style=3D"color: rgb=
(102, 102, 0);">])</span><span style=3D"color: rgb(0, 0, 0);"> </span><span=
 style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0,=
 0);"> </span><span style=3D"color: rgb(136, 0, 0);">/*Do something*/</span=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102=
, 102, 0);">}</span></div></code></div><br><br><br></b></span></font></i></=
div><div><span style=3D'color: rgb(0, 0, 0); line-height: 17.8px; font-fami=
ly: Arial,"Liberation Sans","DejaVu Sans",sans-serif; font-size: 14px;'>&nb=
sp;So we can then call it like:<br></span><i><font color=3D"#000000" face=
=3D"DejaVuSansMono, DejaVu Sans Mono, courier, monospace"><span style=3D"li=
ne-height: 15.36px;"><b><br></b></span></font></i><i><font color=3D"#000000=
" face=3D"DejaVuSansMono, DejaVu Sans Mono, courier, monospace"><span style=
=3D"line-height: 15.36px;"><b></b></span></font></i></div><div style=3D"bor=
der: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color:=
 rgb(250, 250, 250);"><code><div><span style=3D"color: rgb(0, 0, 0);">func<=
/span><span style=3D"color: rgb(102, 102, 0);">((</span><span style=3D"colo=
r: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(102, 102, 0);">[</s=
pan><span style=3D"color: rgb(0, 102, 102);">5</span><span style=3D"color: =
rgb(102, 102, 0);">])());</span><span style=3D"color: rgb(0, 0, 0);"><br><b=
r><br></span></div></code></div><div><br><i><font color=3D"#000000" face=3D=
"DejaVuSansMono, DejaVu Sans Mono, courier, monospace"><span style=3D"line-=
height: 15.36px;"><b><br></b></span></font></i></div><div><span style=3D'co=
lor: rgb(0, 0, 0); line-height: 17.8px; font-family: Arial,"Liberation Sans=
","DejaVu Sans",sans-serif; font-size: 14px;'>Which will create a temporary=
 unnamed &amp;&nbsp;</span><font color=3D"#000000" face=3D"Arial, Liberatio=
n Sans, DejaVu Sans, sans-serif"><span style=3D"line-height: 17.8px; font-s=
ize: 14px;">uninitialized array of 5&nbsp;integers. I believe this could be=
 extended&nbsp;further&nbsp;to apply for other default complex types like p=
ointers. So we can then create a temporary pointer to function for example =
like this:<br></span></font><font color=3D"#000000"><br><div style=3D'borde=
r: 1px solid rgb(187, 187, 187); font-family: DejaVuSansMono,"DejaVu Sans M=
ono",courier,monospace; font-style: italic; font-weight: bold; word-wrap: b=
reak-word; background-color: rgb(250, 250, 250);'><code><div><span style=3D=
"color: rgb(0, 0, 136);">bool</span><span style=3D"color: rgb(0, 0, 0);"> f=
nDoSomethingAndAssignsArrayPo<wbr>inter</span><span style=3D"color: rgb(102=
, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 136);">int</span><span =
style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, =
0);">(*&amp;&amp;</span><span style=3D"color: rgb(0, 0, 0);">arg</span><spa=
n style=3D"color: rgb(102, 102, 0);">)(</span><span style=3D"color: rgb(0, =
0, 136);">int</span><span style=3D"color: rgb(102, 102, 0);">,</span><span =
style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136)=
;">int</span><span style=3D"color: rgb(102, 102, 0);">))</span><span style=
=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 102, 0)=
;">{</span><span style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; </span><s=
pan style=3D"color: rgb(136, 0, 0);">/*Do something*/</span><span style=3D"=
color: rgb(0, 0, 0);"><br><br><br>&nbsp; &nbsp; arg </span><span style=3D"c=
olor: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, 0, 0);"> fu=
nc_addr</span><span style=3D"color: rgb(102, 102, 0);">;</span><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(136, 0, 0);">//=
assign arg some argument</span><span style=3D"color: rgb(0, 0, 0);"><br><br=
><br>&nbsp; &nbsp; </span><span style=3D"color: rgb(136, 0, 0);">/*return*/=
</span><span style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color=
: rgb(102, 102, 0);">}</span></div></code></div><div style=3D'font-family: =
DejaVuSansMono,"DejaVu Sans Mono",courier,monospace; font-style: italic; fo=
nt-weight: bold;'><span style=3D"line-height: 15.36px;"><br></span></div><d=
iv style=3D'font-family: DejaVuSansMono,"DejaVu Sans Mono",courier,monospac=
e; font-style: italic; font-weight: bold;'><span style=3D'line-height: 17.8=
px; font-family: Arial,"Liberation Sans","DejaVu Sans",sans-serif; font-siz=
e: 14px; font-style: normal; font-weight: normal;'>&nbsp;And now if we don'=
t care about the address stored we can write something like this in the fun=
ction call</span></div><div style=3D'font-family: DejaVuSansMono,"DejaVu Sa=
ns Mono",courier,monospace; font-style: italic; font-weight: bold;'><span s=
tyle=3D'line-height: 17.8px; font-family: Arial,"Liberation Sans","DejaVu S=
ans",sans-serif; font-size: 14px; font-style: normal; font-weight: normal;'=
><br></span></div></font><div><div style=3D"border: 1px solid rgb(187, 187,=
 187); color: rgb(0, 0, 0); word-wrap: break-word; background-color: rgb(25=
0, 250, 250);"><code><div><span style=3D"color: rgb(0, 0, 0);">fnDoSomethin=
gAndAssignsArrayPo<wbr>inter</span><span style=3D"color: rgb(102, 102, 0);"=
>((</span><span style=3D"color: rgb(0, 0, 136);">int</span><span style=3D"c=
olor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">(*)(<=
/span><span style=3D"color: rgb(0, 0, 136);">int</span><span style=3D"color=
: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><=
span style=3D"color: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(1=
02, 102, 0);">))());</span></div></code></div><font style=3D"color: rgb(0, =
0, 0);" face=3D"Arial, Liberation Sans, DejaVu Sans, sans-serif"><span styl=
e=3D"line-height: 17.8px; font-size: 14px;"><div><font face=3D"Arial, Liber=
ation Sans, DejaVu Sans, sans-serif"><span style=3D"line-height: 17.8px; fo=
nt-size: 14px;"><br></span></font></div>&nbsp;For now we could only specify=
 a pointer value which will require a unneeded copy&nbsp;initialization&nbs=
p;in the case.<br></span></font><br><br><font color=3D"#000000">About what =
@</font><span style=3D"color: rgb(34, 34, 34); white-space: nowrap;"><span>=
Douglas Boffey</span></span><span style=3D"color: rgb(34, 34, 34); white-sp=
ace: nowrap;">&nbsp;says that my first suggestion will break&nbsp;</span><s=
pan style=3D"white-space: nowrap;">compatibility - I already explained my s=
olution for this problem. Compilers will at first have the option to compil=
e old code using this construct, but will display a warning. You see - that=
 the standard changes for better, doesn't means compilers implement it at a=
ll.</span></div></div></div></blockquote><div>&nbsp;</div><div>I understand=
 that&nbsp;parts of the language could be deprecated, and then used differe=
ntly, but that would be a last resort.&nbsp; Suppose you have a library tha=
t worked fine, only to find that&nbsp;a future version of C++ frowned upon =
it, and eventually, it refused to compile.&nbsp; Suppose that the library w=
as written for&nbsp;C, and continued to work fine for that, but became unus=
able for C++.</div><div>&nbsp;</div><div>Besides, if a function was expecti=
ng a pointer to an array, wouldn=E2=80=99t&nbsp;a declaration along the lin=
es of:</div><div>&nbsp;</div><div style=3D"border: 1px solid rgb(187, 187, =
187); word-wrap: break-word; background-color: rgb(250, 250, 250);" class=
=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint">=
<span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">void</s=
pan><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> foo<=
/span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify"=
>(</span><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify=
">int</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettif=
y"> bar</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-p=
rettify">[])</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-=
prettify"><br></span></div></code></div><br><div>&nbsp;</div><div>be better=
 than</div><div>&nbsp;</div><div style=3D"border: 1px solid rgb(187, 187, 1=
87); word-wrap: break-word; background-color: rgb(250, 250, 250);" class=3D=
"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint"><sp=
an style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">void</span=
><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> foo</sp=
an><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">(<=
/span><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">i=
nt</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify">=
 </span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettif=
y">*</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify=
">bar</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-pre=
ttify">)</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-pret=
tify"><br></span></div></code></div><div>As David said, if you really wante=
d an array that doesn=E2=80=99t decay into a pointer at the slightest provo=
cation, consider using std::array instead of a C array.</div><div>&nbsp;</d=
iv><div><blockquote style=3D"margin-right: 0px;" dir=3D"ltr"><div><font col=
or=3D"#000000" face=3D"Arial, Liberation Sans, DejaVu Sans, sans-serif"><sp=
an style=3D"line-height: 17.8px; font-size: 14px;">My second suggestion is =
allowing the creation of temporary</span></font><span style=3D'color: rgb(0=
, 0, 0); line-height: 17.8px; font-family: Arial,"Liberation Sans","DejaVu =
Sans",sans-serif; font-size: 14px;'>, uninitialized</span><font color=3D"#0=
00000" face=3D"Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style=
=3D"line-height: 17.8px; font-size: 14px;"> <wbr>arrays. This will be neede=
d if you want to implement a function returning pseudo arrays. It will look=
s something like this (this one will add the elements of two arrays and ret=
urn the result as a 'rvalue' reference to a temporary which will actually b=
e an unnamed variable in the calling scope, assigned as a default argument)=
:</span></font></div></blockquote><div><font color=3D"#000000" size=3D"2" f=
ace=3D"arial,sans-serif"><span style=3D"line-height: 17.8px;">Regarding def=
aulting a formal parameter to an initialised array, which is what your exam=
ple seems to suggest, you would then have to, presumably, pass a flag to th=
e function to indicate whether the parameter was given, and hence usable, o=
r not.&nbsp; This leads to fragile code.</span></font></div><div><font colo=
r=3D"#000000" size=3D"2" face=3D"arial,sans-serif"><span style=3D"line-heig=
ht: 17.8px;"></span></font>&nbsp;</div><div><font color=3D"#000000" size=3D=
"2" face=3D"arial,sans-serif"><span style=3D"line-height: 17.8px;">Not only=
 that, the compiler would not be able to match the flag with whether the da=
ta was usable or not, so couldn=E2=80=99t warn about using undefined data.&=
nbsp; Finally, if the data was not a POD, how could the compiler know wheth=
er a destructor would need to be called or not?</span></font></div><div><fo=
nt color=3D"#000000" size=3D"2" face=3D"arial,sans-serif"><span style=3D"li=
ne-height: 17.8px;"></span></font>&nbsp;</div><div><font color=3D"#000000" =
size=3D"2" face=3D"arial,sans-serif"><span style=3D"line-height: 17.8px;"><=
/span></font>&nbsp;</div><div><font color=3D"#000000" face=3D"Arial, Libera=
tion Sans, DejaVu Sans, sans-serif"><span style=3D"line-height: 17.8px; fon=
t-size: 14px;"></span></font>&nbsp;</div></div></div>

<p></p>

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

------=_Part_2504_767852613.1416825339334--
------=_Part_2503_463862289.1416825339334--

.


Author: sasho648 <sasho648@mail.bg>
Date: Mon, 24 Nov 2014 03:21:56 -0800 (PST)
Raw View
------=_Part_2614_247374021.1416828116320
Content-Type: multipart/alternative;
 boundary="----=_Part_2615_86830355.1416828116320"

------=_Part_2615_86830355.1416828116320
Content-Type: text/plain; charset=UTF-8

About the second suggestion - I'm talking about an optional output *value *as
my examples shows. Maybe sometimes you'll want to store some data, but
other times you wouldn't care. In the second case defaulting a formal
reference parameter with an uninitialized temporary data is a good
solution. So if we have a function like this for example:

void DoSomeThingsAndStoreSomeData(void *&&pData = (void *)()) ;


And if we want to benefit from the data we will use an actual nammed
variable but other times if we don't care about it, but we still want the
function to do the 'other things' for us we will just call it with no
arguments. For now this is possible only if we use an actual data as
initialization for the temporary like this:


void DoSomeThingsAndStoreSomeData(void *&&pData = nullptr) ;

This doesn't seems to be a lot of a performance issue but imagine if the
optional output data is some long array like this:

void DoSomeThingsAndStoreSomeData(int (&&pData)[260] = {} ) ;

Then if we don't care about the output when calling it, the compiler will
add a code like this before instancing (illustrative) :

int unnamed[260];

for(size_t i(0); i < 260; ++i)

    unnamed[i] = 0;



DoSomeThingsAndStoreSomeData(unnamed);

But if there is a way to declare unnamed, uninitialized complex types like
this:

void DoSomeThingsAndStoreSomeData(int (&&pData)[260] = (int [260])() ) ;

The above long and performance costing code wouldn't be included. You see
my point now?

About the first suggestion. No it wouldn't be better, the first function
declarations should means something like (if copying arrays was allowed):

template<size_t szArr>
void foo(int bar[szArr]);

The same could be done using structures (or the new 'array' library):

template<size_t szArr>
void foo(array<int, szArr> bar);


Which is quiet different than:

void foo(int *bar);

The first one will declare an function template with one parameter which
will tell the size of the array passed. So depending on it different
functions will be created with different call-stacks to store different
sized arrays.

The second one declares function with a simple pointer type parameter. You
see - there is a big difference and the fact that the first syntax is
not implemented, confuses many programmers (and I'm not the only one that
says this).

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

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

<div dir=3D"ltr">About the second suggestion - I'm talking about an optiona=
l output <b>value&nbsp;</b>as my examples shows. Maybe sometimes you'll wan=
t to store some data, but other times you wouldn't care. In the second case=
 <span style=3D"color: rgb(0, 0, 0); font-family: arial, sans-serif; font-s=
ize: small; line-height: 17.7999992370605px;">defaulting a formal reference=
 parameter with an&nbsp;</span><span style=3D"color: rgb(136, 0, 0); font-f=
amily: monospace; background-color: rgb(250, 250, 250);">uninitialized temp=
orary&nbsp;</span><span style=3D"background-color: rgb(250, 250, 250); line=
-height: 17.7999992370605px;"><font color=3D"#000000" face=3D"arial, sans-s=
erif" size=3D"2">data is a good solution. So if we have a function like thi=
s for example:<br><br></font></span><div class=3D"prettyprint" style=3D"bor=
der: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color:=
 rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettypr=
int"><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #606;" class=3D"styled-by-prettify">DoSomeThingsAndStoreSomeDat=
a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">*&amp;&amp;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">pData </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
*)())</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span></div>=
</code></div><span style=3D"color: rgb(0, 0, 0); font-family: arial, sans-s=
erif; font-size: small; line-height: 17.7999992370605px; background-color: =
rgb(250, 250, 250);"><br><br>And if we want to benefit from the data we wil=
l use an actual nammed variable but other times if we don't care about it, =
but we still want the function to do the 'other things' for us we will just=
 call it with no arguments. For now this is possible only if we use an actu=
al data as initialization for the temporary like this:<br><br><br></span><d=
iv class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); wor=
d-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=3D"p=
rettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">DoSomeThingsAndStoreSomeData</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">*&amp;&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">pData </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">nullptr</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">)</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"><br></span></div></code></div><span class=3D"=
styled-by-prettify" style=3D"font-family: monospace; color: rgb(102, 102, 0=
); background-color: rgb(250, 250, 250);"><br></span><span style=3D"color: =
rgb(0, 0, 0); font-family: arial, sans-serif; font-size: small; line-height=
: 17.7999992370605px; background-color: rgb(250, 250, 250);">This doesn't s=
eems to be a lot of a performance issue but imagine if the optional output =
data is some long array like this:<br><br></span><div class=3D"prettyprint"=
 style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; back=
ground-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">void</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #606;" class=3D"styled-by-prettify">DoSomeThings=
AndStoreSomeData</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(&amp;&amp;</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">pData</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">)[</span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">260</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">]</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">{}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">;</span></div></code></div><span=
 class=3D"styled-by-prettify" style=3D"font-family: monospace; color: rgb(1=
02, 102, 0); background-color: rgb(250, 250, 250);"><br></span><span style=
=3D"color: rgb(0, 0, 0); font-family: arial, sans-serif; font-size: small; =
line-height: 17.7999992370605px; background-color: rgb(250, 250, 250);">The=
n if we don't care about the output when calling it,&nbsp;</span><span styl=
e=3D"color: rgb(0, 0, 0); font-family: arial, sans-serif; font-size: small;=
 line-height: 17.7999992370605px; background-color: rgb(250, 250, 250);">th=
e compiler</span><span style=3D"color: rgb(0, 0, 0); font-family: arial, sa=
ns-serif; font-size: small; line-height: 17.7999992370605px; background-col=
or: rgb(250, 250, 250);">&nbsp;will add a code like this before instancing =
(illustrative) :<br><br></span><div class=3D"prettyprint" style=3D"border: =
1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(=
250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint">=
<span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> unnamed</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"col=
or: #066;" class=3D"styled-by-prettify">260</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">];</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">for</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">size_t i</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(</span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> i </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #06=
6;" class=3D"styled-by-prettify">260</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">++</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
i</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nb=
sp; unnamed</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>[</span><span style=3D"color: #000;" class=3D"styled-by-prettify">i</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">0</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br><br><br><br></span><span style=3D"color: #606;" class=3D"styled-b=
y-prettify">DoSomeThingsAndStoreSomeData</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">unnamed</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">);</span></div></code></div><div><span style=3D"color: rg=
b(0, 0, 0); font-family: monospace; background-color: rgb(250, 250, 250);">=
<br></span></div><div><span style=3D"background-color: rgb(250, 250, 250);"=
><font color=3D"#000000" face=3D"monospace">But if there is a way to declar=
e unnamed,&nbsp;uninitialized complex types like this:</font><br></span><sp=
an style=3D"color: rgb(0, 0, 0); font-family: monospace; background-color: =
rgb(250, 250, 250);"><br></span></div><div><div class=3D"prettyprint" style=
=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background=
-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subp=
rettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">void<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #606;" class=3D"styled-by-prettify">DoSomeThingsAndStore=
SomeData</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(<=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(&amp;&amp;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">pData</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">)[</span><span style=3D"color: =
#066;" class=3D"styled-by-prettify">260</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">260</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">])()</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">;<=
/span></div></code></div><span class=3D"styled-by-prettify" style=3D"font-f=
amily: monospace; color: rgb(102, 102, 0); background-color: rgb(250, 250, =
250);"><br></span><span style=3D"color: rgb(0, 0, 0); font-family: monospac=
e; background-color: rgb(250, 250, 250);">The above long and performance co=
sting code wouldn't be included. You see my point now?</span></div><div><sp=
an style=3D"color: rgb(0, 0, 0); font-family: monospace; background-color: =
rgb(250, 250, 250);"><br></span></div><div><span style=3D"color: rgb(0, 0, =
0); font-family: monospace; background-color: rgb(250, 250, 250);">About th=
e first suggestion. No it wouldn't be better, the first function declaratio=
ns should means something like (if copying arrays was allowed):<br><br></sp=
an><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187)=
; word-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">template</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">size_t szArr</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&gt;</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 style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> foo</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> bar</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">szArr</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">]);</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span></div></code></div></div><div=
><span style=3D"color: rgb(102, 102, 0); font-family: monospace; background=
-color: rgb(250, 250, 250);"><br></span></div><div><span style=3D"color: rg=
b(102, 102, 0); font-family: monospace; background-color: rgb(250, 250, 250=
);">The same could be done using structures (or the new 'array' library):<b=
r><br></span><span class=3D"styled-by-prettify" style=3D"font-family: monos=
pace; color: rgb(0, 0, 136); background-color: rgb(250, 250, 250);"></span>=
</div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 1=
87); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code cl=
ass=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">template</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">size_t szArr</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> foo</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">array<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> szArr</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> bar</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">);</span></div></code></div><div><span style=3D"c=
olor: rgb(0, 0, 0); font-family: monospace; background-color: rgb(250, 250,=
 250);"><br></span></div><div><span style=3D"color: rgb(102, 102, 0); font-=
family: monospace; background-color: rgb(250, 250, 250);"><br></span></div>=
<div><span style=3D"color: rgb(102, 102, 0); font-family: monospace; backgr=
ound-color: rgb(250, 250, 250);">Which is quiet different than:<br><br></sp=
an><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187)=
; word-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> foo</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">int</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">bar</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">);</span></div></code><=
/div><span style=3D"background-color: rgb(250, 250, 250);"><div style=3D"co=
lor: rgb(102, 102, 0); font-family: monospace;"><span style=3D"font-family:=
 monospace; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);"=
><br></span></div><font color=3D"#666600" face=3D"monospace">The first one =
will declare an function template with one parameter which will tell the si=
ze of the array passed. So depending on it different functions will be crea=
ted with different call-stacks to store different sized arrays.</font><br><=
br><font color=3D"#666600" face=3D"monospace">The second one declares funct=
ion with a simple pointer type parameter. You see - there is a big differen=
ce and the fact that the first syntax is not&nbsp;implemented, confuses man=
y programmers (and I'm not the only one that says this).</font><br></span><=
span style=3D"color: rgb(102, 102, 0); font-family: monospace; background-c=
olor: rgb(250, 250, 250);"><br></span></div></div>

<p></p>

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

------=_Part_2615_86830355.1416828116320--
------=_Part_2614_247374021.1416828116320--

.


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Mon, 24 Nov 2014 03:43:55 -0800 (PST)
Raw View
------=_Part_1673_1599995279.1416829435611
Content-Type: multipart/alternative;
 boundary="----=_Part_1674_330426419.1416829435611"

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


On Monday, 24 November 2014 11:21:56 UTC, sasho648 wrote:
>
> About the second suggestion - I'm talking about an optional output=20
> *value *as my examples shows. Maybe sometimes you'll want to store some=
=20
> data, but other times you wouldn't care. In the second case defaulting a=
=20
> formal reference parameter with an uninitialized temporary data is a good=
=20
> solution. So if we have a function like this for example:
>
> void DoSomeThingsAndStoreSomeData(void *&&pData =3D (void *)()) ;
>
>
> And if we want to benefit from the data we will use an actual nammed=20
> variable but other times if we don't care about it, but we still want the=
=20
> function to do the 'other things' for us we will just call it with no=20
> arguments. For now this is possible only if we use an actual data as=20
> initialization for the temporary like this:
>
>
> void DoSomeThingsAndStoreSomeData(void *&&pData =3D nullptr) ;
>
> This doesn't seems to be a lot of a performance issue but imagine if the=
=20
> optional output data is some long array like this:
>
> void DoSomeThingsAndStoreSomeData(int (&&pData)[260] =3D {} ) ;
>
> Then if we don't care about the output when calling it, the compiler will=
=20
> add a code like this before instancing (illustrative) :
>
> int unnamed[260];
>
> for(size_t i(0); i < 260; ++i)
>
>     unnamed[i] =3D 0;
>
>
>
> DoSomeThingsAndStoreSomeData(unnamed);
>
> But if there is a way to declare unnamed, uninitialized complex types lik=
e=20
> this:
>
> void DoSomeThingsAndStoreSomeData(int (&&pData)[260] =3D (int [260])() ) =
;
>
> The above long and performance costing code wouldn't be included. You see=
=20
> my point now?
>
=20
Not really, but I=E2=80=99ll let it go.=20

>
> About the first suggestion. No it wouldn't be better, the first function=
=20
> declarations should means something like (if copying arrays was allowed):
>
> template<size_t szArr>
> void foo(int bar[szArr]);
>
> The same could be done using structures (or the new 'array' library):
>
> template<size_t szArr>
> void foo(array<int, szArr> bar);
>
>
> Which is quiet different than:
>
> void foo(int *bar);
>
> The first one will declare an function template with one parameter which=
=20
> will tell the size of the array passed. So depending on it different=20
> functions will be created with different call-stacks to store different=
=20
> sized arrays.
>
> The second one declares function with a simple pointer type parameter. Yo=
u=20
> see - there is a big difference and the fact that the first syntax is=20
> not implemented, confuses many programmers (and I'm not the only one that=
=20
> says this).
>
=20
Although I see what you want, I would question if passing an array by value=
=20
would be a good idea anyway.  For me, I would not pass anything more=20
compilcated than an inbuilt type or an enum by value, due to performance=20
reasons.
=20
=20

--=20

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

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

<div dir=3D"ltr"><br>On Monday, 24 November 2014 11:21:56 UTC, sasho648  wr=
ote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; bord=
er-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-styl=
e: solid;" class=3D"gmail_quote"><div dir=3D"ltr">About the second suggesti=
on - I'm talking about an optional output <b>value&nbsp;</b>as my examples =
shows. Maybe sometimes you'll want to store some data, but other times you =
wouldn't care. In the second case <span style=3D"color: rgb(0, 0, 0); line-=
height: 17.79px; font-family: arial,sans-serif; font-size: small;">defaulti=
ng a formal reference parameter with an&nbsp;</span><span style=3D"color: r=
gb(136, 0, 0); font-family: monospace; background-color: rgb(250, 250, 250)=
;">uninitialized temporary&nbsp;</span><span style=3D"line-height: 17.79px;=
 background-color: rgb(250, 250, 250);"><font color=3D"#000000" size=3D"2" =
face=3D"arial, sans-serif">data is a good solution. So if we have a functio=
n like this for example:<br><br></font></span><div style=3D"border: 1px sol=
id rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 25=
0, 250);"><code><div><span style=3D"color: rgb(0, 0, 136);">void</span><spa=
n style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, =
102);">DoSomeThingsAndStoreSomeData</span><span style=3D"color: rgb(102, 10=
2, 0);">(</span><span style=3D"color: rgb(0, 0, 136);">v<wbr>oid</span><spa=
n style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102=
, 0);">*&amp;&amp;</span><span style=3D"color: rgb(0, 0, 0);">pData </span>=
<span style=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: rg=
b(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">(</span><span=
 style=3D"color: rgb(0, 0, 136);">void</span><span style=3D"color: rgb(0, 0=
, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">*)())</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0=
);">;</span></div></code></div><span style=3D"color: rgb(0, 0, 0); line-hei=
ght: 17.79px; font-family: arial,sans-serif; font-size: small; background-c=
olor: rgb(250, 250, 250);"><br><br>And if we want to benefit from the data =
we will use an actual nammed variable but other times if we don't care abou=
t it, but we still want the function to do the 'other things' for us we wil=
l just call it with no arguments. For now this is possible only if we use a=
n actual data as initialization for the temporary like this:<br><br><br></s=
pan><div style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-wo=
rd; background-color: rgb(250, 250, 250);"><code><div><span style=3D"color:=
 rgb(0, 0, 136);">void</span><span style=3D"color: rgb(0, 0, 0);"> </span><=
span style=3D"color: rgb(102, 0, 102);">DoSomeThingsAndStoreSomeData</span>=
<span style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(=
0, 0, 136);">v<wbr>oid</span><span style=3D"color: rgb(0, 0, 0);"> </span><=
span style=3D"color: rgb(102, 102, 0);">*&amp;&amp;</span><span style=3D"co=
lor: rgb(0, 0, 0);">pData </span><span style=3D"color: rgb(102, 102, 0);">=
=3D</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color=
: rgb(0, 0, 136);">nullptr</span><span style=3D"color: rgb(102, 102, 0);">)=
</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: r=
gb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br></span><=
/div></code></div><span style=3D"color: rgb(102, 102, 0); font-family: mono=
space; background-color: rgb(250, 250, 250);"><br></span><span style=3D"col=
or: rgb(0, 0, 0); line-height: 17.79px; font-family: arial,sans-serif; font=
-size: small; background-color: rgb(250, 250, 250);">This doesn't seems to =
be a lot of a performance issue but imagine if the optional output data is =
some long array like this:<br><br></span><div style=3D"border: 1px solid rg=
b(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 25=
0);"><code><div><span style=3D"color: rgb(0, 0, 136);">void</span><span sty=
le=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);=
">DoSomeThingsAndStoreSomeData</span><span style=3D"color: rgb(102, 102, 0)=
;">(</span><span style=3D"color: rgb(0, 0, 136);">i<wbr>nt</span><span styl=
e=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);"=
>(&amp;&amp;</span><span style=3D"color: rgb(0, 0, 0);">pData</span><span s=
tyle=3D"color: rgb(102, 102, 0);">)[</span><span style=3D"color: rgb(0, 102=
, 102);">260</span><span style=3D"color: rgb(102, 102, 0);">]</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0=
);">=3D</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"c=
olor: rgb(102, 102, 0);">{}</span><span style=3D"color: rgb(0, 0, 0);"> </s=
pan><span style=3D"color: rgb(102, 102, 0);">)</span><span style=3D"color: =
rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">;</span></d=
iv></code></div><span style=3D"color: rgb(102, 102, 0); font-family: monosp=
ace; background-color: rgb(250, 250, 250);"><br></span><span style=3D"color=
: rgb(0, 0, 0); line-height: 17.79px; font-family: arial,sans-serif; font-s=
ize: small; background-color: rgb(250, 250, 250);">Then if we don't care ab=
out the output when calling it,&nbsp;</span><span style=3D"color: rgb(0, 0,=
 0); line-height: 17.79px; font-family: arial,sans-serif; font-size: small;=
 background-color: rgb(250, 250, 250);">the compiler</span><span style=3D"c=
olor: rgb(0, 0, 0); line-height: 17.79px; font-family: arial,sans-serif; fo=
nt-size: small; background-color: rgb(250, 250, 250);">&nbsp;will add a cod=
e like this before instancing (illustrative) :<br><br></span><div style=3D"=
border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-col=
or: rgb(250, 250, 250);"><code><div><span style=3D"color: rgb(0, 0, 136);">=
int</span><span style=3D"color: rgb(0, 0, 0);"> unnamed</span><span style=
=3D"color: rgb(102, 102, 0);">[</span><span style=3D"color: rgb(0, 102, 102=
);">260</span><span style=3D"color: rgb(102, 102, 0);">];</span><span style=
=3D"color: rgb(0, 0, 0);"><br><br></span><span style=3D"color: rgb(0, 0, 13=
6);">for</span><span style=3D"color: rgb(102, 102, 0);">(</span><span style=
=3D"color: rgb(0, 0, 0);">size_t i</span><span style=3D"color: rgb(102, 102=
, 0);">(</span><span style=3D"color: rgb(0, 102, 102);">0</span><span style=
=3D"color: rgb(102, 102, 0);">);</span><span style=3D"color: rgb(0, 0, 0);"=
> i </span><span style=3D"color: rgb(102, 102, 0);">&lt;</span><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102, 102);">=
260</span><span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"c=
olor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">++</s=
pan><span style=3D"color: rgb(0, 0, 0);">i</span><span style=3D"color: rgb(=
102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br><br>&nbsp; =
&nbsp; unnamed</span><span style=3D"color: rgb(102, 102, 0);">[</span><span=
 style=3D"color: rgb(0, 0, 0);">i</span><span style=3D"color: rgb(102, 102,=
 0);">]</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"c=
olor: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, 0, 0);"> </=
span><span style=3D"color: rgb(0, 102, 102);">0</span><span style=3D"color:=
 rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br><br><b=
r><br></span><span style=3D"color: rgb(102, 0, 102);">DoSomeThingsAndStoreS=
omeData</span><span style=3D"color: rgb(102, 102, 0);">(</span><span style=
=3D"color: rgb(0, 0, 0);">u<wbr>nnamed</span><span style=3D"color: rgb(102,=
 102, 0);">);</span></div></code></div><div><span style=3D"color: rgb(0, 0,=
 0); font-family: monospace; background-color: rgb(250, 250, 250);"><br></s=
pan></div><div><span style=3D"background-color: rgb(250, 250, 250);"><font =
color=3D"#000000" face=3D"monospace">But if there is a way to declare unnam=
ed,&nbsp;uninitialized complex types like this:</font><br></span><span styl=
e=3D"color: rgb(0, 0, 0); font-family: monospace; background-color: rgb(250=
, 250, 250);"><br></span></div><div><div style=3D"border: 1px solid rgb(187=
, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);">=
<code><div><span style=3D"color: rgb(0, 0, 136);">void</span><span style=3D=
"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">DoS=
omeThingsAndStoreSomeData</span><span style=3D"color: rgb(102, 102, 0);">(<=
/span><span style=3D"color: rgb(0, 0, 136);">i<wbr>nt</span><span style=3D"=
color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">(&am=
p;&amp;</span><span style=3D"color: rgb(0, 0, 0);">pData</span><span style=
=3D"color: rgb(102, 102, 0);">)[</span><span style=3D"color: rgb(0, 102, 10=
2);">260</span><span style=3D"color: rgb(102, 102, 0);">]</span><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">=
=3D</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color=
: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 136);">int</sp=
an><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(1=
02, 102, 0);">[</span><span style=3D"color: rgb(0, 102, 102);">260</span><s=
pan style=3D"color: rgb(102, 102, 0);">])()</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">)</span><span =
style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, =
0);">;</span></div></code></div><span style=3D"color: rgb(102, 102, 0); fon=
t-family: monospace; background-color: rgb(250, 250, 250);"><br></span><spa=
n style=3D"color: rgb(0, 0, 0); font-family: monospace; background-color: r=
gb(250, 250, 250);">The above long and performance costing code wouldn't be=
 included. You see my point now?</span></div></div></blockquote><div>&nbsp;=
</div><div>Not really, but I=E2=80=99ll let it&nbsp;go.&nbsp;</div><blockqu=
ote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-colo=
r: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;" c=
lass=3D"gmail_quote"><div dir=3D"ltr"><div><span style=3D"color: rgb(0, 0, =
0); font-family: monospace; background-color: rgb(250, 250, 250);"><br></sp=
an></div><div><span style=3D"color: rgb(0, 0, 0); font-family: monospace; b=
ackground-color: rgb(250, 250, 250);">About the first suggestion. No it wou=
ldn't be better, the first function declarations should means something lik=
e (if copying arrays was allowed):<br><br></span><div style=3D"border: 1px =
solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250,=
 250, 250);"><code><div><span style=3D"color: rgb(0, 0, 136);">template</sp=
an><span style=3D"color: rgb(102, 102, 0);">&lt;</span><span style=3D"color=
: rgb(0, 0, 0);">size_t szArr</span><span style=3D"color: rgb(102, 102, 0);=
">&gt;</span><span style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D=
"color: rgb(0, 0, 136);">void</span><span style=3D"color: rgb(0, 0, 0);"> f=
oo</span><span style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"co=
lor: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(0, 0, 0);"> bar</=
span><span style=3D"color: rgb(102, 102, 0);">[</span><span style=3D"color:=
 rgb(0, 0, 0);">szArr</span><span style=3D"color: rgb(102, 102, 0);">]);</s=
pan><span style=3D"color: rgb(0, 0, 0);"><br></span></div></code></div></di=
v><div><span style=3D"color: rgb(102, 102, 0); font-family: monospace; back=
ground-color: rgb(250, 250, 250);"><br></span></div><div><span style=3D"col=
or: rgb(102, 102, 0); font-family: monospace; background-color: rgb(250, 25=
0, 250);">The same could be done using structures (or the new 'array' libra=
ry):<br><br></span><span style=3D"color: rgb(0, 0, 136); font-family: monos=
pace; background-color: rgb(250, 250, 250);"></span></div><div style=3D"bor=
der: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color:=
 rgb(250, 250, 250);"><code><div><span style=3D"color: rgb(0, 0, 136);">tem=
plate</span><span style=3D"color: rgb(102, 102, 0);">&lt;</span><span style=
=3D"color: rgb(0, 0, 0);">size_t szArr</span><span style=3D"color: rgb(102,=
 102, 0);">&gt;</span><span style=3D"color: rgb(0, 0, 0);"><br></span><span=
 style=3D"color: rgb(0, 0, 136);">void</span><span style=3D"color: rgb(0, 0=
, 0);"> foo</span><span style=3D"color: rgb(102, 102, 0);">(</span><span st=
yle=3D"color: rgb(0, 0, 0);">array</span><span style=3D"color: rgb(102, 102=
, 0);">&lt;</span><span style=3D"color: rgb(0, 0, 136);">int</span><span st=
yle=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0)=
;"> szArr</span><span style=3D"color: rgb(102, 102, 0);">&gt;</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> bar</span><span style=3D"color: rgb(102, 102=
, 0);">);</span></div></code></div><div><span style=3D"color: rgb(0, 0, 0);=
 font-family: monospace; background-color: rgb(250, 250, 250);"><br></span>=
</div><div><span style=3D"color: rgb(102, 102, 0); font-family: monospace; =
background-color: rgb(250, 250, 250);"><br></span></div><div><span style=3D=
"color: rgb(102, 102, 0); font-family: monospace; background-color: rgb(250=
, 250, 250);">Which is quiet different than:<br><br></span><div style=3D"bo=
rder: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color=
: rgb(250, 250, 250);"><code><div><span style=3D"color: rgb(0, 0, 136);">vo=
id</span><span style=3D"color: rgb(0, 0, 0);"> foo</span><span style=3D"col=
or: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 136);">int</=
span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb=
(102, 102, 0);">*</span><span style=3D"color: rgb(0, 0, 0);">bar</span><spa=
n style=3D"color: rgb(102, 102, 0);">);</span></div></code></div><span styl=
e=3D"background-color: rgb(250, 250, 250);"><div style=3D"color: rgb(102, 1=
02, 0); font-family: monospace;"><span style=3D"color: rgb(102, 102, 0); fo=
nt-family: monospace; background-color: rgb(250, 250, 250);"><br></span></d=
iv><font color=3D"#666600" face=3D"monospace">The first one will declare an=
 function template with one parameter which will tell the size of the array=
 passed. So depending on it different functions will be created with differ=
ent call-stacks to store different sized arrays.</font><br><br><font color=
=3D"#666600" face=3D"monospace">The second one declares function with a sim=
ple pointer type parameter. You see - there is a big difference and the fac=
t that the first syntax is not&nbsp;implemented, confuses many programmers =
(and I'm not the only one that says this).</font></span></div></div></block=
quote><div>&nbsp;</div><div>Although I see what you want, I would question&=
nbsp;if passing an array by value would be a good idea anyway.&nbsp; For me=
,&nbsp;I would&nbsp;not pass anything more compilcated than an inbuilt type=
 or an enum by value,&nbsp;due to performance reasons.</div><div>&nbsp;</di=
v><div>&nbsp;</div></div>

<p></p>

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

------=_Part_1674_330426419.1416829435611--
------=_Part_1673_1599995279.1416829435611--

.


Author: Bo Persson <bop@gmb.dk>
Date: Mon, 24 Nov 2014 17:43:14 +0100
Raw View
On 2014-11-24 00:16, sasho648 wrote:
> My first suggestion is banning function params to be declared as arrays
> because their real meaning isn't tolerated - being an actual arrays but
> instead they are always converted to pointers. This is confusing and
> most of the time imposes unwanted behavior. Better tell the user that
> you can't implement a feature rather than giving him another totally
> different. My suggestion is already applied when returning arrays from a
> function - instead of implicitly casting to a pointer type, the compiler
> shows us an error message.
>
> NOTE: The wanted behavior is that when you declare an param as array -
> the argument passed to it will be copied, instead of just referred, by
> using a pointer.
>

This is not a bad proposal, but 40 years too late.


Bo Persson



--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: sasho648 <sasho648@mail.bg>
Date: Mon, 24 Nov 2014 15:14:17 -0800 (PST)
Raw View
------=_Part_772_1858418683.1416870857934
Content-Type: multipart/alternative;
 boundary="----=_Part_773_1440643213.1416870857934"

------=_Part_773_1440643213.1416870857934
Content-Type: text/plain; charset=UTF-8


>
> @Douglas Boffey  "Not really" is not an argument. And I'm not proposing
> to include 'passing an array by value' but just to drop support for this
> misleading syntax of 'array' formal parameters.


@Bo Persson   40, 60 - is this really an useful post?

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

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

<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><span class=
=3D"_username" style=3D"white-space: nowrap;"><span class=3D"GBT-Y1EDJ-B g-=
hovercard" data-userid=3D"105548083684085355974" data-name=3D"Douglas Boffe=
y">@Douglas Boffey</span></span><span style=3D"white-space: nowrap;">&nbsp;=
&nbsp;</span>"Not really" is not an argument. And I'm not proposing to incl=
ude 'passing an array by value' but just to drop support for this misleadin=
g syntax of 'array' formal parameters.</blockquote><div><br></div><div><spa=
n class=3D"_username" style=3D"white-space: nowrap;"><span class=3D"GBT-Y1E=
DJ-B">@Bo Persson</span></span><span style=3D"white-space: nowrap;">&nbsp;<=
/span>&nbsp;&nbsp;40, 60 - is this really an useful post?</div></div>

<p></p>

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

------=_Part_773_1440643213.1416870857934--
------=_Part_772_1858418683.1416870857934--

.


Author: sasho648 <sasho648@mail.bg>
Date: Mon, 24 Nov 2014 15:17:13 -0800 (PST)
Raw View
------=_Part_3478_64412693.1416871033974
Content-Type: multipart/alternative;
 boundary="----=_Part_3479_252373163.1416871033974"

------=_Part_3479_252373163.1416871033974
Content-Type: text/plain; charset=UTF-8

@Douglas Boffey  And I was just showing what one 'normal' people
will logically think one such construct will mean.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

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

<div dir=3D"ltr">@<span class=3D"_username" style=3D"white-space: nowrap;">=
<span class=3D"GBT-Y1EDJ-B g-hovercard" data-userid=3D"10554808368408535597=
4" data-name=3D"Douglas Boffey">Douglas Boffey</span></span><span style=3D"=
white-space: nowrap;">&nbsp;&nbsp;</span>And I was just showing what one 'n=
ormal' people will&nbsp;logically&nbsp;think one such construct will mean.<=
/div>

<p></p>

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

------=_Part_3479_252373163.1416871033974--
------=_Part_3478_64412693.1416871033974--

.


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Tue, 25 Nov 2014 03:43:34 -0800 (PST)
Raw View
------=_Part_110_458763094.1416915814542
Content-Type: multipart/alternative;
 boundary="----=_Part_111_965028128.1416915814543"

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


On Monday, 24 November 2014 23:14:17 UTC, sasho648 wrote:=20
>
>  @Douglas Boffey  "Not really" is not an argument. And I'm not proposing=
=20
>> to include 'passing an array by value' but just to drop support for this=
=20
>> misleading syntax of 'array' formal parameters.
>
> That was meant as a reply to =E2=80=9CYou see my point now?=E2=80=9D, not=
 about the=20
proposal.

--=20

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

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

<div dir=3D"ltr"><BR>On Monday, 24 November 2014 23:14:17 UTC, sasho648 wro=
te:=20
<BLOCKQUOTE style=3D"BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex=
; PADDING-LEFT: 1ex" class=3Dgmail_quote>
<DIV dir=3Dltr>
<BLOCKQUOTE style=3D"BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex=
; PADDING-LEFT: 1ex" class=3Dgmail_quote><SPAN style=3D"WHITE-SPACE: nowrap=
"><SPAN>@Douglas Boffey</SPAN></SPAN><SPAN style=3D"WHITE-SPACE: nowrap">&n=
bsp;&nbsp;</SPAN>"Not really" is not an argument. And I'm not proposing to =
include 'passing an array by value' but just to drop support for this misle=
ading syntax of 'array' formal parameters.</BLOCKQUOTE></DIV></BLOCKQUOTE>
<DIV>That was meant as a reply to =E2=80=9C<FONT color=3D#000000 face=3D"Co=
urier New">You see my point now?</FONT>=E2=80=9D, not about the proposal.</=
DIV></div>

<p></p>

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

------=_Part_111_965028128.1416915814543--
------=_Part_110_458763094.1416915814542--

.


Author: sasho648 <sasho648@mail.bg>
Date: Tue, 25 Nov 2014 04:19:09 -0800 (PST)
Raw View
------=_Part_3719_24097121.1416917949364
Content-Type: multipart/alternative;
 boundary="----=_Part_3720_1273387011.1416917949364"

------=_Part_3720_1273387011.1416917949364
Content-Type: text/plain; charset=UTF-8

@ Douglas Boffey  Exactly, better tell me what didn't you understand to not
see it then just telling me 'I don't see it'. I want to know if this could
be actually proposed so please explain yourself better. And my second
sentence was meant for yours "Although I see what you want, I would
question if passing an array by value would be a good idea anyway.  For
me, I would not pass anything more compilcated than an inbuilt type or an
enum by value, due to performance reasons." - to tell you that I'm *not*
proposing to include passing arrays by value.

@ Thiago Macieira  There is actually a very similar breaking change
introduced with 'C++ 11' which is the '
<http://stackoverflow.com/questions/4434140/narrowing-conversions-in-c0x-is-it-just-me-or-does-this-sound-like-a-breakin>*narrowing
conversion'
<http://stackoverflow.com/questions/4434140/narrowing-conversions-in-c0x-is-it-just-me-or-does-this-sound-like-a-breakin>. *Such
ill-formed constructions aren't something rare in 'old' C++ code, as the
question shows but fixing it is simple. And also many compilers are still
accepting it with only a warning (like 'gcc' for example). So I don't see
why can't the same happen with formal parameter arrays?

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

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

<div dir=3D"ltr"><span style=3D"color: rgb(136, 136, 136); line-height: 19.=
5px;">@&nbsp;</span><span role=3D"gridcell" style=3D"color: rgb(136, 136, 1=
36); line-height: 19.5px;"><span class=3D"_username"><span class=3D"GBT-Y1E=
DJ-B g-hovercard" data-userid=3D"105548083684085355974" data-name=3D"Dougla=
s Boffey" style=3D"color: rgb(34, 34, 34);">Douglas Boffey</span></span>&nb=
sp; Exactly, better tell me what didn't you understand to not see it then j=
ust telling me 'I don't see it'. I want to know if this could be actually p=
roposed so please explain yourself better. And my second sentence was meant=
 for yours "<span style=3D"color: rgb(34, 34, 34); line-height: normal;">Al=
though I see what you want, I would question&nbsp;if passing an array by va=
lue would be a good idea anyway.&nbsp; For me,&nbsp;I would&nbsp;not pass a=
nything more compilcated than an inbuilt type or an enum by value,&nbsp;due=
 to performance reasons." -&nbsp;</span>to tell you that I'm <b>not</b> pro=
posing to include passing arrays by value.<br></span><br><span class=3D"_us=
ername" style=3D"white-space: nowrap;"><span class=3D"GBT-Y1EDJ-B"><span st=
yle=3D"color: rgb(136, 136, 136); font-weight: normal; line-height: 19.5px;=
 white-space: normal;">@&nbsp;</span>Thiago Macieira</span></span><span sty=
le=3D"white-space: nowrap;">&nbsp; There is actually a very similar breakin=
g change introduced with 'C++ 11' which is the <a href=3D"http://stackoverf=
low.com/questions/4434140/narrowing-conversions-in-c0x-is-it-just-me-or-doe=
s-this-sound-like-a-breakin">'</a></span><em style=3D"font-size: 14px; colo=
r: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans=
-serif; line-height: 17.8048000335693px; background-image: initial; backgro=
und-attachment: initial; background-size: initial; background-origin: initi=
al; background-clip: initial; background-position: initial; background-repe=
at: initial;"><a href=3D"http://stackoverflow.com/questions/4434140/narrowi=
ng-conversions-in-c0x-is-it-just-me-or-does-this-sound-like-a-breakin">narr=
owing conversion'</a>.&nbsp;</em><span style=3D"white-space: nowrap;">Such =
ill-formed constructions aren't something rare in 'old' C++ code, as the qu=
estion shows but fixing it is simple. And also many compilers are still acc=
epting it with only a warning (like 'gcc' for example). So I don't see why =
can't the same happen with formal parameter arrays?</span><br></div>

<p></p>

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

------=_Part_3720_1273387011.1416917949364--
------=_Part_3719_24097121.1416917949364--

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Tue, 25 Nov 2014 12:37:38 -0500
Raw View
On 2014-11-25 12:04, Thiago Macieira wrote:
> Array parameters aren't wrong today and wherever they're used, they are used
> for legitimate uses. In fact, as recently as yesterday, I saw someone posting
> this:
>
>  int main(int argc, char *argv[])
>
> This is too ingrained in people's coding styles that arrays and pointers are
> the same thing.

What about deprecating just "sized" arrays?

IIUC, right now 'int foo[]' and 'int foo[3]' mean exactly the same thing
(as parameters) to the compiler. However I bet lots of people make the
mistake of thinking that specifying a size provides some additional
guarantees as to what can be passed.

> Anyway, C++ has a way to pass an actual array. I don't see why we should
> deviate even further from C.

....and deprecating would be a good way to encourage people to start
actually *using* better methods :-).

That said... std::array isn't always the answer. What if I need to pass
an "array" by reference, but the caller doesn't have a std::array?
(Maybe I want to do something to a subset of a larger block of memory,
or have a std::vector, or...)

It seems to me that we could use something like array_view with fixed
size that lets me pass a contiguous block of N objects by reference,
regardless of how those objects are actually managed. (Hmm, don't have
the proposal handy; would the current form of array_view provide that?)

--
Matthew

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Tue, 25 Nov 2014 13:08:54 -0500
Raw View
On 2014-11-25 12:50, Thiago Macieira wrote:
> On 2014-11-25 12:04, Thiago Macieira wrote:
>> Anyway, C++ has a way to pass an actual array. I don't see why we should
>> deviate even further from C.
>
> I wasn't talking about std::array. I meant passing the array by reference:
>
>  void f(int (&foo)[3])

Ah. Right, I've done that. However, I've run into instances where I
*want* to pass (part of) a larger array to such a function. It would be
nice to have a way to do that, that still has guarantees (static where
possible, runtime otherwise) that the passed array isn't too small.

A typical example is a function that works with RGB colors expressed as
tuples (usually float/double), but I want to use that on the RGB portion
of an RGBA array. (Interestingly, *GLSL* provides mechanisms for this
:-)...)

--
Matthew

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Myriachan <myriachan@gmail.com>
Date: Tue, 25 Nov 2014 12:53:50 -0800 (PST)
Raw View
------=_Part_334_2083907255.1416948830950
Content-Type: multipart/alternative;
 boundary="----=_Part_335_918435862.1416948830950"

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

On Tuesday, November 25, 2014 10:09:11 AM UTC-8, Matthew Woehlke wrote:
>
> On 2014-11-25 12:50, Thiago Macieira wrote:=20
> > On 2014-11-25 12:04, Thiago Macieira wrote:=20
> >> Anyway, C++ has a way to pass an actual array. I don't see why we=20
> should=20
> >> deviate even further from C.=20
> >=20
> > I wasn't talking about std::array. I meant passing the array by=20
> reference:=20
> >=20
> >         void f(int (&foo)[3])=20
>
> Ah. Right, I've done that. However, I've run into instances where I=20
> *want* to pass (part of) a larger array to such a function. It would be=
=20
> nice to have a way to do that, that still has guarantees (static where=20
> possible, runtime otherwise) that the passed array isn't too small.=20
>
> A typical example is a function that works with RGB colors expressed as=
=20
> tuples (usually float/double), but I want to use that on the RGB portion=
=20
> of an RGBA array. (Interestingly, *GLSL* provides mechanisms for this=20
> :-)...)=20
>
>
I've run into a similar problem, that you can't use a vector4 as a vector3,=
=20
except that they were vectors in =E2=84=9D=C2=B3, not color-space.  I think=
 that any=20
solution to this needs to address the annoyance that T(*)[S] doesn't decay=
=20
to T(*)[] implicitly, and likewise for references.  Similarly, removing the=
=20
pointless restriction that T(*)[] is an illegal function parameter type. =
=20
Then perhaps static_cast could be changed to permit converting from T(*)[S1=
]=20
to T(*)[S2] for S1 >=3D S2 in addition to the automatic decay?

Melissa

--=20

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

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

<div dir=3D"ltr">On Tuesday, November 25, 2014 10:09:11 AM UTC-8, Matthew W=
oehlke wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 2014-11-25 12:=
50, Thiago Macieira wrote:
<br>&gt; On 2014-11-25 12:04, Thiago Macieira wrote:
<br>&gt;&gt; Anyway, C++ has a way to pass an actual array. I don't see why=
 we should
<br>&gt;&gt; deviate even further from C.
<br>&gt;=20
<br>&gt; I wasn't talking about std::array. I meant passing the array by re=
ference:
<br>&gt;=20
<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;void f(int (&amp;f=
oo)[3])
<br>
<br>Ah. Right, I've done that. However, I've run into instances where I
<br>*want* to pass (part of) a larger array to such a function. It would be
<br>nice to have a way to do that, that still has guarantees (static where
<br>possible, runtime otherwise) that the passed array isn't too small.
<br>
<br>A typical example is a function that works with RGB colors expressed as
<br>tuples (usually float/double), but I want to use that on the RGB portio=
n
<br>of an RGBA array. (Interestingly, *GLSL* provides mechanisms for this
<br>:-)...)
<br>
<br></blockquote><div><br>I've run into a similar problem, that you can't u=
se a vector4 as a vector3, except that they were vectors in =E2=84=9D=C2=B3=
, not color-space.&nbsp; I think that any solution to this needs to address=
 the annoyance that <span style=3D"font-family: courier new,monospace;">T(*=
)[S]</span> doesn't decay to <span style=3D"font-family: courier new,monosp=
ace;">T(*)[]</span> implicitly, and likewise for references.&nbsp; Similarl=
y, removing the pointless restriction that <span style=3D"font-family: cour=
ier new,monospace;">T(*)[]</span> is an illegal function parameter type.&nb=
sp; Then perhaps <span style=3D"font-family: courier new,monospace;">static=
_cast</span> could be changed to permit converting from <span style=3D"font=
-family: courier new,monospace;">T(*)[S1]</span> to <span style=3D"font-fam=
ily: courier new,monospace;">T(*)[S2]</span> for <span style=3D"font-family=
: courier new,monospace;">S1</span> &gt;=3D <span style=3D"font-family: cou=
rier new,monospace;">S2</span> in addition to the automatic decay?<br><br>M=
elissa<br></div></div>

<p></p>

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

------=_Part_335_918435862.1416948830950--
------=_Part_334_2083907255.1416948830950--

.


Author: sasho648 <sasho648@mail.bg>
Date: Tue, 25 Nov 2014 14:00:41 -0800 (PST)
Raw View
------=_Part_4311_1513423660.1416952842331
Content-Type: multipart/alternative;
 boundary="----=_Part_4312_1315138552.1416952842331"

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



25 =D0=BD=D0=BE=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014, =D0=B2=D1=82=D0=BE=D1=
=80=D0=BD=D0=B8=D0=BA, 19:04:20 UTC+2, Thiago Macieira =D0=BD=D0=B0=D0=BF=
=D0=B8=D1=81=D0=B0:
>
> On Tuesday 25 November 2014 04:19:09 sasho648 wrote:=20
> > @ Thiago Macieira  There is actually a very similar breaking change=20
> > introduced with 'C++ 11' which is the '=20
> > <
> http://stackoverflow.com/questions/4434140/narrowing-conversions-in-c0x-i=
s->=20
> it-just-me-or-does-this-sound-like-a-breakin>*narrowing  conversion'=20
> > <
> http://stackoverflow.com/questions/4434140/narrowing-conversions-in-c0x-i=
s->=20
> it-just-me-or-does-this-sound-like-a-breakin>. *Such  ill-formed=20
> > constructions aren't something rare in 'old' C++ code, as the question=
=20
> > shows but fixing it is simple. And also many compilers are still=20
> accepting=20
> > it with only a warning (like 'gcc' for example). So I don't see why=20
> can't=20
> > the same happen with formal parameter arrays?=20
>
> The narrowing conversion problem passed the test I put forward. It had a=
=20
> very=20
> good reason for being and it help catch possibly broken code.=20
>
> Array parameters aren't wrong today and wherever they're used, they are=
=20
> used=20
> for legitimate uses. In fact, as recently as yesterday, I saw someone=20
> posting=20
> this:=20
>
>         int main(int argc, char *argv[])=20
>
> This is too ingrained in people's coding styles that arrays and pointers=
=20
> are=20
> the same thing.=20
>
> Anyway, C++ has a way to pass an actual array. I don't see why we should=
=20
> deviate even further from C.=20
> --=20
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org=20
>    Software Architect - Intel Open Source Technology Center=20
>       PGP/GPG: 0x6EF45358; fingerprint:=20
>       E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358=20
>
>
You're talking real? So in this case declaring a variable like this:

int *pArray;

will be the same as declaring it like this:


int pArray[200];

If you can't distinguish pointers from arrays you should really stop using=
=20
'C++' forever.

@Matthew Woehlke and @Zhihao Yuan=20

Thanks for the support. Yep I believe deprecating this special treatment=20
for arrays as formal parameters will definitely remove programmers=20
confusion and also prevent unwanted behavior if used with different indent.=
=20
For another argument I want to point out that return type of a function,=20
declared as array is not-allowed for the same reason as array formal=20
parameters are implicitly converted to pointers which is somehow strange=20
and add to the confusion. Why one-time when the feature is not supported=20
the language will not support it but another time it will implicitly=20
implement some other feature, as both of the requests are similar (if not=
=20
equal). Illustration:

Not legal:

int Func(int *)[5];

*Compiler thoughts:

An return value with an array type, I can't implement this so I'll stop=20
compiling and report the user.

Legal:

int *Func(int [5]);


*Compiler thoughts:

An argument with an array type, hmm - Let's not get the user mad again and=
=20
implicitly convert it to a pointer, I believe he will like that.

About the arrays of unknown bounds - I believe is a good idea to deprecate=
=20
them too as being a formal parameters because, they fall into category=20
'arrays' too. I see your thoughts that a pointer and an array with unknown=
=20
size can be written the same thing but if you use them as a variable=20
declarations, the difference will clearly occur. An example:

   =20
int *pArray;


int Array[] =3D {0, 1, 2, 3, 4};


pArray =3D Array;


cout << sizeof(Array) << endl;


cout << sizeof(pArray) << endl;


The difference of 'sizeof(Array)' and 'sizeof(pArray)' is clear and some=20
users could try to do the same in a function declared with a formal=20
parameter array with unknown bounds (named 'arg_0'), in which the=20
'sizeof(arg_0)' will not show the size of the actual array but instead of=
=20
it's first element pointer which is not an expected behavior.

--=20

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

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

<div dir=3D"ltr"><br><br>25 =D0=BD=D0=BE=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014=
, =D0=B2=D1=82=D0=BE=D1=80=D0=BD=D0=B8=D0=BA, 19:04:20 UTC+2, Thiago Maciei=
ra =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0:<blockquote class=3D"gmail_quote" s=
tyle=3D"margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-colo=
r: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">On Tue=
sday 25 November 2014 04:19:09 sasho648 wrote:&nbsp;<br>&gt; @ Thiago Macie=
ira &nbsp;There is actually a very similar breaking change&nbsp;<br>&gt; in=
troduced with 'C++ 11' which is the '&nbsp;<br>&gt; &lt;<a href=3D"http://s=
tackoverflow.com/questions/4434140/narrowing-conversions-in-c0x-is-" target=
=3D"_blank">http://stackoverflow.com/<wbr>questions/4434140/narrowing-<wbr>=
conversions-in-c0x-is-</a>&gt; it-just-me-or-does-this-sound-<wbr>like-a-br=
eakin&gt;*narrowing &nbsp;conversion'&nbsp;<br>&gt; &lt;<a href=3D"http://s=
tackoverflow.com/questions/4434140/narrowing-conversions-in-c0x-is-" target=
=3D"_blank">http://stackoverflow.com/<wbr>questions/4434140/narrowing-<wbr>=
conversions-in-c0x-is-</a>&gt; it-just-me-or-does-this-sound-<wbr>like-a-br=
eakin&gt;. *Such &nbsp;ill-formed&nbsp;<br>&gt; constructions aren't someth=
ing rare in 'old' C++ code, as the question&nbsp;<br>&gt; shows but fixing =
it is simple. And also many compilers are still accepting&nbsp;<br>&gt; it =
with only a warning (like 'gcc' for example). So I don't see why can't&nbsp=
;<br>&gt; the same happen with formal parameter arrays?&nbsp;<br><br>The na=
rrowing conversion problem passed the test I put forward. It had a very&nbs=
p;<br>good reason for being and it help catch possibly broken code.&nbsp;<b=
r><br>Array parameters aren't wrong today and wherever they're used, they a=
re used&nbsp;<br>for legitimate uses. In fact, as recently as yesterday, I =
saw someone posting&nbsp;<br>this:&nbsp;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;int main(int argc, char *argv[])&nbsp;<br><br>This is =
too ingrained in people's coding styles that arrays and pointers are&nbsp;<=
br>the same thing.&nbsp;<br><br>Anyway, C++ has a way to pass an actual arr=
ay. I don't see why we should&nbsp;<br>deviate even further from C.&nbsp;<b=
r>--&nbsp;<br>Thiago Macieira - thiago (AT)&nbsp;<a href=3D"http://macieira=
..info/" target=3D"_blank">macieira.info</a>&nbsp;- thiago (AT)&nbsp;<a href=
=3D"http://kde.org/" target=3D"_blank">kde.org</a>&nbsp;<br>&nbsp; &nbsp;So=
ftware Architect - Intel Open Source Technology Center&nbsp;<br>&nbsp; &nbs=
p; &nbsp; PGP/GPG: 0x6EF45358; fingerprint:&nbsp;<br>&nbsp; &nbsp; &nbsp; E=
067 918B B660 DBD1 105C &nbsp;966C 33F5 F005 6EF4 5358&nbsp;<br><br></block=
quote><div><br></div><div>You're talking real? So in this case declaring a =
variable like this:<br><br><div class=3D"prettyprint" style=3D"border: 1px =
solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250,=
 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">int</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">pArray</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">;</span></div></code></div><div><br></div>will be =
the same as&nbsp;declaring&nbsp;it like this:<br><br><br><div class=3D"pret=
typrint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-wo=
rd; background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div=
 class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> pArray</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[=
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">200</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">];</span></div></=
code></div><br>If you can't&nbsp;distinguish pointers from arrays you shoul=
d&nbsp;really stop using 'C++' forever.</div><div><br></div><div>@<span cla=
ss=3D"_username" style=3D"white-space: nowrap;"><span class=3D"GBT-Y1EDJ-B"=
>Matthew Woehlke</span></span><span style=3D"white-space: nowrap;">&nbsp;an=
d @</span><span class=3D"_username" style=3D"white-space: nowrap;"><span cl=
ass=3D"GBT-Y1EDJ-B">Zhihao Yuan</span></span><span style=3D"white-space: no=
wrap;">&nbsp;</span></div><div><span style=3D"white-space: nowrap;"><br></s=
pan></div><div><span style=3D"white-space: nowrap;">Thanks for the support.=
 Yep I believe&nbsp;</span>deprecating&nbsp;this special treatment for arra=
ys as formal parameters will definitely remove programmers confusion and al=
so prevent unwanted behavior if used with different indent. For another arg=
ument I want to point out that return type of a function, declared as array=
 is not-allowed for the same reason as array formal parameters are implicit=
ly converted to pointers which is somehow strange and add to the confusion.=
 Why one-time when the feature is not supported the language will not suppo=
rt it but another time it will implicitly implement some other feature, as =
both of the requests are similar (if not equal). Illustration:<br></div><di=
v><div><br></div>Not legal:<br><br><div class=3D"prettyprint" style=3D"bord=
er: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: =
rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettypri=
nt"><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Func</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">*)[</span><span style=3D"color: #066;" class=3D"styled-by-p=
rettify">5</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
];</span></div></code></div><br></div><div>*Compiler thoughts:<br><br>An re=
turn value with an array type, I can't implement this so I'll stop compilin=
g and report the user.<br></div><div><br></div><div><div>Legal:</div><div><=
br></div><div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187=
, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);">=
<code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">*</span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">Func</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span s=
tyle=3D"color: #066;" class=3D"styled-by-prettify">5</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">]);</span></div></code></div><div=
><br></div><div><br></div><div>*Compiler thoughts:<br><br>An argument with =
an array type, hmm - Let's not get the user mad again and implicitly conver=
t it to a pointer, I believe he will like that.</div></div></div><div><br><=
/div><div>About the arrays of unknown bounds - I believe is a good idea to =
deprecate them too as being a formal parameters because, they fall into cat=
egory 'arrays' too. I see your thoughts that a pointer and an array with un=
known size can be written the same thing but if you use them as a variable =
declarations, the difference will clearly occur. An example:<br><br><div>&n=
bsp; &nbsp;&nbsp;</div><div class=3D"prettyprint" style=3D"border: 1px soli=
d rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250=
, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">*</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">pArray</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br><br><br></span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Ar=
ray</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[]</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">=3D</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: #066;" cla=
ss=3D"styled-by-prettify">0</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">1=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">2</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"=
styled-by-prettify">3</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">4</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>pArray </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #606;" class=3D"styled-by-prettify">Array</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br><br><br>cout </span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">sizeof</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">Array</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">&lt;&lt;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> endl</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br></span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">cout </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">sizeof</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">pArray</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> endl</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan></div></code></div><div><br></div></div><div><br></div><div>The differe=
nce of 'sizeof(Array)' and 'sizeof(pArray)' is clear and some users could t=
ry to do the same in a function declared with a formal parameter array with=
 unknown bounds&nbsp;(named 'arg_0'), in which the 'sizeof(arg_0)' will not=
 show the size of the actual array but instead of it's first element pointe=
r which is not an expected behavior.</div></div>

<p></p>

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

------=_Part_4312_1315138552.1416952842331--
------=_Part_4311_1513423660.1416952842331--

.


Author: sasho648 <sasho648@mail.bg>
Date: Tue, 25 Nov 2014 14:16:52 -0800 (PST)
Raw View
------=_Part_736_651794238.1416953812243
Content-Type: multipart/alternative;
 boundary="----=_Part_737_391674719.1416953812243"

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

Also please discuss my second suggestion, which is a proposal to add a new=
=20
syntax with which you will be able to declare unnamed, uninitialized=20
variables of complex types (like array and pointers). This shall be needed=
=20
for 'arrays' returning by value implementations and optional output=20
parameters for functions, without using structures (because using them for=
=20
the propose will be just too messy). The syntax I purpose is very simple:

*(complex-type)()*

Which can be then used like:

(int *)() //constructs an unnamed, uninitialized object with a type pointer=
=20
to int


(int [5])() //constructs an unnamed, uninitialized object with a type array=
=20
of int with 5 elements

Here is the question =20
<http://stackoverflow.com/questions/27100629/c-how-to-declare-a-temporary-u=
nnamed-uninitialized-array>with=20
an example where it will be needed. And a quote of myself with another use.

24 =D0=BD=D0=BE=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014, =D0=BF=D0=BE=D0=BD=D0=
=B5=D0=B4=D0=B5=D0=BB=D0=BD=D0=B8=D0=BA, 11:20:03 UTC+2, sasho648 =D0=BD=D0=
=B0=D0=BF=D0=B8=D1=81=D0=B0:
>
> @David Krauss About passing arrays as reference - it could be a small=20
> issue but the solution isn't so big to implement too. I mean - it will be=
=20
> only a way to declare something like this:
>
> T *array()*
>
> And then use it like, if we have a function:
>
>
>
>
> *void func(int (&&arg)[5]) { /*Do something*/ }*
>  So we can then call it like:
>
> func((int[5])());
>
>
>
>
> Which will create a temporary unnamed & uninitialized array of=20
> 5 integers. I believe this could be extended further to apply for other=
=20
> default complex types like pointers. So we can then create a temporary=20
> pointer to function for example like this:
>
> bool fnDoSomethingAndAssignsArrayPointer(int (*&&arg)(int, int))
> {
>     /*Do something*/
>
>
>     arg =3D func_addr; //assign arg some argument
>
>
>     /*return*/
> }
>
>  And now if we don't care about the address stored we can write something=
=20
> like this in the function call
>
> fnDoSomethingAndAssignsArrayPointer((int (*)(int, int))());
>
>  For now we could only specify a pointer value which will require a=20
> unneeded copy initialization in the case.
>

--=20

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

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

<div dir=3D"ltr">Also please discuss my second suggestion, which is a propo=
sal to add a new syntax with which you will be able to declare unnamed, uni=
nitialized variables of complex types (like array and pointers). This shall=
 be needed for 'arrays' returning by value implementations and optional out=
put parameters for functions, without using structures (because using them =
for the propose will be just too messy). The syntax I purpose is very simpl=
e:<br><br><i>(complex-type)()</i><div><i><br></i></div><div>Which can be th=
en used like:<br><br></div><div class=3D"prettyprint" style=3D"border: 1px =
solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250,=
 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">*)()</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"styl=
ed-by-prettify">//constructs an unnamed, uninitialized object with a type p=
ointer to int</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br><br><br></span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">5</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: #800;" class=
=3D"styled-by-prettify">//constructs an unnamed, uninitialized object with =
a type array of int with 5 elements</span></div></code></div><div><br></div=
><div>Here is the&nbsp;<a href=3D"http://stackoverflow.com/questions/271006=
29/c-how-to-declare-a-temporary-unnamed-uninitialized-array">question&nbsp;=
</a>with an example where it will be needed. And a quote of myself with ano=
ther use.</div><br>24 =D0=BD=D0=BE=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014, =D0=
=BF=D0=BE=D0=BD=D0=B5=D0=B4=D0=B5=D0=BB=D0=BD=D0=B8=D0=BA, 11:20:03 UTC+2, =
sasho648 =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0:<blockquote class=3D"gmail_qu=
ote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padd=
ing-left: 1ex;"><div dir=3D"ltr"><span style=3D"white-space:nowrap"><span>@=
David Krauss&nbsp;</span></span><span style=3D"color:rgb(0,0,0);font-family=
:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size:14px;line-heigh=
t:17.8048000335693px">About passing arrays as reference - it could be a sma=
ll issue but the solution isn't so big to implement too. I mean - it will b=
e only a way to declare something like this:<br></span><br><span style=3D"c=
olor:rgb(128,128,128);font-style:italic;line-height:1.1em;font-family:DejaV=
uSans,'DejaVu Sans',arial,sans-serif">T</span><span style=3D"color:rgb(0,0,=
0);font-family:DejaVuSans,'DejaVu Sans',arial,sans-serif;line-height:15.360=
0006103516px">&nbsp;</span><i><font color=3D"#808080" face=3D"DejaVuSans, D=
ejaVu Sans, arial, sans-serif"><span style=3D"line-height:14.3000001907349p=
x">array</span></font><font color=3D"#000000" face=3D"DejaVuSansMono, DejaV=
u Sans Mono, courier, monospace"><span style=3D"line-height:15.360000610351=
6px"><b>()</b></span></font></i><br><div><i><font color=3D"#000000" face=3D=
"DejaVuSansMono, DejaVu Sans Mono, courier, monospace"><span style=3D"line-=
height:15.3600006103516px"><b><br></b></span></font></i></div><div><span st=
yle=3D"color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',s=
ans-serif;font-size:14px;line-height:17.8048000335693px">And then use it li=
ke, if we have a function:<br></span><i><font color=3D"#000000" face=3D"Dej=
aVuSansMono, DejaVu Sans Mono, courier, monospace"><span style=3D"line-heig=
ht:15.3600006103516px"><b><br><div style=3D"border:1px solid rgb(187,187,18=
7);word-wrap:break-word;background-color:rgb(250,250,250)"><code><div><span=
 style=3D"color:#008">void</span><span style=3D"color:#000"> func</span><sp=
an style=3D"color:#660">(</span><span style=3D"color:#008">int</span><span =
style=3D"color:#000"> </span><span style=3D"color:#660">(&amp;&amp;</span><=
span style=3D"color:#000">arg</span><span style=3D"color:#660">)[</span><sp=
an style=3D"color:#066">5</span><span style=3D"color:#660">])</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#660">{</span><span style=
=3D"color:#000"> </span><span style=3D"color:#800">/*Do something*/</span><=
span style=3D"color:#000"> </span><span style=3D"color:#660">}</span></div>=
</code></div><br><br><br></b></span></font></i></div><div><span style=3D"co=
lor:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif=
;font-size:14px;line-height:17.8048000335693px">&nbsp;So we can then call i=
t like:<br></span><i><font color=3D"#000000" face=3D"DejaVuSansMono, DejaVu=
 Sans Mono, courier, monospace"><span style=3D"line-height:15.3600006103516=
px"><b><br></b></span></font></i><i><font color=3D"#000000" face=3D"DejaVuS=
ansMono, DejaVu Sans Mono, courier, monospace"><span style=3D"line-height:1=
5.3600006103516px"><b></b></span></font></i></div><div style=3D"border:1px =
solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,25=
0)"><code><div><span style=3D"color:#000">func</span><span style=3D"color:#=
660">((</span><span style=3D"color:#008">int</span><span style=3D"color:#66=
0">[</span><span style=3D"color:#066">5</span><span style=3D"color:#660">])=
());</span><span style=3D"color:#000"><br><br><br></span></div></code></div=
><div><br><i><font color=3D"#000000" face=3D"DejaVuSansMono, DejaVu Sans Mo=
no, courier, monospace"><span style=3D"line-height:15.3600006103516px"><b><=
br></b></span></font></i></div><div><span style=3D"color:rgb(0,0,0);font-fa=
mily:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size:14px;line-h=
eight:17.8048000335693px">Which will create a temporary unnamed &amp;&nbsp;=
</span><font color=3D"#000000" face=3D"Arial, Liberation Sans, DejaVu Sans,=
 sans-serif"><span style=3D"font-size:14px;line-height:17.8048000335693px">=
uninitialized array of 5&nbsp;integers. I believe this could be extended&nb=
sp;further&nbsp;to apply for other default complex types like pointers. So =
we can then create a temporary pointer to function for example like this:<b=
r></span></font><font color=3D"#000000"><br><div style=3D"font-family:DejaV=
uSansMono,'DejaVu Sans Mono',courier,monospace;font-style:italic;font-weigh=
t:bold;border:1px solid rgb(187,187,187);word-wrap:break-word;background-co=
lor:rgb(250,250,250)"><code><div><span style=3D"color:#008">bool</span><spa=
n style=3D"color:#000"> fnDoSomethingAndAssignsArrayPo<wbr>inter</span><spa=
n style=3D"color:#660">(</span><span style=3D"color:#008">int</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#660">(*&amp;&amp;</span><=
span style=3D"color:#000">arg</span><span style=3D"color:#660">)(</span><sp=
an style=3D"color:#008">int</span><span style=3D"color:#660">,</span><span =
style=3D"color:#000"> </span><span style=3D"color:#008">int</span><span sty=
le=3D"color:#660">))</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#660">{</span><span style=3D"color:#000"><br>&nbsp; &nbsp; </spa=
n><span style=3D"color:#800">/*Do something*/</span><span style=3D"color:#0=
00"><br><br><br>&nbsp; &nbsp; arg </span><span style=3D"color:#660">=3D</sp=
an><span style=3D"color:#000"> func_addr</span><span style=3D"color:#660">;=
</span><span style=3D"color:#000"> </span><span style=3D"color:#800">//assi=
gn arg some argument</span><span style=3D"color:#000"><br><br><br>&nbsp; &n=
bsp; </span><span style=3D"color:#800">/*return*/</span><span style=3D"colo=
r:#000"><br></span><span style=3D"color:#660">}</span></div></code></div><d=
iv style=3D"font-family:DejaVuSansMono,'DejaVu Sans Mono',courier,monospace=
;font-style:italic;font-weight:bold"><span style=3D"line-height:15.36000061=
03516px"><br></span></div><div style=3D"font-family:DejaVuSansMono,'DejaVu =
Sans Mono',courier,monospace;font-style:italic;font-weight:bold"><span styl=
e=3D"font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size=
:14px;font-style:normal;font-weight:normal;line-height:17.8048000335693px">=
&nbsp;And now if we don't care about the address stored we can write someth=
ing like this in the function call</span></div><div style=3D"font-family:De=
jaVuSansMono,'DejaVu Sans Mono',courier,monospace;font-style:italic;font-we=
ight:bold"><span style=3D"font-family:Arial,'Liberation Sans','DejaVu Sans'=
,sans-serif;font-size:14px;font-style:normal;font-weight:normal;line-height=
:17.8048000335693px"><br></span></div></font><div><div style=3D"color:rgb(0=
,0,0);border:1px solid rgb(187,187,187);word-wrap:break-word;background-col=
or:rgb(250,250,250)"><code><div><span style=3D"color:#000">fnDoSomethingAnd=
AssignsArrayPo<wbr>inter</span><span style=3D"color:#660">((</span><span st=
yle=3D"color:#008">int</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">(*)(</span><span style=3D"color:#008">int</span><span style=
=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#008">int</span><span style=3D"color:#660">))());</span></div></code><=
/div><font face=3D"Arial, Liberation Sans, DejaVu Sans, sans-serif" style=
=3D"color:rgb(0,0,0)"><span style=3D"font-size:14px;line-height:17.80480003=
35693px"><div><font face=3D"Arial, Liberation Sans, DejaVu Sans, sans-serif=
"><span style=3D"font-size:14px;line-height:17.8048000335693px"><br></span>=
</font></div>&nbsp;For now we could only specify a pointer value which will=
 require a unneeded copy&nbsp;initialization&nbsp;in the case.</span></font=
><br></div></div></div></blockquote></div>

<p></p>

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

------=_Part_737_391674719.1416953812243--
------=_Part_736_651794238.1416953812243--

.


Author: Myriachan <myriachan@gmail.com>
Date: Tue, 25 Nov 2014 16:08:31 -0800 (PST)
Raw View
------=_Part_3133_888728535.1416960511297
Content-Type: multipart/alternative;
 boundary="----=_Part_3134_1111722860.1416960511297"

------=_Part_3134_1111722860.1416960511297
Content-Type: text/plain; charset=UTF-8

On Tuesday, November 25, 2014 2:16:52 PM UTC-8, sasho648 wrote:
>
> Also please discuss my second suggestion, which is a proposal to add a new
> syntax with which you will be able to declare unnamed, uninitialized
> variables of complex types (like array and pointers). This shall be needed
> for 'arrays' returning by value implementations and optional output
> parameters for functions, without using structures (because using them for
> the propose will be just too messy). The syntax I purpose is very simple:
>
> *(complex-type)()*
>
> Which can be then used like:
>
> (int *)() //constructs an unnamed, uninitialized object with a type
> pointer to int
>
>
> (int [5])() //constructs an unnamed, uninitialized object with a type
> array of int with 5 elements
>
>
>
Would you have an equivalent to the "most vexing parse" rule?  For example,
the currently-legal code:

struct Type
{
    void operator ()() const { }
};

int main()
{
    (Type())();
    return 0;
}


Would that be a compiler error due to attempting to construct a function of
type "Type ()", or would it compile like in C++14, constructing a temporary
of type Type and calling operator () on it?

Melissa

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

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

<div dir=3D"ltr">On Tuesday, November 25, 2014 2:16:52 PM UTC-8, sasho648 w=
rote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8e=
x;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Also ple=
ase discuss my second suggestion, which is a proposal to add a new syntax w=
ith which you will be able to declare unnamed, uninitialized variables of c=
omplex types (like array and pointers). This shall be needed for 'arrays' r=
eturning by value implementations and optional output parameters for functi=
ons, without using structures (because using them for the propose will be j=
ust too messy). The syntax I purpose is very simple:<br><br><i>(complex-typ=
e)()</i><div><i><br></i></div><div>Which can be then used like:<br><br></di=
v><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;back=
ground-color:rgb(250,250,250)"><code><div><span style=3D"color:#660">(</spa=
n><span style=3D"color:#008">int</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">*)()</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#800">//constructs an unnamed, uninitialized object with =
a type pointer to int</span><span style=3D"color:#000"><br><br><br></span><=
span style=3D"color:#660">(</span><span style=3D"color:#008">int</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#660">[</span><span sty=
le=3D"color:#066">5</span><span style=3D"color:#660">])()</span><span style=
=3D"color:#000"> </span><span style=3D"color:#800">//constructs an unnamed,=
 uninitialized object with a type array of int with 5 elements</span></div>=
</code></div><div><br></div><br></div></blockquote><div><br>Would you have =
an equivalent to the "most vexing parse" rule?&nbsp; For example, the curre=
ntly-legal code:<br><br><div class=3D"prettyprint" style=3D"background-colo=
r: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: soli=
d; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><=
div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">struct</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">T=
ype</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">()()</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">const</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> main</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">(</span><span style=3D"color: #606;" class=3D"styled-by-pr=
ettify">Type</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">())();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">return</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span></div></code></div><br><br>Wo=
uld that be a compiler error due to attempting to construct a function of t=
ype "<span style=3D"font-family: courier new,monospace;">Type ()</span>", o=
r would it compile like in C++14, constructing a temporary of type <span st=
yle=3D"font-family: courier new,monospace;">Type</span> and calling <span s=
tyle=3D"font-family: courier new,monospace;">operator ()</span> on it?<br><=
br>Melissa<br></div></div>

<p></p>

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

------=_Part_3134_1111722860.1416960511297--
------=_Part_3133_888728535.1416960511297--

.


Author: sasho648 <sasho648@mail.bg>
Date: Wed, 26 Nov 2014 02:28:57 -0800 (PST)
Raw View
------=_Part_199_1821394261.1416997737124
Content-Type: multipart/alternative;
 boundary="----=_Part_200_1941440289.1416997737124"

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



26 =D0=BD=D0=BE=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014, =D1=81=D1=80=D1=8F=D0=
=B4=D0=B0, 02:08:31 UTC+2, Myriachan =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0:
>
> On Tuesday, November 25, 2014 2:16:52 PM UTC-8, sasho648 wrote:
>>
>> Also please discuss my second suggestion, which is a proposal to add a=
=20
>> new syntax with which you will be able to declare unnamed, uninitialized=
=20
>> variables of complex types (like array and pointers). This shall be need=
ed=20
>> for 'arrays' returning by value implementations and optional output=20
>> parameters for functions, without using structures (because using them f=
or=20
>> the propose will be just too messy). The syntax I purpose is very simple=
:
>>
>> *(complex-type)()*
>>
>> Which can be then used like:
>>
>> (int *)() //constructs an unnamed, uninitialized object with a type=20
>> pointer to int
>>
>>
>> (int [5])() //constructs an unnamed, uninitialized object with a type=20
>> array of int with 5 elements
>>
>>
>>
> Would you have an equivalent to the "most vexing parse" rule?  For=20
> example, the currently-legal code:
>
> struct Type
> {
>     void operator ()() const { }
> };
>
> int main()
> {
>     (Type())();
>     return 0;
> }
>
>
> Would that be a compiler error due to attempting to construct a function=
=20
> of type "Type ()", or would it compile like in C++14, constructing a=20
> temporary of type Type and calling operator () on it?
>
> Melissa
>

Hmm can't the parser just detect that is trying to construct an object of=
=20
type 'function' which is illegal and search for other useful meanings? But=
=20
I smell another non-sense here which is connected with the most vexing=20
parse. The problem is the same as arrays as formal parameters but instead=
=20
for functions which are always implicitly converted to function pointers. I=
=20
suggest banning such construct for the same reasons pointed here for array=
=20
formal parameters plus that if banned the vexing parse complexity will be=
=20
reduced.

Not Legal:

int (*Func(int ()))();

Legal:

int (*Func(int ()))();

And the most vexing parse example which complexity will be relaxed if=20
function as formal parameters are banned:

// Is this:
// 1) A variable of type std::string initialized to a std::string()?
// 2) The declaration of a function that returns a std::string and has one=
=20
argument,
//    which is a pointer to a function with no arguments that returns a=20
std::string?
std::string foo(std::string());


If my suggestion is implemented the upper declarations will always be=20
interpreted as '1'. If you want to declare them like '2', you should use=20
function pointers like this.

std::string foo(std::string(*)());

--=20

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

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

<div dir=3D"ltr"><br><br>26 =D0=BD=D0=BE=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014=
, =D1=81=D1=80=D1=8F=D0=B4=D0=B0, 02:08:31 UTC+2, Myriachan =D0=BD=D0=B0=D0=
=BF=D0=B8=D1=81=D0=B0:<blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">On Tuesday, November 25, 2014 2:16:52 PM UTC-8, sasho648 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">Also please discuss m=
y second suggestion, which is a proposal to add a new syntax with which you=
 will be able to declare unnamed, uninitialized variables of complex types =
(like array and pointers). This shall be needed for 'arrays' returning by v=
alue implementations and optional output parameters for functions, without =
using structures (because using them for the propose will be just too messy=
). The syntax I purpose is very simple:<br><br><i>(complex-type)()</i><div>=
<i><br></i></div><div>Which can be then used like:<br><br></div><div style=
=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;background-color=
:rgb(250,250,250)"><code><div><span style=3D"color:#660">(</span><span styl=
e=3D"color:#008">int</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">*)()</span><span style=3D"color:#000"> </span><span style=
=3D"color:#800">//constructs an unnamed, uninitialized object with a type p=
ointer to int</span><span style=3D"color:#000"><br><br><br></span><span sty=
le=3D"color:#660">(</span><span style=3D"color:#008">int</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">[</span><span style=3D"c=
olor:#066">5</span><span style=3D"color:#660">])()</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#800">//constructs an unnamed, uninit=
ialized object with a type array of int with 5 elements</span></div></code>=
</div><div><br></div><br></div></blockquote><div><br>Would you have an equi=
valent to the "most vexing parse" rule?&nbsp; For example, the currently-le=
gal code:<br><br><div style=3D"background-color:rgb(250,250,250);border-col=
or:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-wor=
d"><code><div><span style=3D"color:#008">struct</span><span style=3D"color:=
#000"> </span><span style=3D"color:#606">Type</span><span style=3D"color:#0=
00"><br></span><span style=3D"color:#660">{</span><span style=3D"color:#000=
"><br>&nbsp; &nbsp; </span><span style=3D"color:#008">void</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#008">operator</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#660">()()</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#008">const</span><span style=
=3D"color:#000"> </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></span><span style=3D"color:#660">};</span><span style=3D"color:#=
000"><br><br></span><span style=3D"color:#008">int</span><span style=3D"col=
or:#000"> main</span><span style=3D"color:#660">()</span><span style=3D"col=
or:#000"><br></span><span style=3D"color:#660">{</span><span style=3D"color=
:#000"><br>&nbsp; &nbsp; </span><span style=3D"color:#660">(</span><span st=
yle=3D"color:#606">Type</span><span style=3D"color:#660">())();</span><span=
 style=3D"color:#000"><br>&nbsp; &nbsp; </span><span style=3D"color:#008">r=
eturn</span><span style=3D"color:#000"> </span><span style=3D"color:#066">0=
</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br></=
span><span style=3D"color:#660">}</span><span style=3D"color:#000"><br></sp=
an></div></code></div><br><br>Would that be a compiler error due to attempt=
ing to construct a function of type "<span style=3D"font-family:courier new=
,monospace">Type ()</span>", or would it compile like in C++14, constructin=
g a temporary of type <span style=3D"font-family:courier new,monospace">Typ=
e</span> and calling <span style=3D"font-family:courier new,monospace">oper=
ator ()</span> on it?<br><br>Melissa<br></div></div></blockquote><div><br><=
/div><div>Hmm can't the parser just detect that is trying to construct an o=
bject of type 'function' which is illegal and search for other useful meani=
ngs? But I smell another non-sense here which is connected with the most ve=
xing parse. The problem is the same as arrays as formal parameters but inst=
ead for functions which are always implicitly converted to function pointer=
s. I suggest banning such construct for the same reasons pointed here for a=
rray formal parameters plus that if banned the vexing parse complexity will=
 be reduced.</div><div><br>Not Legal:</div><div><br></div><div><div class=
=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: =
break-word; background-color: rgb(250, 250, 250);"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">int</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: #606;" class=3D"styled-by-prettify">Func</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">()))();</span></div></code></div><br>=
Legal:<br><br><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187=
, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);">=
<code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">(*</span><span style=3D"color: #606;" class=3D"sty=
led-by-prettify">Func</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">()))();</span>=
</div></code></div><br>And the most vexing parse example which complexity w=
ill be relaxed if function as formal parameters are banned:<br><br><div cla=
ss=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap=
: break-word; background-color: rgb(250, 250, 250);"><code class=3D"prettyp=
rint"><div class=3D"subprettyprint"><span style=3D"color: #800;" class=3D"s=
tyled-by-prettify">// Is this:</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span><span style=3D"color: #800;" class=3D"styled=
-by-prettify">// 1) A variable of type std::string initialized to a std::st=
ring()?</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
></span><span style=3D"color: #800;" class=3D"styled-by-prettify">// 2) The=
 declaration of a function that returns a std::string and has one argument,=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span=
><span style=3D"color: #800;" class=3D"styled-by-prettify">// &nbsp; &nbsp;=
which is a pointer to a function with no arguments that returns a std::stri=
ng?</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>std=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">string</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> foo</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">string</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">());</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"><br></span></div></code></div><div><br></div><br></div><div>I=
f my suggestion is implemented the upper declarations will always be interp=
reted as '1'. If you want to declare them like '2', you should use function=
 pointers like this.</div><div><br></div><div><div class=3D"prettyprint" st=
yle=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; backgro=
und-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"s=
ubprettyprint"><span style=3D"color: #000;" class=3D"styled-by-prettify">st=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">string</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> foo</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">string</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(*)());</span></div></code></div></div></div>

<p></p>

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

------=_Part_200_1941440289.1416997737124--
------=_Part_199_1821394261.1416997737124--

.


Author: sasho648 <sasho648@mail.bg>
Date: Wed, 26 Nov 2014 11:34:23 -0800 (PST)
Raw View
------=_Part_5911_1899527208.1417030463140
Content-Type: multipart/alternative;
 boundary="----=_Part_5912_861888554.1417030463140"

------=_Part_5912_861888554.1417030463140
Content-Type: text/plain; charset=UTF-8

Yep, I never meant that.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_5912_861888554.1417030463140
Content-Type: text/html; charset=UTF-8

<div dir="ltr">Yep, I never meant that.</div>

<p></p>

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

------=_Part_5912_861888554.1417030463140--
------=_Part_5911_1899527208.1417030463140--

.


Author: sasho648 <sasho648@mail.bg>
Date: Thu, 27 Nov 2014 12:49:35 -0800 (PST)
Raw View
------=_Part_916_411338310.1417121375723
Content-Type: multipart/alternative;
 boundary="----=_Part_917_613116477.1417121375723"

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

Let's sum up my proposals:

1st proposal:

Changing 8.3.5/5 from this:

After determining the type of each parameter, any parameter of type =E2=80=
=9Carray=20
of T=E2=80=9D or =E2=80=9Cfunction returning T=E2=80=9D is adjusted to be =
=E2=80=9Cpointer to T=E2=80=9D or=20
=E2=80=9Cpointer to function returning T,=E2=80=9D respectively.

To something like this

Parameters of type =E2=80=9Carray of T=E2=80=9D and =E2=80=9Cfunction retur=
ning T=E2=80=9D are not allowed.

The arguments for this change are the following:

1. Removing confusion (for the array parameters ban suggestion):

Declaring a function with parameter of type 'array' have certain=20
expectations which aren't implemented now. Like if write:

void SomeFunc(int arg[5]); //which will be the same as void SomeFunc(int=20
*arg);


We first expect that only arrays of size '5' will be accept but this is not=
=20
true, we can have the following, legal code:

int arr[200];


SomeFunc(arr); //Absolutely legal


Second we expect the array data to be copied into the argument temporary=20
when instancing but this won't happen. So if we edit the content of the=20
parameter in function 'SomeFunc', we'll actually edit it's pointing array.

void SomeFunc(int arg[5])

{
      arg[4] =3D 90; // editing the data pointed by 'arg' (in the previous=
=20
example this would mean that we are actually storing the value at 'arr[4]')
}


Third if we use 'sizeof' to get the size of the array parameter we'll=20
actually only retrieve the size of a pointer.

void SomeFunc(int arg[5])

{
      std::cout << sizeof(arg) << std::endl; // same as std::cout <<=20
sizeof(void *) << std::endl
}

NOTE: Don't think that the above expectations are imaginary as you can=20
implement exactly the same things but using instead of raw arrays,=20
structures containing them. Like this (which is already implemented by the=
=20
STD library - std::array):

template <size_t size_, typename type>
struct arr1 { type d[size_]; };


arr1<5, int> FunctionReturningAndAcceptingArrays(arr1<5, int> ArrayArg)
{
    int (&refArrayArgAsArray)[5] =3D *(int (*)[5])&ArrayArg; // store a=20
reference to 'ArrayArg' as 'int [5]' array


    refArrayArgAsArray[3] =3D 90;


    cout << "'refArrayArgAsArray' number of elements =3D "  << sizeof(
refArrayArgAsArray) / sizeof(int) << endl; //shows out that=20
'refArrayArgAsArray' is really an array and not a pointer by getting it's=
=20
element number


    return ArrayArg; //return the 'ArrayArg' array by value
}


int main()
{
    int arr[5] =3D {1, 2, 3, 4, 5};


    arr1<5, int> return_value =3D FunctionReturningAndAcceptingArrays(*(arr=
1<5
, int>*)arr); //cast 'arr' to structure and pass it to the function call=20
then save it's return value


    int (&refReturn_valueAsArray)[5] =3D *(int (*)[5])&return_value; // sto=
re=20
a reference to 'return_value' as 'int [5]' array


    //cout the values of the returned array and the local to show that the=
=20
local passed as an argument ('arr') was not changed


    cout << "refReturn_valueAsArray array values:" << endl;


    for(size_t i(0); i < 5; ++i)
        cout << refReturn_valueAsArray[i] << " ";


    cout << endl << "arr array values:" << endl;


    for(size_t i(0); i < 5; ++i)
        cout << arr[i] << " ";
}

The output of the program is this:

'refArrayArgAsArray' number of elements =3D 5
> refReturn_valueAsArray array values:
> 1 2 3 90 5
> arr array values:
> 1 2 3 4 5


2. Encouraging people to use new proper implementations (like 'std::array')=
..

3. Return type of those is not-allowed to be declared but parameter one is =
implicitly=20
adjusted (for both the function & array parameters ban):

Not Legal:

int (*Func(int ()))(); // a function returning function

int Func(int *)[5]; // a function returning array

Legal:

int (*Func(int ()))(); // a function with one parameter of type function

int *Func(int [5]); // a function with one parameter of type array

4. Most vexing parse reduced complexity (for function parameters ban):

As function parameters wouldn't be allowed, declaration like this:

std::string foo(std::string());

will be no longer interpreted as a function one.

2nd proposal:

Allowing this syntax:

*(**complex-type**)() *

*complex-type-alias**()*

For creating unnamed and uninitialized objects by using a complex-type in=
=20
brackets or a complex-type type-alias. Those new structures will be used in=
=20
cases when there is a function which will store some data in a reference=20
object, passed as an argument but you'll not always care about them and=20
also when you want to 'return' raw arrays. Example of the first case:

void DoSomeThingsAndStoreSomeData(int (&&refData)[260]) ;=20

Sometimes you will care about the data stored at'refData' but others you=20
won't and in this cases you'll want to pass an unnamed and uninitialized
 placeholder object (normally by using an argument default value) which you=
=20
can't do for now. We could only write something like this:

void DoSomeThingsAndStoreSomeData(int (&&refData)[260] =3D {} ) ;

But the above construction, when the function is instanced with no=20
arguments, will zero-initialize the unnamed object which will be referenced=
=20
by 'refData' and thus will waste program time. By using my new syntax we=20
could write this to prevent it:

void DoSomeThingsAndStoreSomeData(int (&&refData)[260] =3D (int [260])() ) =
;


Or this (by using a type alias):

using int_260_array_type =3D int [260];

void DoSomeThingsAndStoreSomeData(int (&&refData)[260] =3D int_260_array_ty=
pe
() ) ;

Example of the second case (enabling the feature of 'returning' raw arrays)=
:

int (&&funcReturnRawArray(int (&&result)[5] =3D (int [5])()))[5] //By defau=
lt=20
creates an temporary uninitialized object, emulating return value storage=
=20
(as it's life-time equals to the expression of the function instance)
{
    //Do Something


    return (int (&&)[5])result; //return a 'raw' array
}

--=20

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

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

<div dir=3D"ltr">Let's sum up my proposals:<div><br></div><div>1st proposal=
:</div><div><br></div><div>Changing&nbsp;<span style=3D"color: rgb(0, 0, 0)=
; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-si=
ze: 14px; line-height: 17.8048000335693px;">8.3.5/5&nbsp;</span><span style=
=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu San=
s', sans-serif; font-size: 14px; line-height: 17.8048000335693px;">from thi=
s:</span></div><div><span style=3D"color: rgb(0, 0, 0); font-family: Arial,=
 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height=
: 17.8048000335693px;"><br></span></div><div><span style=3D"color: rgb(0, 0=
, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; fon=
t-size: 14px; line-height: 17.8048000335693px; background-color: rgb(238, 2=
38, 238);">After determining the type of each parameter, any parameter of t=
ype =E2=80=9Carray of T=E2=80=9D or =E2=80=9Cfunction returning T=E2=80=9D =
is adjusted to be =E2=80=9Cpointer to T=E2=80=9D or =E2=80=9Cpointer to fun=
ction returning T,=E2=80=9D respectively.</span><span style=3D"color: rgb(0=
, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; =
font-size: 14px; line-height: 17.8048000335693px;"><br></span></div><div><s=
pan style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'D=
ejaVu Sans', sans-serif; font-size: 14px; line-height: 17.8048000335693px; =
background-color: rgb(238, 238, 238);"><br></span></div><div><span style=3D=
"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans',=
 sans-serif; font-size: 14px; line-height: 17.8048000335693px;">To somethin=
g like this</span><br></div><div><span style=3D"color: rgb(0, 0, 0); font-f=
amily: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px=
; line-height: 17.8048000335693px;"><br></span></div><div><span style=3D"co=
lor: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sa=
ns-serif; font-size: 14px; line-height: 17.8048000335693px; background-colo=
r: rgb(238, 238, 238);">Parameters of type&nbsp;</span><span style=3D"color=
: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-=
serif; font-size: 14px; line-height: 17.8048000335693px; background-color: =
rgb(238, 238, 238);">=E2=80=9Carray of T=E2=80=9D and&nbsp;</span><span sty=
le=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu S=
ans', sans-serif; font-size: 14px; line-height: 17.8048000335693px; backgro=
und-color: rgb(238, 238, 238);">=E2=80=9Cfunction returning T=E2=80=9D</spa=
n><span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans'=
, 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.8048000335693=
px; background-color: rgb(238, 238, 238);">&nbsp;are not allowed.</span></d=
iv><div><span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation=
 Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.8048000=
335693px; background-color: rgb(238, 238, 238);"><br></span></div><div><spa=
n style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'Dej=
aVu Sans', sans-serif; font-size: 14px; line-height: 17.8048000335693px;">T=
he arguments for this change are the following:</span><span style=3D"color:=
 rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-s=
erif; font-size: 14px; line-height: 17.8048000335693px; background-color: r=
gb(238, 238, 238);"><br></span></div><div><span style=3D"color: rgb(0, 0, 0=
); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-s=
ize: 14px; line-height: 17.8048000335693px;"><br></span></div><div><font co=
lor=3D"#000000" face=3D"Arial, Liberation Sans, DejaVu Sans, sans-serif"><s=
pan style=3D"font-size: 14px; line-height: 17.8048000335693px;">1. Removing=
 confusion (for the array parameters ban suggestion):<br><br></span></font>=
</div><div><font color=3D"#000000" face=3D"Arial, Liberation Sans, DejaVu S=
ans, sans-serif"><span style=3D"font-size: 14px; line-height: 17.8048000335=
693px;">Declaring a function with parameter of type 'array' have certain ex=
pectations which aren't implemented now. Like if write:<br><br><div class=
=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: =
break-word; background-color: rgb(250, 250, 250);"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify=
">SomeFunc</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> arg</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">5</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">]);</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"s=
tyled-by-prettify">//which will be the same as void SomeFunc(int *arg);</sp=
an></div></code></div></span></font></div><div><font color=3D"#000000" face=
=3D"Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style=3D"font-si=
ze: 14px; line-height: 17.8048000335693px;"><br></span></font></div><div><f=
ont color=3D"#000000" face=3D"Arial, Liberation Sans, DejaVu Sans, sans-ser=
if"><span style=3D"font-size: 14px; line-height: 17.8048000335693px;"><br><=
/span></font></div><div><font color=3D"#000000" face=3D"Arial, Liberation S=
ans, DejaVu Sans, sans-serif"><span style=3D"font-size: 14px; line-height: =
17.8048000335693px;">We first expect that only arrays of size '5' will be a=
ccept but this is not true, we can have the following, legal code:<br><br><=
/span></font></div><div class=3D"prettyprint" style=3D"border: 1px solid rg=
b(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 25=
0);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> arr</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">[</span><span style=3D"color: #066;" clas=
s=3D"styled-by-prettify">200</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">];</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br><br><br></span><span style=3D"color: #606;" class=3D"styled-b=
y-prettify">SomeFunc</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>arr</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #800;" class=3D"styled-by-prettify">//Absolutely legal</spa=
n></div></code></div><div><span style=3D"color: rgb(0, 0, 0); font-family: =
Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-=
height: 17.8048000335693px;"><br></span><font color=3D"#000000" face=3D"Ari=
al, Liberation Sans, DejaVu Sans, sans-serif"><span style=3D"font-size: 14p=
x; line-height: 17.8048000335693px;"><br>Second we expect the array data to=
 be copied into the argument temporary when instancing but this won't happe=
n. So if we edit the content of the parameter in function '</span></font><s=
pan style=3D"color: rgb(102, 0, 102); font-family: monospace; background-co=
lor: rgb(250, 250, 250);">SomeFunc</span><span style=3D"font-size: 14px; li=
ne-height: 17.8048000335693px; color: rgb(0, 0, 0); font-family: Arial, 'Li=
beration Sans', 'DejaVu Sans', sans-serif;">', we'll actually edit it's poi=
nting array.<br><br></span><span class=3D"styled-by-prettify" style=3D"font=
-family: monospace; font-size: 14px; line-height: 17.8048000335693px; color=
: rgb(0, 0, 136); background-color: rgb(250, 250, 250);"></span></div><div =
class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-w=
rap: break-word; background-color: rgb(250, 250, 250);"><code class=3D"pret=
typrint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-p=
rettify">SomeFunc</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">in=
t</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> arg</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span s=
tyle=3D"color: #066;" class=3D"styled-by-prettify">5</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">])</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; arg</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #06=
6;" class=3D"styled-by-prettify">4</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">90</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #800;" class=3D"styled-by-prettify">// editing the data pointed by 'arg'=
 (in the previous example this would mean that we are actually storing the =
value at 'arr[4]')</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">}</span></div></code></div><div><span class=3D"styled-by-prettify" style=
=3D"font-family: monospace; font-size: 14px; line-height: 17.8048000335693p=
x; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);"><br></sp=
an></div><div><span class=3D"styled-by-prettify" style=3D"font-family: mono=
space; font-size: 14px; line-height: 17.8048000335693px; color: rgb(102, 10=
2, 0); background-color: rgb(250, 250, 250);"><br></span></div><div><span s=
tyle=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu=
 Sans', sans-serif; font-size: 14px; line-height: 17.8048000335693px;">Thir=
d if we use 'sizeof' to get the size of the array parameter we'll actually =
only retrieve the size of a pointer.</span><br></div><div><span style=3D"co=
lor: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sa=
ns-serif; font-size: 14px; line-height: 17.8048000335693px;"><br></span></d=
iv><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187)=
; word-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">SomeFunc</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> ar=
g</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><=
span style=3D"color: #066;" class=3D"styled-by-prettify">5</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">])</span><span style=3D"col=
or: #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>&nbsp; &nbsp; &nbsp; std</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">cout </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">sizeof</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">arg</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">endl</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">// same as std::cout &lt;&lt; sizeof(void *) &lt;&l=
t; std::endl</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</s=
pan></div></code></div><div><span class=3D"styled-by-prettify" style=3D"fon=
t-family: monospace; color: rgb(102, 102, 0); background-color: rgb(250, 25=
0, 250);"><br></span></div><div><span style=3D"color: rgb(0, 0, 0); font-fa=
mily: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px;=
 line-height: 17.8048000335693px;">NOTE: Don't think that the above expecta=
tions are imaginary as you can implement exactly the same things but&nbsp;<=
/span><span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation S=
ans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.804800033=
5693px;">using</span><span style=3D"color: rgb(0, 0, 0); font-family: Arial=
, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-heigh=
t: 17.8048000335693px;">&nbsp;instead of raw arrays, structures containing =
them. Like this (which is already implemented by the STD library - std::arr=
ay):</span></div><div><br></div><div class=3D"prettyprint" style=3D"border:=
 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb=
(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"=
><span style=3D"color: #008;" class=3D"styled-by-prettify">template</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">size_t size_</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> type</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> arr1 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> type d</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">size_</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">];</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br><br>arr1</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">5</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #606;" class=3D"styled-by-prettify">FunctionReturningAndAccep=
tingArrays</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">arr1</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><spa=
n style=3D"color: #066;" class=3D"styled-by-prettify">5</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">int</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-p=
rettify">ArrayArg</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp;=
 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(&amp;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">refArrayArgAsArray</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">)[</span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">5</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">]</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">*(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">(*)[</span><span sty=
le=3D"color: #066;" class=3D"styled-by-prettify">5</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">])&amp;</span><span style=3D"color:=
 #606;" class=3D"styled-by-prettify">ArrayArg</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"sty=
led-by-prettify">// store a reference to 'ArrayArg' as 'int [5]' array</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>&nb=
sp; &nbsp; refArrayArgAsArray</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">[</span><span style=3D"color: #066;" class=3D"styled-by-=
prettify">3</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>]</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #066;" class=3D"styled-by-prettify">90</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br><br><br>&nbsp; &nbsp; cout </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">"'refArrayArgAsArray' number of eleme=
nts =3D "</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
&nbsp;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;=
&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">sizeof</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">refArrayArgAsArray</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">/</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">sizeof</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">int</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">&lt;&lt;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> endl</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800=
;" class=3D"styled-by-prettify">//shows out that 'refArrayArgAsArray' is re=
ally an array and not a pointer by getting it's element number</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>&nbsp; &nbs=
p; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">return<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #606;" class=3D"styled-by-prettify">ArrayArg</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: #=
800;" class=3D"styled-by-prettify">//return the 'ArrayArg' array by value</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br></span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> main</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> arr</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">[</span><span style=3D"color: #066;" class=3D"styled-by-prettify=
">5</span><span style=3D"color: #660;" class=3D"styled-by-prettify">]</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">{</span><span style=3D"color: #066;" clas=
s=3D"styled-by-prettify">1</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">2<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">3</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"=
styled-by-prettify">4</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">5</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>&nbsp; &nbsp=
; arr1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;=
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">5</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=
: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> return_value </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">FunctionReturningAndAcceptingArrays</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(*(</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">arr1</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">&lt;</span><span style=3D"color: #066;" class=3D=
"styled-by-prettify">5</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;*)</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">arr</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #8=
00;" class=3D"styled-by-prettify">//cast 'arr' to structure and pass it to =
the function call then save it's return value</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br><br><br>&nbsp; &nbsp; </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(&amp;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">refReturn_valueAsArray</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">)[</span><span style=3D"color: #=
066;" class=3D"styled-by-prettify">5</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">*(</span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">int</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:=
 #066;" class=3D"styled-by-prettify">5</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">])&amp;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">return_value</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-p=
rettify">// store a reference to 'return_value' as 'int [5]' array</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>&nbsp; =
&nbsp; </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//c=
out the values of the returned array and the local to show that the local p=
assed as an argument ('arr') was not changed</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br><br><br>&nbsp; &nbsp; cout </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #080;" class=3D"styled-by-prettify">"refReturn_valueAsArray array v=
alues:"</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> endl</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>&nbsp; &nbsp; </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">for</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">size_t i</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> i </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">5=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">++</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">i</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; cout </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> refReturn_valueAsArray</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">i</span><span style=3D"c=
olor: #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">&lt;&lt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"style=
d-by-prettify">" "</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><br>&nbsp; &nbsp; cout </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> endl </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettif=
y">"arr array values:"</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> endl</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>&=
nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">for</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">size_t i</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> i </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-b=
y-prettify">5</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">++</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">i</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; cout </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> arr</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">i</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">]</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-pret=
tify">" "</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></div></=
code></div><div><br></div><div><span class=3D"styled-by-prettify" style=3D"=
font-family: monospace; color: rgb(102, 102, 0); background-color: rgb(250,=
 250, 250);">The output of the program is this:</span></div><div><span clas=
s=3D"styled-by-prettify" style=3D"font-family: monospace; color: rgb(102, 1=
02, 0); background-color: rgb(250, 250, 250);"><br></span></div><div><span =
class=3D"styled-by-prettify" style=3D"background-color: rgb(250, 250, 250);=
"><font color=3D"#666600" face=3D"monospace"><div><blockquote class=3D"gmai=
l_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border=
-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1e=
x;">'refArrayArgAsArray' number of elements =3D 5<br>refReturn_valueAsArray=
 array values:<br>1 2 3 90 5<br>arr array values:<br>1 2 3 4 5</blockquote>=
</div><div><br></div><div><span style=3D"color: rgb(0, 0, 0); font-family: =
Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-=
height: 17.8048000335693px; background-color: rgb(255, 255, 255);">2. Encou=
raging people to use new proper implementations (like 'std::array').</span>=
<br></div><div><br></div></font></span></div><div><span style=3D"color: rgb=
(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif=
; font-size: 14px; line-height: 17.8048000335693px;">3. Return type of thos=
e is not-allowed to be declared but parameter one is&nbsp;</span><font colo=
r=3D"#000000" face=3D"Arial, Liberation Sans, DejaVu Sans, sans-serif"><spa=
n style=3D"font-size: 14px; line-height: 17.8048000335693px;">implicitly ad=
justed (for both the function &amp; array parameters ban):</span></font></d=
iv><div><font color=3D"#000000" face=3D"Arial, Liberation Sans, DejaVu Sans=
, sans-serif"><span style=3D"font-size: 14px; line-height: 17.8048000335693=
px;"><br></span></font></div><div><div>Not Legal:</div><div><br></div><div>=
<div style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; =
background-color: rgb(250, 250, 250);"><code><span style=3D"color: rgb(0, 0=
, 136);">int</span><span style=3D"color: rgb(0, 0, 0);">&nbsp;</span><span =
style=3D"color: rgb(102, 102, 0);">(*</span><span style=3D"color: rgb(102, =
0, 102);">Func</span><span style=3D"color: rgb(102, 102, 0);">(</span><span=
 style=3D"color: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(0, 0,=
 0);">&nbsp;</span><span style=3D"color: rgb(102, 102, 0);">()))(); // a fu=
nction returning function</span></code></div><div style=3D"border: 1px soli=
d rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250=
, 250);"><code><span style=3D"color: rgb(102, 102, 0);"><br></span></code><=
/div><div style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-w=
ord; background-color: rgb(250, 250, 250);"><code><span style=3D"color: rgb=
(0, 0, 136);">int</span><span style=3D"color: rgb(0, 0, 0);">&nbsp;</span><=
span style=3D"color: rgb(102, 0, 102);">Func</span><span style=3D"color: rg=
b(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 136);">int</span><=
span style=3D"color: rgb(0, 0, 0);">&nbsp;</span><span style=3D"color: rgb(=
102, 102, 0);">*)[</span><span style=3D"color: rgb(0, 102, 102);">5</span><=
span style=3D"color: rgb(102, 102, 0);">]; // a function returning array</s=
pan><span style=3D"color: rgb(102, 102, 0);"><br></span></code></div><br>Le=
gal:<br><br><div style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: =
break-word; background-color: rgb(250, 250, 250);"><code><span style=3D"col=
or: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(0, 0, 0);">&nbsp;<=
/span><span style=3D"color: rgb(102, 102, 0);">(*</span><span style=3D"colo=
r: rgb(102, 0, 102);">Func</span><span style=3D"color: rgb(102, 102, 0);">(=
</span><span style=3D"color: rgb(0, 0, 136);">int</span><span style=3D"colo=
r: rgb(0, 0, 0);">&nbsp;</span><span style=3D"color: rgb(102, 102, 0);">())=
)(); // a function with one parameter of type function</span></code></div><=
/div></div><div style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: b=
reak-word; background-color: rgb(250, 250, 250);"><code><span style=3D"colo=
r: rgb(102, 102, 0);"><br></span></code></div><div style=3D"border: 1px sol=
id rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 25=
0, 250);"><code><span style=3D"color: rgb(0, 0, 136);">int</span><span styl=
e=3D"color: rgb(0, 0, 0);">&nbsp;</span><span style=3D"color: rgb(102, 102,=
 0);">*</span><span style=3D"color: rgb(102, 0, 102);">Func</span><span sty=
le=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 136=
);">int</span><span style=3D"color: rgb(0, 0, 0);">&nbsp;</span><span style=
=3D"color: rgb(102, 102, 0);">[</span><span style=3D"color: rgb(0, 102, 102=
);">5</span><span style=3D"color: rgb(102, 102, 0);">]); // a function with=
 one parameter of type array</span><span style=3D"color: rgb(102, 102, 0);"=
><br></span></code></div><div><br></div><div>4. Most vexing parse reduced c=
omplexity (<span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberat=
ion Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.8048=
000335693px;">for function parameters ban):<br><br>As function parameters w=
ouldn't be allowed, declaration like this:</span></div><div><span style=3D"=
color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', =
sans-serif; font-size: 14px; line-height: 17.8048000335693px;"><br></span><=
/div><div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 18=
7, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><cod=
e class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color:=
 #000;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">string</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> foo</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">string</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">());</span></d=
iv></code></div><span style=3D"font-family: monospace; color: rgb(102, 102,=
 0); background-color: rgb(250, 250, 250);"><br></span><span style=3D"color=
: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-=
serif; font-size: 14px; line-height: 17.8048000335693px;">will be no longer=
 interpreted as a function one.</span></div><div><span style=3D"color: rgb(=
0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;=
 font-size: 14px; line-height: 17.8048000335693px;"><br></span></div><div><=
span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', '=
DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.8048000335693px;=
">2nd proposal:</span></div><div><span style=3D"color: rgb(0, 0, 0); font-f=
amily: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px=
; line-height: 17.8048000335693px;"><br></span></div><div><font color=3D"#0=
00000" face=3D"Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style=
=3D"font-size: 14px; line-height: 17.8048000335693px;">Allowing&nbsp;</span=
></font><span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation=
 Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.8048000=
335693px;">this syntax:</span></div><div><span style=3D"color: rgb(0, 0, 0)=
; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-si=
ze: 14px; line-height: 17.8048000335693px;"><br></span></div><div><span sty=
le=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu S=
ans', sans-serif; font-size: 14px; line-height: 17.8048000335693px;"><b>(</=
b><i>complex-type</i><b>)()&nbsp;</b></span></div><div><span style=3D"color=
: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-=
serif; font-size: 14px; line-height: 17.8048000335693px;"><i><br></i></span=
></div><div><span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Libera=
tion Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.804=
8000335693px;"><i>complex-type-alias</i><b>()</b></span></div><div><span st=
yle=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu =
Sans', sans-serif; font-size: 14px; line-height: 17.8048000335693px;"><br><=
/span></div><div><font color=3D"#000000" face=3D"Arial, Liberation Sans, De=
jaVu Sans, sans-serif"><span style=3D"font-size: 14px; line-height: 17.8048=
000335693px;">For creating&nbsp;</span></font><font color=3D"#000000" face=
=3D"Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style=3D"font-si=
ze: 14px; line-height: 17.8048000335693px;">unnamed and&nbsp;uninitialized&=
nbsp;</span></font><span style=3D"color: rgb(0, 0, 0); font-family: Arial, =
'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height:=
 17.8048000335693px;">objects by using a complex-type in brackets or a&nbsp=
;</span><span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation=
 Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.8048000=
335693px;">complex-type type-alias. Those new structures will be used in ca=
ses when there is a function which will store some data in a reference obje=
ct, passed as an argument but you'll not always care about them and also wh=
en you want to 'return' raw arrays. Example of the first case:</span></div>=
<div><span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sa=
ns', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.8048000335=
693px;"><br></span></div><div><div class=3D"prettyprint" style=3D"border: 1=
px solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(2=
50, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><=
span style=3D"font-family: Arial, Helvetica, sans-serif; color: rgb(0, 0, 1=
36);"><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span>=
</span><span style=3D"font-family: Arial, Helvetica, sans-serif;"><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><span style=
=3D"font-family: Arial, Helvetica, sans-serif; color: rgb(102, 0, 102);"><s=
pan style=3D"color: #606;" class=3D"styled-by-prettify">DoSomeThingsAndStor=
eSomeData</span></span><span style=3D"font-family: Arial, Helvetica, sans-s=
erif; color: rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(</span></span><span style=3D"font-family: Arial, Helvetica,=
 sans-serif; color: rgb(0, 0, 136);"><span style=3D"color: #008;" class=3D"=
styled-by-prettify">i</span><wbr><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">nt</span></span><span style=3D"font-family: Arial, Helvetic=
a, sans-serif;"><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span></span><span style=3D"font-family: Arial, Helvetica, sans-serif; col=
or: rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(&amp;&amp;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">ref</span></span><span style=3D"font-family: Arial, Helvetica, sans-=
serif;"><span style=3D"color: #000;" class=3D"styled-by-prettify">Data</spa=
n></span><span style=3D"font-family: Arial, Helvetica, sans-serif; color: r=
gb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>)[</span></span><span style=3D"font-family: Arial, Helvetica, sans-serif; =
color: rgb(0, 102, 102);"><span style=3D"color: #066;" class=3D"styled-by-p=
rettify">260</span></span><span style=3D"font-family: Arial, Helvetica, san=
s-serif; color: rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">]</span></span><span style=3D"font-family: Arial, Helveti=
ca, sans-serif; color: rgb(102, 102, 0);"><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)</span></span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span></div></code></div><span style=3D"font-family: monospace; bac=
kground-color: rgb(250, 250, 250);"><div style=3D"color: rgb(102, 102, 0);"=
><span style=3D"font-family: monospace; color: rgb(102, 102, 0); background=
-color: rgb(250, 250, 250);"><br></span></div><div><font color=3D"#000000">=
<span class=3D"styled-by-prettify">Sometimes you will care about the data s=
tored at'</span><span style=3D"font-family: Arial, Helvetica, sans-serif;">=
<span class=3D"styled-by-prettify">ref</span></span><span style=3D"font-fam=
ily: Arial, Helvetica, sans-serif;"><span class=3D"styled-by-prettify">Data=
</span></span><span style=3D"font-family: Arial, Helvetica, sans-serif;"><s=
pan class=3D"styled-by-prettify">' but others you won't and in this cases y=
ou'll want to pass an&nbsp;</span></span><font face=3D"Arial, Liberation Sa=
ns, DejaVu Sans, sans-serif" style=3D"background-color: rgb(255, 255, 255);=
"><span style=3D"font-size: 14px; line-height: 17.8048000335693px;"><span c=
lass=3D"styled-by-prettify">unnamed and&nbsp;</span></span></font><span sty=
le=3D"font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; fon=
t-size: 14px; line-height: 17.8048000335693px; background-color: rgb(255, 2=
55, 255);"><span class=3D"styled-by-prettify">uninitialized</span></span><f=
ont face=3D"Arial, Liberation Sans, DejaVu Sans, sans-serif" style=3D"backg=
round-color: rgb(255, 255, 255);"><span style=3D"font-size: 14px; line-heig=
ht: 17.8048000335693px;"><span class=3D"styled-by-prettify">&nbsp;placehold=
er&nbsp;</span></span></font><span style=3D"font-family: Arial, 'Liberation=
 Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.8048000=
335693px; background-color: rgb(255, 255, 255);"><span class=3D"styled-by-p=
rettify">object (normally by using an argument default value) which you can=
't do for now. We could only write something&nbsp;</span></span></font><spa=
n style=3D"font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif=
; font-size: 14px; line-height: 17.8048000335693px; color: rgb(0, 0, 0); ba=
ckground-color: rgb(255, 255, 255);">like this:</span></div></span></div><d=
iv><span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans=
', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.804800033569=
3px;"><br></span></div><div><div class=3D"prettyprint" style=3D"border: 1px=
 solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250=
, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #606;" class=3D"styled-by-prettify">DoSomeThingsAndStoreSomeData</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(&amp;&amp;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">refData</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">)[</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">260</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">]</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">{}</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #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><span class=3D"styled-by=
-prettify" style=3D"font-family: monospace; color: rgb(102, 102, 0); backgr=
ound-color: rgb(250, 250, 250);"><br></span><font color=3D"#000000" face=3D=
"Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style=3D"font-size:=
 14px; line-height: 17.8048000335693px;">But the above construction, when t=
he function is instanced with no arguments, will zero-initialize the unname=
d object which will be referenced by '</span></font><span style=3D"color: r=
gb(0, 0, 0); font-family: monospace; background-color: rgb(250, 250, 250);"=
>refData</span><span style=3D"font-size: 14px; line-height: 17.804800033569=
3px; color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sa=
ns', sans-serif;">' and thus will waste program time. By using my new synta=
x we could write this to prevent it:</span></div><div><span style=3D"font-s=
ize: 14px; line-height: 17.8048000335693px; color: rgb(0, 0, 0); font-famil=
y: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;"><br></span></div><=
div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187=
); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code clas=
s=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;=
" class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">DoSomeThingsAndStoreSomeData</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(&amp;&amp;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">refData</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">)[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">2=
60</span><span style=3D"color: #660;" class=3D"styled-by-prettify">]</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">2=
60</span><span style=3D"color: #660;" class=3D"styled-by-prettify">])()</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">;</span></div></code></div><span class=3D=
"styled-by-prettify" style=3D"font-family: monospace; color: rgb(102, 102, =
0); background-color: rgb(250, 250, 250);"><br></span><span style=3D"font-s=
ize: 14px; line-height: 17.8048000335693px; color: rgb(0, 0, 0); font-famil=
y: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif;"><br>Or this (by us=
ing a type alias):</span></div><div><span style=3D"font-size: 14px; line-he=
ight: 17.8048000335693px; color: rgb(0, 0, 0); font-family: Arial, 'Liberat=
ion Sans', 'DejaVu Sans', sans-serif;"><br></span></div><div class=3D"prett=
yprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-wor=
d; background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div =
class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">using</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> int_260_array_type </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">260</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">];</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">DoSomeThingsAndStoreSomeData</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(&amp;&amp;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">refData</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">)[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">26=
0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">]</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> int_260_array_type</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">;</span></div></code></div><div><span style=3D"color: rgb(0,=
 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; f=
ont-size: 14px; line-height: 17.8048000335693px;"><br></span></div><div><sp=
an style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'De=
jaVu Sans', sans-serif; font-size: 14px; line-height: 17.8048000335693px;">=
Example of the second case (enabling the feature of 'returning' raw arrays)=
:</span><span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation=
 Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.8048000=
335693px;"><br></span></div><div><span style=3D"color: rgb(0, 0, 0); font-f=
amily: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px=
; line-height: 17.8048000335693px;"><br></span></div><div><div class=3D"pre=
ttyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-w=
ord; background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><di=
v class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-=
prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(&amp;=
&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">funcR=
eturnRawArray</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">(&amp;&amp;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">result</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">)[</span><span style=3D"c=
olor: #066;" class=3D"styled-by-prettify">5</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"col=
or: #066;" class=3D"styled-by-prettify">5</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">])()))[</span><span style=3D"color: #066;" c=
lass=3D"styled-by-prettify">5</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">]</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify"=
>//By default creates an temporary </span><span style=3D"font-family: Arial=
, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-heigh=
t: 17.8048000335693px; background-color: rgb(255, 255, 255);"><span style=
=3D"color: #800;" class=3D"styled-by-prettify">uninitialized object, emulat=
ing return value storage (as it's life-time equals to</span><span style=3D"=
color: #800;" class=3D"styled-by-prettify"> the expression of the function =
instance)</span></span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp=
; &nbsp; </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/=
/Do Something</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br><br><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">return</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(&amp;&amp;)[</span=
><span style=3D"color: #066;" class=3D"styled-by-prettify">5</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">])</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">result</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: #800;" class=3D"=
styled-by-prettify">//return a 'raw' array</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">}</span></div></code></div><font color=3D"#000000=
" face=3D"Arial, Liberation Sans, DejaVu Sans, sans-serif"><span style=3D"f=
ont-size: 14px; line-height: 17.8048000335693px;"><div><br></div></span></f=
ont></div></div>

<p></p>

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

------=_Part_917_613116477.1417121375723--
------=_Part_916_411338310.1417121375723--

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Fri, 28 Nov 2014 11:23:43 -0500
Raw View
On 2014-11-27 15:49, sasho648 wrote:
> void SomeFunc(int arg[5]); //which will be the same as void SomeFunc(int
> *arg);
>
>
> We first expect that only arrays of size '5' will be accept but this is not
> true, we can have the following, legal code:
>
> int arr[200];
>
>
> SomeFunc(arr); //Absolutely legal

Oh, it's *much* worse than that :-).

    int foo(int bar[5]) { ... }

    int main()
    {
        struct S
        {
            int a;
            float b;
        } s;

        foo(&s.a);
        return 0;
    }

Not even a warning, even with -Wall -Wextra. This is perfectly valid,
and yet oh so broken...

> 2. Encouraging people to use new proper implementations (like 'std::array').

....or just 'int foo(int (&)[5])'.

However, I think we need a way to pass an int[20] to such a function
first, or else we will break lots of existing code. (This particular
anti-pattern is all over VTK, to name one example, and there are lots
and lots of cases of passing a T[4] to a function that takes a T[3].)
Without a good solution for this, what will end up happening is that
T[N] signatures will all become T* instead, in order to preserve source
compatibility, which won't gain us anything and will lose that at least
the declaration suggests to the user how large the array should be.

--
Matthew

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: sasho648 <sasho648@mail.bg>
Date: Fri, 28 Nov 2014 11:41:22 -0800 (PST)
Raw View
------=_Part_7760_862447375.1417203682468
Content-Type: multipart/alternative;
 boundary="----=_Part_7761_209121635.1417203682474"

------=_Part_7761_209121635.1417203682474
Content-Type: text/plain; charset=UTF-8

@Matthew Woehlke If you mean declaring a function which will accept as
argument only pointer to arrays with specific size - this is already
implemented by using 'array' pointers and passing your arrays by address
(not using the implicit pointer to first element decay). Example:

void f(int (*)[4]);

//This function can only be instanced by passing a pointer to array of 4
int's (not a pointer to it's first element)

//Example instances


int main()
{
    int array[260];


    int array1[4];



    f(&array1); // Legal passes an argument of type 'int (*)[4]'


    f(&array); // Illegal passes an argument of type 'int (*)[260]'



    f(array); f(array1); //both illegal passes an argument of type 'int *'

}


So my suggestion will also encourage programmers like you to educate about
this syntax and use it instead of the other misleading one.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

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

<div dir=3D"ltr"><span class=3D"_username" style=3D"white-space: nowrap;"><=
span class=3D"GBT-Y1EDJ-B">@Matthew Woehlke</span></span><span style=3D"whi=
te-space: nowrap;">&nbsp;If you mean declaring a function which will accept=
 as argument only pointer to arrays with specific size - this is already im=
plemented by using 'array' pointers and passing your arrays by address (not=
 using the implicit pointer to first element decay). Example:</span><br><di=
v><span style=3D"white-space: nowrap;"><br></span></div><div class=3D"prett=
yprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-wor=
d; background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div =
class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">void</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">int</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=
: #066;" class=3D"styled-by-prettify">4</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">]);</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br></span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">//This function can only be instanced by passing a =
pointer to array of 4 int's (not a pointer to it's first element)</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span=
 style=3D"color: #800;" class=3D"styled-by-prettify">//Example instances</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br><=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> main</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color:=
 #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> array</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">[</span><span style=3D"color: #066;" class=3D"sty=
led-by-prettify">260</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">];</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br><br><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> array1</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">4=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">];</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br><br>&n=
bsp; &nbsp; f</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">a=
rray1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #800;" class=3D"styled-by-prettify">// Legal passes an arg=
ument of type 'int (*)[4]'</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>&nbsp; &nbsp; <br><br>&nbsp; &nbsp; f</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(&amp;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">array</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: #800;" class=3D=
"styled-by-prettify">// Illegal passes an argument of type 'int (*)[260]'</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br>=
<br>&nbsp; &nbsp; f</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
array</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> f</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">array1</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: #800;" cla=
ss=3D"styled-by-prettify">//both illegal passes an argument of type 'int *'=
</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></di=
v></code></div><div><span style=3D"white-space: nowrap;"><br></span></div><=
div><span style=3D"white-space: nowrap;"><br></span></div><div><span style=
=3D"white-space: nowrap;">So my suggestion will also encourage programmers =
like you to educate about this syntax and use it instead of the other misle=
ading one.</span></div></div>

<p></p>

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

------=_Part_7761_209121635.1417203682474--
------=_Part_7760_862447375.1417203682468--

.


Author: sasho648 <sasho648@mail.bg>
Date: Fri, 28 Nov 2014 11:49:25 -0800 (PST)
Raw View
------=_Part_633_318419774.1417204165099
Content-Type: multipart/alternative;
 boundary="----=_Part_634_151893294.1417204165099"

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

@Jens Maurer Compiling existing 'C' code in 'C++' which uses function=20
parameters declared as arrays could be done by using the "C" linkage=20
construct - "extern "C"". So 8.3.5/5 will look something like this:

After determining the type of each parameter, any parameter of type =E2=80=
=9Carray=20
of T=E2=80=9D or =E2=80=9Cfunction returning T=E2=80=9D is adjusted to be =
=E2=80=9Cpointer to T=E2=80=9D or=20
=E2=80=9Cpointer to function returning T,=E2=80=9D respectively, only if th=
e function is=20
declared to be with 'C' linkage. Otherwise parameters of type =E2=80=9Carra=
y of T=E2=80=9D=20
and =E2=80=9Cfunction returning T=E2=80=9D are not allowed.

--=20

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

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

<div dir=3D"ltr"><span class=3D"_username" style=3D"white-space: nowrap;"><=
span class=3D"GBT-Y1EDJ-B">@Jens Maurer</span></span><span style=3D"white-s=
pace: nowrap;">&nbsp;Compiling existing 'C' code in 'C++' which uses functi=
on parameters declared as arrays could be done by using the "C" linkage con=
struct - "</span><span class=3D"kw4" style=3D"line-height: 1.2em; color: rg=
b(0, 0, 255);">extern</span><span style=3D"color: rgb(0, 0, 0); line-height=
: 1.2em; background-color: rgb(249, 249, 249);"> </span><span class=3D"st0"=
 style=3D"line-height: 1.2em; color: rgb(0, 128, 0);">"C"</span><span style=
=3D"white-space: nowrap;">". So&nbsp;</span><span style=3D"color: rgb(0, 0,=
 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font=
-size: 14px; line-height: 17.8048000335693px;">8.3.5/5 will look something =
like this:<br></span><span style=3D"white-space: nowrap;"><br></span><span =
style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaV=
u Sans', sans-serif; font-size: 14px; line-height: 17.8048000335693px; back=
ground-color: rgb(238, 238, 238);">After determining the type of each param=
eter, any parameter of type =E2=80=9Carray of T=E2=80=9D or =E2=80=9Cfuncti=
on returning T=E2=80=9D is adjusted to be =E2=80=9Cpointer to T=E2=80=9D or=
 =E2=80=9Cpointer to function returning T,=E2=80=9D respectively, only if t=
he function is declared to be with 'C' linkage. Otherwise p</span><span sty=
le=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu S=
ans', sans-serif; font-size: 14px; line-height: 17.8048000335693px; backgro=
und-color: rgb(238, 238, 238);">arameters of type&nbsp;</span><span style=
=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu San=
s', sans-serif; font-size: 14px; line-height: 17.8048000335693px; backgroun=
d-color: rgb(238, 238, 238);">=E2=80=9Carray of T=E2=80=9D and&nbsp;</span>=
<span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', =
'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.8048000335693px=
; background-color: rgb(238, 238, 238);">=E2=80=9Cfunction returning T=E2=
=80=9D</span><span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Liber=
ation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.80=
48000335693px; background-color: rgb(238, 238, 238);">&nbsp;are not allowed=
..</span><br></div>

<p></p>

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

------=_Part_634_151893294.1417204165099--
------=_Part_633_318419774.1417204165099--

.