Topic: Some constexpr changes.
Author: sasho648 <sasho648@mail.bg>
Date: Mon, 22 Dec 2014 10:22:31 -0800 (PST)
Raw View
------=_Part_2719_1160526821.1419272551074
Content-Type: multipart/alternative;
boundary="----=_Part_2720_1527798493.1419272551074"
------=_Part_2720_1527798493.1419272551074
Content-Type: text/plain; charset=UTF-8
The propose and motivation is inhered from here
<https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/ej8T6Iyl8VM>
..
First allowing functions parameters to be declared constexpr, which, in
such case can be assigned only constant-expressions.
Example:
void Func(constexpr int a);
void Func(int a);
int *pa;
int b = 10;
Func(9); //instance 'void Func(constexpr int a)'
Func(*pa); //instance 'void Func(int a)'
Func(b); //instance one of the 2 function overloads, depending on how
compiler will asses the var 'b'
Second, declaring a function constexpr will mean that only constexpr values
can be returned from it and that *it is required* to be evaluated at
compile-time. The second statement will be also valid for functions with
constexpr parameters.
constexpr int FuncAdd(int a, int b)
{
return a + b; //is the expression constant or not is defined by how
the compiler would assess arguments 'a' & 'b'
}
cout << FuncAdd(9, 8) << endl; //ok, literals '9' & '8' are always constant
expression, so the return value is
int *pa;
cout << FuncAdd(*pa, 8) << endl; //error '*pa' can't be constant expression
*Note: In both of the above examples FuncAdd will be evaluated at
compile-time*
Third, functions with either constexpr return-value or parameters *won't
have any restrictions in their definitions. *Code in them that can't be
evaluated at compile-time will be used to create a new function, with it's
dependencies, which will be instanced at run-time.
constexpr int FuncAdd(int a, int b)
{
cout << a << " + " << b << " is " << a + b << endl;
return a + b;
}
FuncAdd(9, 8); //roughly equivalent to 'cout << 9 << " + " << 8 << " is "
<< 16 << endl;'
Fourth, variables declared as constexpr at global scope won't be editable.
However ones, declared in local scope, if not declared as const will be
modifiable only in control flow, defined from other const expressions and
only with other const expressions.
constexpr float Pi = 3.14;
void SomeFunc(bool b);
int main()
{
Pi = 3; //invalid, 'Pi' is declared in global namespace
int arr[10];
for(constexpr int i(0); i < 10; ++i) //ok, 'i' is a local and the
condition under which it will be edited is constant expression too ('i <
10')
arr[i] = 0;
//the above is equivalent to assigning zero on each array element like:
//arr[0] = 0; arr[1] = 0; arr[2] = 0; //....
const constexpr int Index = 90;
++Index; //invalid 'Index' is an uneditable local constant expression
}
--
---
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_2720_1527798493.1419272551074
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The propose and motivation is inhered from <a href=3D"http=
s://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/ej8T6Iyl8VM"=
>here</a>.<div><br></div><div>First allowing functions parameters to be dec=
lared constexpr, which, in such case can be assigned only constant-expressi=
ons.</div><div><br></div><div>Example:<br><br></div><div class=3D"prettypri=
nt" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; b=
ackground-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div clas=
s=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">void</span><span 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"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> a</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styl=
ed-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-pr=
ettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">F=
unc</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"> a</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></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: #000;" class=3D"style=
d-by-prettify">pa</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><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">int<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> b </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #066;" class=3D"styled-by-prettify">10</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br></span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">Func</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-by-p=
rettify">9</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">//instance 'void =
Func(constexpr int a)'</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br><br></span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">Func</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">(*</span><span style=3D"color: #000;" class=3D"styled-by-prettify">pa</=
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: #800;" class=3D"styled-by-prettify">//instance 'void Func(int a)=
'</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><=
/span><span style=3D"color: #606;" class=3D"styled-by-prettify">Func</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">b</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">//instance one of the 2 function overloads, dependi=
ng on how compiler will asses the var 'b'</span></div></code></div><div><br=
></div><div><br></div><div>Second, declaring a function constexpr will mean=
that only constexpr values can be returned from it and that <b>it is requi=
red</b> to be evaluated at compile-time. The second statement will be also =
valid for functions with constexpr parameters.</div><div><br></div><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: #008;" class=3D"s=
tyled-by-prettify">constexpr</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: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">FuncAdd=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> a</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: #008;" class=
=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> b</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &nbs=
p; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">r=
eturn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">+</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> b</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">//is the expression constant or not is defined=
by how the compiler would assess arguments 'a' & 'b'</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><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span></div></code></div><div><span st=
yle=3D"color: rgb(0, 0, 136); font-family: monospace; background-color: rgb=
(250, 250, 250);"><br></span></div><div><span style=3D"color: rgb(0, 0, 136=
); font-family: monospace; background-color: rgb(250, 250, 250);"><br></spa=
n></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: #=
000;" class=3D"styled-by-prettify">cout </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: #606;" class=3D"s=
tyled-by-prettify">FuncAdd</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">9</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: #066;" class=3D"styled-by-prettify">8</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;" cl=
ass=3D"styled-by-prettify"> endl</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-pret=
tify">//ok, literals '9' & '8' are always constant expression, so the r=
eturn value is</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><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"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">pa</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br><br>cout </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify"><<</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" cl=
ass=3D"styled-by-prettify">FuncAdd</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(*</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">pa</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">8</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify"><<</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> endl</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"style=
d-by-prettify">//error '*pa' can't be constant expression</span></div></cod=
e></div><div><span style=3D"color: rgb(102, 0, 102); font-family: monospace=
; background-color: rgb(250, 250, 250);"><br></span></div><div><i>Note: In =
both of the above examples FuncAdd will be evaluated at compile-time</i><sp=
an style=3D"color: rgb(0, 0, 136); font-family: monospace; background-color=
: rgb(250, 250, 250);"><br></span></div><div><br></div><div>Third, function=
s with either constexpr return-value or parameters <b>won't have any restri=
ctions in their definitions. </b>Code in them that can't be evaluated =
at compile-time will be used to create a new function, with it's dependenci=
es, which will be instanced at run-time.</div><div><br></div><div class=3D"=
prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: brea=
k-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">constexpr</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #606;" class=3D"styled-by-prettify">FuncAdd</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"> a</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: #000;" class=3D"styled-by-=
prettify"> b</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br> &nbs=
p;cout </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><=
;<</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a </=
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: #080;" 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"> b </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"st=
yled-by-prettify">" is "</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify"><<</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> a </span><span style=3D"color: #660;" class=3D"styled-by-prettify">+</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> b </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify"><<</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> endl</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br><br> </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> a </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">+</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> b</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"style=
d-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br><br><br></span><span style=3D"color: #606;" class=3D"styled-by-pr=
ettify">FuncAdd</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"color: #066;" class=3D"styled-by-prettify">9</s=
pan><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">8</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">//roughly equivalent to 'cout << 9 << " + " &=
lt;< 8 << " is " << 16 << endl;'</span></div></code></=
div><div><span style=3D"color: rgb(102, 0, 102); font-family: monospace; ba=
ckground-color: rgb(250, 250, 250);"><br></span></div><div><br></div><div>F=
ourth, variables declared as constexpr at global scope won't be editable. H=
owever ones, declared in local scope, if not declared as const will be modi=
fiable only in control flow, defined from other const expressions and only =
with other const expressions.</div><div><br></div><div class=3D"prettyprint=
" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; bac=
kground-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">constexpr</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">float</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">Pi</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: #066;" class=
=3D"styled-by-prettify">3.14</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">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><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> b</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: #008=
;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" clas=
s=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-b=
y-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
> </span><span style=3D"color: #606;" class=3D"styled-by=
-prettify">Pi</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</s=
pan><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: #800;" cla=
ss=3D"styled-by-prettify">//invalid, 'Pi' is declared in global namespace</=
span><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-prettif=
y"> arr</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[</=
span><span style=3D"color: #066;" class=3D"styled-by-prettify">10</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">];</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br> &n=
bsp;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">for</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> i</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #066;" class=3D"s=
tyled-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"><<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #066;" class=3D"styled-by-prettify">10</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"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//ok, =
'i' is a local and the condition under which it will be edited</span><span =
style=3D"color: #800;" class=3D"styled-by-prettify"> is constant expression=
too ('i < 10')</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br><br> arr</span><span style=3D"=
color: #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;" clas=
s=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">=3D</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 styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br><br> </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">//the above is =
equivalent to assigning zero on each array element like:</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br> </span=
><span style=3D"color: #800;" class=3D"styled-by-prettify">//arr[0] =3D 0; =
arr[1] =3D 0; arr[2] =3D 0; //....</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br></span><span style=3D"color: rgb(0, 0, 0);"=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span></span><span style=3D"color: #008;" class=3D"styled-by-prettify">const=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><sp=
an 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"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;=
" class=3D"styled-by-prettify">Index</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">=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 style=3D"color: #000;" class=3D"styled-by-prettify"><br><br> &=
nbsp; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">++</=
span><span style=3D"color: #606;" class=3D"styled-by-prettify">Index</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: #800;" class=3D"styled-by-prettify">//invalid 'Index' is an uneditable =
local constant expression</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br><br></span></div></code></div><div><br><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_2720_1527798493.1419272551074--
------=_Part_2719_1160526821.1419272551074--
.
Author: sasho648 <sasho648@mail.bg>
Date: Tue, 23 Dec 2014 07:00:12 -0800 (PST)
Raw View
------=_Part_3419_1533639046.1419346812814
Content-Type: multipart/alternative;
boundary="----=_Part_3420_1772714828.1419346812814"
------=_Part_3420_1772714828.1419346812814
Content-Type: text/plain; charset=UTF-8
I decided to change some of my suggestions.
First 'constexpr' will be both function-specifier and a variable one.
Functions which are 'constexpr' should be evaluated at compile-time. This
change reflects my second example:
constexpr int FuncAdd(int a, int b) //function declared as constexpr,
return type is 'int'
{
return a + b; //is the expression constant or not is defined by how
the compiler would assess arguments 'a' & 'b'
}
cout << FuncAdd(9, 8) << endl; //ok, literals '9' & '8' are always constant
expression, so the return value is
int *pa;
cout << FuncAdd(*pa, 8) << endl; //ok, returned value of 'FuncAdd' is
assessed as non-constant expression
And adds new ones:
auto constexpr FuncAdd(constexpr int a, constexpr int b) -> constexpr int //function
declared as constexpr, return type is 'constexpr int'
{
return a + b; //this expression will always be constexpr
}
cout << FuncAdd(9, 8) << endl; //ok, literals '9' & '8' are constant
expression
int *pa;
cout << FuncAdd(*pa, 8) << endl; //error, '*pa' is not a constant expression
I'm also suggesting the keyword 'explicit', being placed after a
'constexpr' function declaration, to be allowed and to specify that the
function shouldn't produce any run-time code and that it should be executed
all in run-time. Examples:
constexpr int FuncAdd(int a, int b) explicit
{
cout << a << " + " << b << " is " << a + b << endl; //should produce
error, 'std::ostream::operator<<' is not a an explicit constexpr function
return a + b;
}
constexpr int FuncAdd(int a, int b)
{
return a + b; //is the expression constant or not is defined by how
the compiler would assess arguments 'a' & 'b'
}
int *pa;
cout << FuncAdd(*pa, 8) << endl; //error '*pa' + 8 can't be evaluated at
compile-time
--
---
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_3420_1772714828.1419346812814
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>I decided to change some of my suggestions.</div><div=
><br></div><div><br></div><div>First 'constexpr' will be both function-spec=
ifier and a variable one. Functions which are 'constexpr' should be evaluat=
ed at compile-time. This change reflects my second example:</div><div><br><=
/div><div><br></div><div class=3D"prettyprint" style=3D"border: 1px solid r=
gb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 2=
50);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">FuncAdd</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"colo=
r: #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">//function declared as constexpr, return type is 'int'=
</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 st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br> <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">return</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> a </span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">+</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">//is the expression constant or not is defined by how the=
compiler would assess arguments 'a' & 'b'</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><di=
v><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);"><c=
ode class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">cout </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify"><<</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">FuncAdd</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-b=
y-prettify">9</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: #066;" class=3D"styled-by-prettify">8</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify"><<</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> endl</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: #800;" class=3D"styled-by-pr=
ettify">//ok, literals '9' & '8' are always constant expression, so the=
return value is</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">pa</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br><br>cout </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify"><<</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;"=
class=3D"styled-by-prettify">FuncAdd</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(*</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">pa</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">8</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify"><<</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> endl</span><span style=3D"color: #6=
60;" 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">//ok, returned value of 'FuncAdd' is assessed as non-consta=
nt expression</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br></span></div></code></div><div><br></div><div>And adds new ones:<br>=
<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"><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">FuncAdd</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">constexpr</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: #000;" class=3D"styled-by-prettify"> a</span><spa=
n 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">constexpr</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> b</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">->=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><sp=
an 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"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">//function declared as constexpr, return typ=
e is 'constexpr int'</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&=
nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">return</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> a </span><span style=3D"color: #660;" class=3D"styled-by-prettify">+<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> b</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=
: #800;" class=3D"styled-by-prettify">//this expression will always be cons=
texpr</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span></d=
iv></code></div><br><div><br><div class=3D"prettyprint" style=3D"border: 1p=
x solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(25=
0, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">cout </span><span s=
tyle=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: #606;" class=3D"styled-by-prettify">FuncAdd</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #066;" c=
lass=3D"styled-by-prettify">9</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: #066;" class=3D"styled-by-prettify"=
>8</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"><<</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> endl</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: #800;" class=
=3D"styled-by-prettify">//ok, literals '9' & '8' are constant expressio=
n</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><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"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">pa</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br>cout </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">FuncAdd</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(*</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">pa</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #066;" class=3D"styled-by-prettify">8</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;" cl=
ass=3D"styled-by-prettify"> endl</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-pret=
tify">//error, '*pa' is not a constant expression</span></div></code></div>=
<br><br>I'm also suggesting the keyword 'explicit', being placed after a 'c=
onstexpr' function declaration, to be allowed and to specify that the =
function shouldn't produce any run-time code and that it should be executed=
all in run-time. Examples:<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">constexpr</sp=
an><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: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">FuncAdd</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> a</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> b</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">explicit</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br> cout </span><span style=3D"color:=
#660;" class=3D"styled-by-prettify"><<</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> a </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"sty=
led-by-prettify">" + "</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"=
> b </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><&l=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #080;" class=3D"styled-by-prettify">" is "</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><<</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> a </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">+</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> b </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> endl</span><span style=3D"color: #660;" class=3D"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"=
>//should produce error, 'std::ostream::operator<<' is not a an expli=
cit constexpr function</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br><br> </span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> a </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">+</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> b</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span></div=
></code></div><span style=3D"font-family: monospace; color: rgb(102, 102, 0=
); background-color: rgb(250, 250, 250);"><div><span style=3D"font-family: =
monospace; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);">=
<br></span></div><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"><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><spa=
n 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"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;=
" class=3D"styled-by-prettify">FuncAdd</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> a</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">return</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> a </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">+</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> b</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">//is the=
expression constant or not is defined by how the compiler would assess arg=
uments 'a' & 'b'</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">}</span></div></code></div><span style=3D"font-family: monospace; color=
: rgb(102, 102, 0); background-color: rgb(250, 250, 250);"><br></span><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">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: #000;" class=3D"styled-by-prettify">p=
a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>cout </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 sty=
le=3D"color: #606;" class=3D"styled-by-prettify">FuncAdd</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(*</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">pa</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">8</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: #660;" class=3D"styled-by-prettify"><<</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"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">//error '*pa' + 8 can't be evaluated =
at compile-time</span></div></code></div><span style=3D"font-family: monosp=
ace; color: rgb(136, 0, 0); background-color: rgb(250, 250, 250);"><br></sp=
an><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_3420_1772714828.1419346812814--
------=_Part_3419_1533639046.1419346812814--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Tue, 23 Dec 2014 19:23:53 +0200
Raw View
On 23 December 2014 at 17:00, sasho648 <sasho648@mail.bg> wrote:
> I decided to change some of my suggestions.
>
>
> First 'constexpr' will be both function-specifier and a variable one.
> Functions which are 'constexpr' should be evaluated at compile-time. This
> change reflects my second example:
>
>
> constexpr int FuncAdd(int a, int b) //function declared as constexpr, return
> type is 'int'
> {
> return a + b; //is the expression constant or not is defined by how the
> compiler would assess arguments 'a' & 'b'
> }
>
>
> cout << FuncAdd(9, 8) << endl; //ok, literals '9' & '8' are always constant
> expression, so the return value is
>
> int *pa;
>
> cout << FuncAdd(*pa, 8) << endl; //ok, returned value of 'FuncAdd' is
> assessed as non-constant expression
How does this part change anything from the status quo?
>
> And adds new ones:
>
>
> auto constexpr FuncAdd(constexpr int a, constexpr int b) -> constexpr int
> //function declared as constexpr, return type is 'constexpr int'
> {
> return a + b; //this expression will always be constexpr
> }
>
>
> cout << FuncAdd(9, 8) << endl; //ok, literals '9' & '8' are constant
> expression
>
> int *pa;
>
> cout << FuncAdd(*pa, 8) << endl; //error, '*pa' is not a constant expression
I don't think it's an accident that
1) constexpr functions by design can be evaluated with runtime values, so it
would be interesting to know the views of the designers of constexpr
in this area
2) it's also no accident that implementations are not required to
evaluate constexpr
functions at translation time, so similarly the original designers'
views would be interesting.
> I'm also suggesting the keyword 'explicit', being placed after a 'constexpr'
> function declaration, to be allowed and to specify that the function
> shouldn't produce any run-time code and that it should be executed all in
> run-time. Examples:
>
> constexpr int FuncAdd(int a, int b) explicit
> {
> cout << a << " + " << b << " is " << a + b << endl; //should produce
> error, 'std::ostream::operator<<' is not a an explicit constexpr function
>
> return a + b;
> }
How is this different from the constexpr function returning a constexpr int?
Also, we know how to do context-sensitive keywords, so reusing explicit
for such a purpose is not the best of ideas because it's far from clear
what exactly is supposed to be explicit here.
--
---
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: Tue, 23 Dec 2014 10:01:55 -0800 (PST)
Raw View
------=_Part_3693_699752999.1419357715042
Content-Type: multipart/alternative;
boundary="----=_Part_3694_1128203221.1419357715042"
------=_Part_3694_1128203221.1419357715042
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
23 =D0=B4=D0=B5=D0=BA=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:23:54 UTC+2, Ville Voutilainen =D0=BD=D0=B0=
=D0=BF=D0=B8=D1=81=D0=B0:
>
> On 23 December 2014 at 17:00, sasho648 <sash...@mail.bg <javascript:>>=20
> wrote:=20
> > I decided to change some of my suggestions.=20
> >=20
> >=20
> > First 'constexpr' will be both function-specifier and a variable one.=
=20
> > Functions which are 'constexpr' should be evaluated at compile-time.=20
> This=20
> > change reflects my second example:=20
> >=20
> >=20
> > constexpr int FuncAdd(int a, int b) //function declared as constexpr,=
=20
> return=20
> > type is 'int'=20
> > {=20
> > return a + b; //is the expression constant or not is defined by ho=
w=20
> the=20
> > compiler would assess arguments 'a' & 'b'=20
> > }=20
> >=20
> >=20
> > cout << FuncAdd(9, 8) << endl; //ok, literals '9' & '8' are always=20
> constant=20
> > expression, so the return value is=20
> >=20
> > int *pa;=20
> >=20
> > cout << FuncAdd(*pa, 8) << endl; //ok, returned value of 'FuncAdd' is=
=20
> > assessed as non-constant expression=20
>
> How does this part change anything from the status quo?=20
>
> >=20
> > And adds new ones:=20
> >=20
> >=20
> > auto constexpr FuncAdd(constexpr int a, constexpr int b) -> constexpr=
=20
> int=20
> > //function declared as constexpr, return type is 'constexpr int'=20
> > {=20
> return a + b; //this expression will always be constexpr=20
> > }=20
> >=20
> >=20
> > cout << FuncAdd(9, 8) << endl; //ok, literals '9' & '8' are constant=20
> > expression=20
> >=20
> > int *pa;=20
> >=20
> > cout << FuncAdd(*pa, 8) << endl; //error, '*pa' is not a constant=20
> expression=20
>
> I don't think it's an accident that=20
> 1) constexpr functions by design can be evaluated with runtime values, so=
=20
> it=20
> would be interesting to know the views of the designers of constexpr=20
> in this area=20
> 2) it's also no accident that implementations are not required to=20
> evaluate constexpr=20
> functions at translation time, so similarly the original designers'=20
> views would be interesting.=20
>
>
> > I'm also suggesting the keyword 'explicit', being placed after a=20
> 'constexpr'=20
> > function declaration, to be allowed and to specify that the function=20
> > shouldn't produce any run-time code and that it should be executed all=
=20
> in=20
> > run-time. Examples:=20
> >=20
> > constexpr int FuncAdd(int a, int b) explicit=20
> > {=20
> > cout << a << " + " << b << " is " << a + b << endl; //should=20
> produce=20
> > error, 'std::ostream::operator<<' is not a an explicit constexpr=20
> function=20
> >=20
> > return a + b;=20
> > }=20
>
> How is this different from the constexpr function returning a constexpr=
=20
> int?=20
> Also, we know how to do context-sensitive keywords, so reusing explicit=
=20
> for such a purpose is not the best of ideas because it's far from clear=
=20
> what exactly is supposed to be explicit here.=20
>
It's different in that evaluating the function at compile-time wouldn't=20
produce any run-time code.
A function can return constant expression and still produces run-time code.=
=20
Example:
auto constexpr FuncAdd(constexpr int a, constexpr int b) -> constexpr int /=
/function=20
declared as constexpr, return type is 'constexpr int'
{
cout << a << " + " << b << " is " << a + b << endl;
return a + b; //this expression will always be constexpr
}
If we instance the above function like this:
FuncAdd(9, 8);
It will be roughly equivalent to writing this:
cout << 9 << " + " << 8 << " is " << 17 << endl;
If we declare the above function with the explicit keyword (or some other=
=20
specifier with similar meaning) it will fail to compiler because we are=20
instancing a function that will surely require run-time code (or one which=
=20
isn't declared with 'explicit'):
auto constexpr FuncAdd(constexpr int a, constexpr int b) explicit ->=20
constexpr int //function declared as constexpr, return type is 'constexpr=
=20
int'
{
cout << a << " + " << b << " is " << a + b << endl; //should produce=
=20
error, 'std::ostream::operator<<' is not a an explicit constexpr function
return a + b; //this expression will always be constexpr
}
This will be useful when there is a big hierarchy of const-expression calls=
=20
which we want to not to produce any additional run-time code.
Yes it will be very nice if constexpr designers comment this idea.
EDIT:
constexpr int FuncAdd(int a, int b) explicit
{
return a + b;
}
*I saw that I forgot the 'explicit' keyword in the above example.*
--=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_3694_1128203221.1419357715042
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>23 =D0=B4=D0=B5=D0=BA=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:23:54 UTC+2, Ville=
Voutilainen =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0:<blockquote class=3D"gmai=
l_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;=
padding-left: 1ex;">On 23 December 2014 at 17:00, sasho648 <<a href=3D"j=
avascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"fmlUhJrJ464J" onmous=
edown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'ja=
vascript:';return true;">sash...@mail.bg</a>> wrote:
<br>> I decided to change some of my suggestions.
<br>>
<br>>
<br>> First 'constexpr' will be both function-specifier and a variable o=
ne.
<br>> Functions which are 'constexpr' should be evaluated at compile-tim=
e. This
<br>> change reflects my second example:
<br>>
<br>>
<br>> constexpr int FuncAdd(int a, int b) //function declared as constex=
pr, return
<br>> type is 'int'
<br>> {
<br>> return a + b; //is the expression constant or =
not is defined by how the
<br>> compiler would assess arguments 'a' & 'b'
<br>> }
<br>>
<br>>
<br>> cout << FuncAdd(9, 8) << endl; //ok, literals '9' &=
; '8' are always constant
<br>> expression, so the return value is
<br>>
<br>> int *pa;
<br>>
<br>> cout << FuncAdd(*pa, 8) << endl; //ok, returned value =
of 'FuncAdd' is
<br>> assessed as non-constant expression
<br>
<br>How does this part change anything from the status quo?
<br>
<br>>
<br>> And adds new ones:
<br>>
<br>>
<br>> auto constexpr FuncAdd(constexpr int a, constexpr int b) -> con=
stexpr int
<br>> //function declared as constexpr, return type is 'constexpr int'
<br>> { </blockquote><blockquote class=3D"gmail_quote" style=3D"mar=
gin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">&=
gt; return a + b; //this expression will always be cons=
texpr
<br>> }
<br>>
<br>>
<br>> cout << FuncAdd(9, 8) << endl; //ok, literals '9' &=
; '8' are constant
<br>> expression
<br>>
<br>> int *pa;
<br>>
<br>> cout << FuncAdd(*pa, 8) << endl; //error, '*pa' is not=
a constant expression
<br>
<br>I don't think it's an accident that
<br>1) constexpr functions by design can be evaluated with runtime values, =
so it
<br>would be interesting to know the views of the designers of constexpr
<br>in this area
<br>2) it's also no accident that implementations are not required to
<br>evaluate constexpr
<br>functions at translation time, so similarly the original designers'
<br>views would be interesting.
<br>
<br>
<br>> I'm also suggesting the keyword 'explicit', being placed after a '=
constexpr'
<br>> function declaration, to be allowed and to specify that the functi=
on
<br>> shouldn't produce any run-time code and that it should be executed=
all in
<br>> run-time. Examples:
<br>>
<br>> constexpr int FuncAdd(int a, int b) explicit
<br>> {
<br>> cout << a << " + " << b <=
< " is " << a + b << endl; //should produce
<br>> error, 'std::ostream::operator<<' is not a an explicit const=
expr function
<br>>
<br>> return a + b;
<br>> }
<br>
<br>How is this different from the constexpr function returning a constexpr=
int?
<br>Also, we know how to do context-sensitive keywords, so reusing explicit
<br>for such a purpose is not the best of ideas because it's far from clear
<br>what exactly is supposed to be explicit here.
<br></blockquote><div><br></div><div>It's different in that evaluating the =
function at compile-time wouldn't produce any run-time code.</div><div><br>=
</div><div>A function can return constant expression and still produces run=
-time code. Example:</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"subp=
rettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">auto<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">FuncAdd</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">constexpr</span><span style=3D"color: #0=
00;" 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"> a</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">constexp=
r</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 st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> b</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><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">constexpr</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </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: #800;" class=3D"styled-by-prettify">//function decla=
red as constexpr, return type is 'constexpr int'</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> cout </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify"><<</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> a </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify"><<</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=
=3D"styled-by-prettify">" + "</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-pr=
ettify"> b </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
><<</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #080;" class=3D"styled-by-prettify">" is "</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 st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> a </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">+</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> b </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> endl</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br><br> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> a </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">+</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> b</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">//this expression=
will always be constexpr</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">}</span></div></code></div><div><span style=3D"font-family: monosp=
ace; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);"><br></=
span></div><div>If we instance the above function like this:<br><br><span s=
tyle=3D"color: rgb(102, 0, 102); font-family: monospace; background-color: =
rgb(250, 250, 250);"><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 styl=
e=3D"color: #606;" class=3D"styled-by-prettify">FuncAdd</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">9</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">8</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">);</span></div></code></div><br></span>It will be roughly equivalent=
to writing this:<br><br><span style=3D"color: rgb(136, 0, 0); font-family:=
monospace; background-color: rgb(250, 250, 250);"><div class=3D"prettyprin=
t" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; ba=
ckground-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">cout </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&l=
t;<</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #066;" class=3D"styled-by-prettify">9</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"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #08=
0;" 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"><<</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pr=
ettify">8</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><spa=
n style=3D"color: #080;" class=3D"styled-by-prettify">" is "</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify"><<</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;"=
class=3D"styled-by-prettify">17</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><<</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> endl</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span></div></code></div></span><br></div><div>If we declare the =
above function with the explicit keyword (or some other specifier with simi=
lar meaning) it will fail to compiler because we are instancing a function =
that will surely require run-time code (or one which isn't declared with 'e=
xplicit'):<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"color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">FuncAdd</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">constexpr</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: #000;" class=3D"styled-by-prettify"> a</s=
pan><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">constexpr</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> b</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: #008;" class=3D"styled-by-prettify"=
>explicit</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</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: #008;" class=3D"styled-by-prettify">constexpr</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><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: #800;" clas=
s=3D"styled-by-prettify">//function declared as constexpr, return type is '=
constexpr int'</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
cout </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify"><<</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> a </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;<</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #080;" 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"><<</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> b </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify"><<</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" =
class=3D"styled-by-prettify">" is "</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify"><<</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> a </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">+</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> b=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> endl</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #800;" class=3D"styled-by-prettify">//should produce error, 'std::ostr=
eam::operator<<' is not a an explicit constexpr function</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br><br> &=
nbsp;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">retur=
n</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">+</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> b</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: #800;" class=
=3D"styled-by-prettify">//this expression will always be constexpr</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></code></di=
v><span class=3D"styled-by-prettify" style=3D"font-family: monospace; color=
: rgb(102, 102, 0); background-color: rgb(250, 250, 250);"><br></span></div=
><div>This will be useful when there is a big hierarchy of const-expression=
calls which we want to not to produce any additional run-time code.<br></d=
iv><div><br></div><div>Yes it will be very nice if constexpr designers comm=
ent this idea.</div><div><br></div><div>EDIT:<br><br><div class=3D"prettypr=
int" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; =
background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div cla=
ss=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">constexpr</span><span style=3D"color: #000;" 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><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">FuncAdd</span><span s=
tyle=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: #=
000;" class=3D"styled-by-prettify"> a</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: #000;" class=3D"styled-by-prettify=
"> b</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: #008;" class=3D"styled-by-prettify">explicit</span><span sty=
le=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: #0=
00;" class=3D"styled-by-prettify"><br> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> a </span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">+</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> b</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-prett=
ify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
</span></div></code></div><div><br></div><div><i>I saw that I forgot the 'e=
xplicit' keyword in the above example.</i></div></div><div><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_3694_1128203221.1419357715042--
------=_Part_3693_699752999.1419357715042--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Tue, 23 Dec 2014 16:20:55 -0200
Raw View
On Tuesday 23 December 2014 19:23:53 Ville Voutilainen wrote:
> 2) it's also no accident that implementations are not required to
> evaluate constexpr
> functions at translation time, so similarly the original designers'
> views would be interesting.
Wait, what?
I assume you mean when you're assigning to a variable that isn't itself
constexpr.
So:
constexpt int five() { return 5; }
static int five_too() { return 5; }
constexpr int i1 = five(); // always compile-time, never runtime
constexpr int i2 = five_too(); // compilation error
int i3 = five(); // compile-time or runtime
int i4 = five_too(); // compile-time or runtime
Is that it?
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
--
---
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: Tue, 23 Dec 2014 13:47:04 -0800 (PST)
Raw View
------=_Part_713_1544699603.1419371224125
Content-Type: multipart/alternative;
boundary="----=_Part_714_836419038.1419371224125"
------=_Part_714_836419038.1419371224125
Content-Type: text/plain; charset=UTF-8
I thought that it'll be clearer, 'constexpr' function specifier, to be
written after the function declaration. Also as a keyword that will
restrict code-generation in an constant-expression function, I thought that
keyword 'true' before 'constexpr' will be more meaningful then 'explicit'.
So here are some examples using this new syntax:
constexpr int FuncAdd(int a, int b); // 'FuncAdd' have a return-type of
'constexpr int'
int FuncAdd(int a, int b) constexpr; // 'FuncAdd' function is 'constexpr'
int FuncAdd(int a, int b) true constexpr; // 'FuncAdd' function is 'true
constexpr' and so it isn't allowed to generate run-time code
What would you say - is this way better?
--
---
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_714_836419038.1419371224125
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I thought that it'll be clearer, 'constexpr' function spec=
ifier, to be written after the function declaration. Also as a keyword that=
will restrict code-generation in an constant-expression function, I though=
t that keyword 'true' before 'constexpr' will be more meaningful then 'expl=
icit'. So here are some examples using this new syntax:<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">constexpr</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">FuncAdd</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span style=3D"colo=
r: #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: #000;" class=3D"styled=
-by-prettify"> b</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #800;" class=3D"styled-by-prettify">// 'FuncAdd=
' have a return-type of 'constexpr int'</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by=
-prettify">FuncAdd</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">i=
nt</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> b</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: #008;" class=3D"styled-by-pr=
ettify">constexpr</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #800;" class=3D"styled-by-prettify">// 'FuncAdd=
' function is 'constexpr'</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Fun=
cAdd</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"> a</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> b</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: #008;" class=3D"styled-by-prettify">tr=
ue</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</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">// 'FuncAdd' function is 'true const=
expr' and so it isn't allowed to generate run-time code</span></div></code>=
</div><div><br><span class=3D"styled-by-prettify" style=3D"font-family: mon=
ospace; color: rgb(136, 0, 0); background-color: rgb(250, 250, 250);"><br><=
/span>What would you say - is this way better?<br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_714_836419038.1419371224125--
------=_Part_713_1544699603.1419371224125--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Tue, 23 Dec 2014 19:49:15 -0200
Raw View
On Tuesday 23 December 2014 13:47:04 sasho648 wrote:
> I thought that it'll be clearer, 'constexpr' function specifier, to be
> written after the function declaration. Also as a keyword that will
> restrict code-generation in an constant-expression function, I thought that
> keyword 'true' before 'constexpr' will be more meaningful then 'explicit'.
> So here are some examples using this new syntax:
>
> constexpr int FuncAdd(int a, int b); // 'FuncAdd' have a return-type of
> 'constexpr int'
>
> int FuncAdd(int a, int b) constexpr; // 'FuncAdd' function is 'constexpr'
>
> int FuncAdd(int a, int b) true constexpr; // 'FuncAdd' function is 'true
> constexpr' and so it isn't allowed to generate run-time code
>
>
> What would you say - is this way better?
Irrelevant question, since it's impossible.
constexpr int FuncAdd(int a, int b)
declares a constexpr function that returns int.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
--
---
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: Tue, 23 Dec 2014 13:52:37 -0800 (PST)
Raw View
------=_Part_3936_1451172905.1419371557593
Content-Type: multipart/alternative;
boundary="----=_Part_3937_891235356.1419371557593"
------=_Part_3937_891235356.1419371557593
Content-Type: text/plain; charset=UTF-8
What is it impossible?
--
---
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_3937_891235356.1419371557593
Content-Type: text/html; charset=UTF-8
<div dir="ltr">What is it impossible?</div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an 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_3937_891235356.1419371557593--
------=_Part_3936_1451172905.1419371557593--
.
Author: sasho648 <sasho648@mail.bg>
Date: Tue, 23 Dec 2014 14:37:40 -0800 (PST)
Raw View
------=_Part_651_748134302.1419374260984
Content-Type: multipart/alternative;
boundary="----=_Part_652_376460529.1419374260984"
------=_Part_652_376460529.1419374260984
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Sorry for bumping but I just wanted to edit myself for a second time. It's=
=20
not a good idea 'constexpr' specifier to be put after declaration, because=
=20
this doesn't allow us to create a possible implementation of 'constexpr'=20
class functions. That's way they'll be put before function declaration as=
=20
before. This will also allow C++11 code compatibility. So the previous=20
examples will be written like:
auto FuncAdd(int a, int b) -> constexpr int; // 'FuncAdd' have a=20
return-type of 'constexpr int'
constexpr int FuncAdd(int a, int b); // 'FuncAdd' function is 'constexpr'
true constexpr int FuncAdd(int a, int b); // 'FuncAdd' function is 'true=20
constexpr' and so it isn't allowed to generate run-time code
Please discuss this and the implementability of my ideas.
23 =D0=B4=D0=B5=D0=BA=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, 23:47:04 UTC+2, sasho648 =D0=BD=D0=B0=D0=BF=D0=
=B8=D1=81=D0=B0:
>
> I thought that it'll be clearer, 'constexpr' function specifier, to be=20
> written after the function declaration. Also as a keyword that will=20
> restrict code-generation in an constant-expression function, I thought th=
at=20
> keyword 'true' before 'constexpr' will be more meaningful then 'explicit'=
..=20
> So here are some examples using this new syntax:
>
> constexpr int FuncAdd(int a, int b); // 'FuncAdd' have a return-type of=
=20
> 'constexpr int'
>
> int FuncAdd(int a, int b) constexpr; // 'FuncAdd' function is 'constexpr'
>
> int FuncAdd(int a, int b) true constexpr; // 'FuncAdd' function is 'true=
=20
> constexpr' and so it isn't allowed to generate run-time code
>
>
> What would you say - is this way better?
>
--=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_652_376460529.1419374260984
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Sorry for bumping but I just wanted to edit myself for a s=
econd time. It's not a good idea 'constexpr' specifier to be put after decl=
aration, because this doesn't allow us to create a possible implementation =
of 'constexpr' class functions. That's way they'll be put before function d=
eclaration as before. This will also allow C++11 code compatibility. So the=
previous examples will be written like:<br><br><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">=
auto</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #606;" class=3D"styled-by-prettify">FuncAdd</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> a</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: #008;" class=3D"style=
d-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> b</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"> </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">constexpr</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">int</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: #800;" class=3D"styled-by-pr=
ettify">// 'FuncAdd' have a return-type of 'constexpr int'</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">FuncAdd</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"colo=
r: #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">// 'FuncAdd' function is 'constexpr'</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">true</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pr=
ettify">FuncAdd</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"> a</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: #000;=
" class=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-pre=
ttify">// 'FuncAdd' function is 'true constexpr' and so it isn't allowed to=
generate run-time code</span></div></code></div><div><br></div>Please disc=
uss this and the implementability of my ideas.<br><br>23 =D0=B4=D0=B5=D0=BA=
=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, 23:47:04 UTC+2, sasho648 =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0:<bloc=
kquote 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">I thought that it'=
ll be clearer, 'constexpr' function specifier, to be written after the func=
tion declaration. Also as a keyword that will restrict code-generation in a=
n constant-expression function, I thought that keyword 'true' before 'const=
expr' will be more meaningful then 'explicit'. So here are some examples us=
ing this new syntax:<br><br><div style=3D"border:1px solid rgb(187,187,187)=
;word-wrap:break-word;background-color:rgb(250,250,250)"><code><div><span s=
tyle=3D"color:#008">constexpr</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#008">int</span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#606">FuncAdd</span><span style=3D"color:#660">(</span><span =
style=3D"color:#008">int</span><span style=3D"color:#000"> a</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">int</span><span style=3D"color:#000"> b</span><span style=
=3D"color:#660">);</span><span style=3D"color:#000"> </span><span style=3D"=
color:#800">// 'FuncAdd' have a return-type of 'constexpr int'</span><span =
style=3D"color:#000"><br><br></span><span style=3D"color:#008">int</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#606">FuncAdd</span><=
span style=3D"color:#660">(</span><span style=3D"color:#008">int</span><spa=
n style=3D"color:#000"> a</span><span style=3D"color:#660">,</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#008">int</span><span style=
=3D"color:#000"> b</span><span style=3D"color:#660">)</span><span style=3D"=
color:#000"> </span><span style=3D"color:#008">constexpr</span><span style=
=3D"color:#660">;</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#800">// 'FuncAdd' function is 'constexpr'</span><span style=3D"color:=
#000"><br><br></span><span style=3D"color:#008">int</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#606">FuncAdd</span><span style=3D"c=
olor:#660">(</span><span style=3D"color:#008">int</span><span style=3D"colo=
r:#000"> a</span><span style=3D"color:#660">,</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#008">int</span><span style=3D"color:#000"=
> b</span><span style=3D"color:#660">)</span><span style=3D"color:#000"> </=
span><span style=3D"color:#008">true</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#008">constexpr</span><span style=3D"color:#660">;<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#800">// 'Fun=
cAdd' function is 'true constexpr' and so it isn't allowed to generate run-=
time code</span></div></code></div><div><br><span style=3D"font-family:mono=
space;color:rgb(136,0,0);background-color:rgb(250,250,250)"><br></span>What=
would you say - is this way better?<br></div></div></blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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_652_376460529.1419374260984--
------=_Part_651_748134302.1419374260984--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Tue, 23 Dec 2014 23:31:21 -0200
Raw View
On Tuesday 23 December 2014 14:37:40 sasho648 wrote:
> Please discuss this and the implementability of my ideas.
By the way, if you really want this to work, you should implement them
yourself or convince someone to do it. Most of the non-trivial language
enhancements need to have an implementation in one of the two open source
compilers proving that they work before they get to be considered.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
--
---
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: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 24 Dec 2014 11:15:38 +0200
Raw View
On 23 December 2014 at 20:20, Thiago Macieira <thiago@macieira.org> wrote:
> On Tuesday 23 December 2014 19:23:53 Ville Voutilainen wrote:
>> 2) it's also no accident that implementations are not required to
>> evaluate constexpr
>> functions at translation time, so similarly the original designers'
>> views would be interesting.
>
> Wait, what?
>
> I assume you mean when you're assigning to a variable that isn't itself
> constexpr.
>
> So:
>
> constexpt int five() { return 5; }
> static int five_too() { return 5; }
>
> constexpr int i1 = five(); // always compile-time, never runtime
> constexpr int i2 = five_too(); // compilation error
> int i3 = five(); // compile-time or runtime
> int i4 = five_too(); // compile-time or runtime
>
> Is that it?
That "always compile-time, never run-time" is "always static
initialization, never
dynamic initialization", and I don't see a requirement that it cannot
be performed
at run-time. Therefore the suggestion that no run-time code can be generated
seems like a new restriction to me. Yes, I know, a high-quality implementation
will do that initialization at translation time, but I don't think we
require that to
be so. And if we want to start requiring that, the question is, why would we?
--
---
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: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 24 Dec 2014 11:22:34 +0200
Raw View
On 23 December 2014 at 20:01, sasho648 <sasho648@mail.bg> wrote:
>> How does this part change anything from the status quo?
> It's different in that evaluating the function at compile-time wouldn't
> produce any run-time code.
Neither does the existing evaluation of a constant expression, if the
target context of that expression is a constexpr variable. I guess
you want to be able to guarantee that target contexts that can be
either constant expression or runtime values, like indexing operator
arguments would benefit from being required to be constant expressions.
There are indirect ways to do that; instead of writing
myArray[getSomeValue()];
one would need
constexpr int foo = getSomeValue();
myArray[foo];
There are, naturally, situations where that is infeasible. For such situations,
perhaps we'd need to allow constexpr lambdas instead of making changes
or additions to constexpr functions?
--
---
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: Wed, 24 Dec 2014 02:52:25 -0800 (PST)
Raw View
------=_Part_4159_88976533.1419418345591
Content-Type: multipart/alternative;
boundary="----=_Part_4160_779971819.1419418345591"
------=_Part_4160_779971819.1419418345591
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
24 =D0=B4=D0=B5=D0=BA=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014, =D1=81=D1=80=D1=
=8F=D0=B4=D0=B0, 11:15:40 UTC+2, Ville Voutilainen =D0=BD=D0=B0=D0=BF=D0=B8=
=D1=81=D0=B0:
>
> On 23 December 2014 at 20:20, Thiago Macieira <thi...@macieira.org=20
> <javascript:>> wrote:=20
> > On Tuesday 23 December 2014 19:23:53 Ville Voutilainen wrote:=20
> >> 2) it's also no accident that implementations are not required to=20
> >> evaluate constexpr=20
> >> functions at translation time, so similarly the original designers'=20
> >> views would be interesting.=20
> >=20
> > Wait, what?=20
> >=20
> > I assume you mean when you're assigning to a variable that isn't itself=
=20
> > constexpr.=20
> >=20
> > So:=20
> >=20
> > constexpt int five() { return 5; }=20
> > static int five_too() { return 5; }=20
> >=20
> > constexpr int i1 =3D five(); // always compile-time, never=
=20
> runtime=20
> > constexpr int i2 =3D five_too(); // compilation error=20
> > int i3 =3D five(); // compile-time or runtime=20
> > int i4 =3D five_too(); // compile-time or runtime=20
> >=20
> > Is that it?=20
>
>
> That "always compile-time, never run-time" is "always static=20
> initialization, never=20
> dynamic initialization", and I don't see a requirement that it cannot=20
> be performed=20
> at run-time. Therefore the suggestion that no run-time code can be=20
> generated=20
> seems like a new restriction to me. Yes, I know, a high-quality=20
> implementation=20
> will do that initialization at translation time, but I don't think we=20
> require that to=20
> be so. And if we want to start requiring that, the question is, why would=
=20
> we?=20
>
Actually I'm not proposing such restriction as it's already there and=20
instead I want it to be lifted - you can't generate run-time code by=20
calling 'constexpr' function, which will be used as a constant expression.=
=20
Some examples:
constexpr int Func()
{
cout << "Hi" << endl;
=20
return 9;
}
The above code will generate compile-time error under Clang=20
<http://melpon.org/wandbox/permlink/pp20lvyNpMpZIeLt>, stating that 'Func'=
=20
never produces constant expression. My propose is such function to be=20
valid, even if used to initialize a constant expression, and to produce=20
run-time code which instance the line which inputs 'Hi' unless the function=
=20
is declared as 'true constexpr' (which means that a function should be=20
always executed at compile-time and no run-time code should be produced).=
=20
Some examples using the above function:
struct S
{
std::array<int, Func()> arr; //equal to constructing an object with=20
'Func()' in global space, should instance 'cout << "Hi" << endl;' before=20
executing 'main()'
} ;
int main()
{
std::array<int, Func()> arr; //equal to instancing 'Func()' right here
}
If you want to be sure that such 'non-expected' code will be generated, you=
=20
declared the function as 'true constexpr':
true constexpr int Func()
{
cout << "Hi" << endl; //error, this will surely require run-time code=
=20
to be produced (or we are instancing an non-true constant-expression=20
function)
=20
return 9;
}
--=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_4160_779971819.1419418345591
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>24 =D0=B4=D0=B5=D0=BA=D0=B5=D0=BC=D0=B2=D1=80=D0=
=B8 2014, =D1=81=D1=80=D1=8F=D0=B4=D0=B0, 11:15:40 UTC+2, Ville Voutilainen=
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0:<blockquote class=3D"gmail_quote" sty=
le=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left=
: 1ex;">On 23 December 2014 at 20:20, Thiago Macieira <<a href=3D"javasc=
ript:" target=3D"_blank" gdf-obfuscated-mailto=3D"GyXWRd16ohEJ" onmousedown=
=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascr=
ipt:';return true;">thi...@macieira.org</a>> wrote:
<br>> On Tuesday 23 December 2014 19:23:53 Ville Voutilainen wrote:
<br>>> 2) it's also no accident that implementations are not required=
to
<br>>> evaluate constexpr
<br>>> functions at translation time, so similarly the original desig=
ners'
<br>>> views would be interesting.
<br>>
<br>> Wait, what?
<br>>
<br>> I assume you mean when you're assigning to a variable that isn't i=
tself
<br>> constexpr.
<br>>
<br>> So:
<br>>
<br>> constexpt int five() { return 5; }
<br>> static int five_too() { return 5; }
<br>>
<br>> constexpr int i1 =3D five(); &n=
bsp; // always compile-time, never runtime
<br>> constexpr int i2 =3D five_too(); // compilation error
<br>> int i3 =3D five();  =
; // compile-time or runtime
<br>> int i4 =3D five_too(); //=
compile-time or runtime
<br>>
<br>> Is that it?
<br>
<br>
<br>That "always compile-time, never run-time" is "always static
<br>initialization, never
<br>dynamic initialization", and I don't see a requirement that it cannot
<br>be performed
<br>at run-time. Therefore the suggestion that no run-time code can be gene=
rated
<br>seems like a new restriction to me. Yes, I know, a high-quality impleme=
ntation
<br>will do that initialization at translation time, but I don't think we
<br>require that to
<br>be so. And if we want to start requiring that, the question is, why wou=
ld we? <br></blockquote><div><br></div><div>Actually I'm not proposing=
such restriction as it's already there and instead I want it to be lifted =
- you can't generate run-time code by calling 'constexpr' function, which w=
ill be used as a constant expression. Some examples:<br><br><div class=3D"p=
rettyprint" 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-b=
y-prettify">constexpr</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: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #606;" class=3D"styled-by-prettify">Func</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><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br> cout </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><<</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">"Hi"</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"> endl</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br> <br> </span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">return</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">9</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
}</span></div></code></div><div><br></div></div><div>The above code will ge=
nerate compile-time error under <a href=3D"http://melpon.org/wandbox/permli=
nk/pp20lvyNpMpZIeLt">Clang</a>, stating that 'Func' never produces constant=
expression. My propose is such function to be valid, even if used to initi=
alize a constant expression, and to produce run-time code which instance th=
e line which inputs 'Hi' unless the function is declared as 'true constexpr=
' (which means that a function should be always executed at compile-time an=
d no run-time code should be produced). Some examples using the above funct=
ion:<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"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> S<br></span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br> std</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">array</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">int</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: #606;" class=3D"styled-by-prettify">F=
unc</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">;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #800;" class=3D"styled-by-prettify">//equal to constructing an object w=
ith 'Func()' in global space, should instance 'cout << "Hi" << =
endl;' before executing 'main()'</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"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
;</span></div></code></div><div><br></div><div><br></div><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=
"> 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 sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br> std</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">::</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"co=
lor: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" 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: #000;" class=3D"styled-by-pret=
tify"> arr</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">//equal to instanc=
ing 'Func()' right here</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">}</span></div></code></div><div><br></div><div>If you want to be sur=
e that such 'non-expected' code will be generated, you declared the functio=
n as 'true constexpr':<br><br><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"color: #008;" class=3D"styled-by-prettify">true</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">constexpr</span><span style=3D"co=
lor: #000;" 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: #606;" class=3D"styl=
ed-by-prettify">Func</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">{</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &n=
bsp; cout </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
<<</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #080;" class=3D"styled-by-prettify">"Hi"</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify"><<</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> endl</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: #800;" class=
=3D"styled-by-prettify">//error, this will surely require run-time code to =
be produced (or we are instancing an non-true constant-expression function)=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
<br> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">return</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettif=
y">9</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></code>=
</div><span class=3D"styled-by-prettify" style=3D"font-family: monospace; c=
olor: rgb(102, 102, 0); background-color: rgb(250, 250, 250);"><br></span><=
br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_4160_779971819.1419418345591--
------=_Part_4159_88976533.1419418345591--
.
Author: sasho648 <sasho648@mail.bg>
Date: Wed, 24 Dec 2014 02:57:21 -0800 (PST)
Raw View
------=_Part_2953_1120320233.1419418641741
Content-Type: multipart/alternative;
boundary="----=_Part_2954_1326242299.1419418641741"
------=_Part_2954_1326242299.1419418641741
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Are you sure about this? Can I just write some good-worded proposal and=20
send it to ISO C++?
24 =D0=B4=D0=B5=D0=BA=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014, =D1=81=D1=80=D1=
=8F=D0=B4=D0=B0, 03:31:27 UTC+2, Thiago Macieira =D0=BD=D0=B0=D0=BF=D0=B8=
=D1=81=D0=B0:
>
> On Tuesday 23 December 2014 14:37:40 sasho648 wrote:=20
> > Please discuss this and the implementability of my ideas.=20
>
> By the way, if you really want this to work, you should implement them=20
> yourself or convince someone to do it. Most of the non-trivial language=
=20
> enhancements need to have an implementation in one of the two open source=
=20
> compilers proving that they work before they get to be considered.=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
>
>
--=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_2954_1326242299.1419418641741
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Are you sure about this? Can I just write some good-worded=
proposal and send it to ISO C++?<br><br>24 =D0=B4=D0=B5=D0=BA=D0=B5=D0=BC=
=D0=B2=D1=80=D0=B8 2014, =D1=81=D1=80=D1=8F=D0=B4=D0=B0, 03:31:27 UTC+2, Th=
iago Macieira =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0:<blockquote class=3D"gma=
il_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid=
;padding-left: 1ex;">On Tuesday 23 December 2014 14:37:40 sasho648 wrote:
<br>> Please discuss this and the implementability of my ideas.
<br>
<br>By the way, if you really want this to work, you should implement them=
=20
<br>yourself or convince someone to do it. Most of the non-trivial language=
=20
<br>enhancements need to have an implementation in one of the two open sour=
ce=20
<br>compilers proving that they work before they get to be considered.
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%=
3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg\75AFQjCNEswDUBNCNanbu7euhq=
Ln_62FW8ag';return true;" onclick=3D"this.href=3D'http://www.google.com/url=
?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg\75AFQjCNEswDUBNC=
Nanbu7euhqLn_62FW8ag';return true;">macieira.info</a> - thiago (AT) <a href=
=3D"http://kde.org" target=3D"_blank" onmousedown=3D"this.href=3D'http://ww=
w.google.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AFQj=
CNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;" onclick=3D"this.href=3D'http:=
//www.google.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75=
AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;">kde.org</a>
<br> Software Architect - Intel Open Source Technology Center
<br> PGP/GPG: 0x6EF45358; fingerprint:
<br> E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4=
5358
<br>
<br></blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_2954_1326242299.1419418641741--
------=_Part_2953_1120320233.1419418641741--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Wed, 24 Dec 2014 10:28:09 -0200
Raw View
On Wednesday 24 December 2014 11:15:38 Ville Voutilainen wrote:
> That "always compile-time, never run-time" is "always static
> initialization, never
> dynamic initialization", and I don't see a requirement that it cannot
> be performed
> at run-time. Therefore the suggestion that no run-time code can be generated
> seems like a new restriction to me. Yes, I know, a high-quality
> implementation will do that initialization at translation time, but I don't
> think we require that to
> be so. And if we want to start requiring that, the question is, why would
> we?
Indeed. As long as it happens on static initialisation time, I guess it
suffices. The user can't tell the static initialisation that happened at
translation time from static initialisation that happened very early at
runtime, provided all static initialisation in all translation units is done
before the first dynamic initialisation happens.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
--
---
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: Thiago Macieira <thiago@macieira.org>
Date: Wed, 24 Dec 2014 10:28:58 -0200
Raw View
On Wednesday 24 December 2014 02:57:21 sasho648 wrote:
> Are you sure about this? Can I just write some good-worded proposal and
> send it to ISO C++?
You can. But your chances increase if you can prove it works.
>=20
> 24 =D0=B4=D0=B5=D0=BA=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014, =D1=81=D1=80=D1=
=8F=D0=B4=D0=B0, 03:31:27 UTC+2, Thiago Macieira =D0=BD=D0=B0=D0=BF=D0=B8=
=D1=81=D0=B0:
> > On Tuesday 23 December 2014 14:37:40 sasho648 wrote:
> > > Please discuss this and the implementability of my ideas.
> >=20
> > By the way, if you really want this to work, you should implement them
> > yourself or convince someone to do it. Most of the non-trivial language
> > enhancements need to have an implementation in one of the two open sour=
ce
> > compilers proving that they work before they get to be considered.
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
--=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: sasho648 <sasho648@mail.bg>
Date: Wed, 31 Dec 2014 05:27:35 -0800 (PST)
Raw View
------=_Part_214_1952199652.1420032455799
Content-Type: multipart/alternative;
boundary="----=_Part_215_1364392298.1420032455799"
------=_Part_215_1364392298.1420032455799
Content-Type: text/plain; charset=UTF-8
Just wanted to add another reason for adding 'constexpr' parameters which
is written in this post
<https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/RdAK-0RyiY0>
..
It's about accessing 'std::tuple' elements which would be easier by adding
the ability function parameters to be 'constexpr'.
--
---
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_215_1364392298.1420032455799
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Just wanted to add another reason for adding 'constexpr' p=
arameters which is written in this <a href=3D"https://groups.google.com/a/i=
socpp.org/forum/#!topic/std-proposals/RdAK-0RyiY0">post</a>.<div><br></div>=
<div>It's about accessing 'std::tuple' elements which would be easier by ad=
ding the ability function parameters to be 'constexpr'.</div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_215_1364392298.1420032455799--
------=_Part_214_1952199652.1420032455799--
.
Author: kkimdev@gmail.com
Date: Wed, 4 Jan 2017 12:38:01 -0800 (PST)
Raw View
------=_Part_559_796304230.1483562281310
Content-Type: multipart/alternative;
boundary="----=_Part_560_922095691.1483562281311"
------=_Part_560_922095691.1483562281311
Content-Type: text/plain; charset=UTF-8
Also, we can have constexpr math functions so that things like std::exp(x)
can be evaluated at compile or run time depending on x.
Personally, I'm creating a custom floating point class that flushes
subnormal numbers to zero at initialization. with SSE enabled, I can use
inline assembly to do that more efficiently but that can't be constexpr.
So being able to distinguish constexpr argument and selecting optimized
code depending on it will be really useful.
On Wednesday, December 31, 2014 at 5:27:35 AM UTC-8, sasho648 wrote:
>
> Just wanted to add another reason for adding 'constexpr' parameters which
> is written in this post
> <https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/RdAK-0RyiY0>
> .
>
> It's about accessing 'std::tuple' elements which would be easier by adding
> the ability function parameters to be 'constexpr'.
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/6bca56a7-3ddf-496a-9728-3b29c7fdb200%40isocpp.org.
------=_Part_560_922095691.1483562281311
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Also, we can have constexpr math functions so that th=
ings like std::exp(x) can be evaluated at compile or run time depending on =
x.<br></div><div><br></div><div>Personally, I'm creating a custom float=
ing point class that flushes subnormal numbers to zero at initialization. =
=C2=A0with SSE enabled, I can use inline assembly to do that more efficient=
ly but that can't be constexpr. =C2=A0So being able to distinguish cons=
texpr argument and selecting optimized code depending on it will be really =
useful.<br><br>On Wednesday, December 31, 2014 at 5:27:35 AM UTC-8, sasho64=
8 wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0=
..8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Just =
wanted to add another reason for adding 'constexpr' parameters whic=
h is written in this <a href=3D"https://groups.google.com/a/isocpp.org/foru=
m/#!topic/std-proposals/RdAK-0RyiY0" target=3D"_blank" rel=3D"nofollow" onm=
ousedown=3D"this.href=3D'https://groups.google.com/a/isocpp.org/forum/#=
!topic/std-proposals/RdAK-0RyiY0';return true;" onclick=3D"this.href=3D=
'https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/RdA=
K-0RyiY0';return true;">post</a>.<div><br></div><div>It's about acc=
essing 'std::tuple' elements which would be easier by adding the ab=
ility function parameters to be 'constexpr'.</div></div></blockquot=
e></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/6bca56a7-3ddf-496a-9728-3b29c7fdb200%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/6bca56a7-3ddf-496a-9728-3b29c7fdb200=
%40isocpp.org</a>.<br />
------=_Part_560_922095691.1483562281311--
------=_Part_559_796304230.1483562281310--
.
Author: kk1674@nyu.edu
Date: Wed, 4 Jan 2017 12:39:44 -0800 (PST)
Raw View
------=_Part_52_1568363895.1483562384244
Content-Type: multipart/alternative;
boundary="----=_Part_53_125556158.1483562384244"
------=_Part_53_125556158.1483562384244
Content-Type: text/plain; charset=UTF-8
Also, we can have constexpr math functions so that things like std::exp(x)
can be evaluated at compile or run time depending on x.
Personally, I'm creating a custom floating point class that flushes
subnormal numbers to zero at initialization. with SSE enabled, I can use
inline assembly to do that more efficiently but that can't be constexpr.
So being able to distinguish constexpr argument and selecting optimized
code depending on it will be really useful.
On Wednesday, December 31, 2014 at 5:27:35 AM UTC-8, sasho648 wrote:
>
> Just wanted to add another reason for adding 'constexpr' parameters which
> is written in this post
> <https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/RdAK-0RyiY0>
> .
>
> It's about accessing 'std::tuple' elements which would be easier by adding
> the ability function parameters to be 'constexpr'.
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ef38ae5c-df77-44dd-840b-58e88253ecd2%40isocpp.org.
------=_Part_53_125556158.1483562384244
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Also, we can have constexpr math functions so that th=
ings like std::exp(x) can be evaluated at compile or run time depending on =
x.<br></div><div><br></div><div>Personally, I'm creating a custom float=
ing point class that flushes subnormal numbers to zero at initialization. =
=C2=A0with SSE enabled, I can use inline assembly to do that more efficient=
ly but that can't be constexpr. =C2=A0So being able to distinguish cons=
texpr argument and selecting optimized code depending on it will be really =
useful.</div><br>On Wednesday, December 31, 2014 at 5:27:35 AM UTC-8, sasho=
648 wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:=
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Jus=
t wanted to add another reason for adding 'constexpr' parameters wh=
ich is written in this <a href=3D"https://groups.google.com/a/isocpp.org/fo=
rum/#!topic/std-proposals/RdAK-0RyiY0" target=3D"_blank" rel=3D"nofollow" o=
nmousedown=3D"this.href=3D'https://groups.google.com/a/isocpp.org/forum=
/#!topic/std-proposals/RdAK-0RyiY0';return true;" onclick=3D"this.href=
=3D'https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/=
RdAK-0RyiY0';return true;">post</a>.<div><br></div><div>It's about =
accessing 'std::tuple' elements which would be easier by adding the=
ability function parameters to be 'constexpr'.</div></div></blockq=
uote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/ef38ae5c-df77-44dd-840b-58e88253ecd2%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/ef38ae5c-df77-44dd-840b-58e88253ecd2=
%40isocpp.org</a>.<br />
------=_Part_53_125556158.1483562384244--
------=_Part_52_1568363895.1483562384244--
.
Author: "D. B." <db0451@gmail.com>
Date: Wed, 4 Jan 2017 20:40:42 +0000
Raw View
--001a1145b1be698a5305454accec
Content-Type: text/plain; charset=UTF-8
There are several threads floating around here, relatively near the top of
the list, which discuss the prospect of constexpr function arguments. I
think anything worth saying about this is worth saying there - or has
already been said.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhEjRz7j8nSkEaC7P_8zd1qSv7F28qvJ8WixyuXoVSyh0Q%40mail.gmail.com.
--001a1145b1be698a5305454accec
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">There are several threads floating around here, relatively=
near the top of the list, which discuss the prospect of constexpr function=
arguments. I think anything worth saying about this is worth saying there =
- or has already been said.<br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CACGiwhEjRz7j8nSkEaC7P_8zd1qSv7F28qvJ=
8WixyuXoVSyh0Q%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhEjRz7j8nSk=
EaC7P_8zd1qSv7F28qvJ8WixyuXoVSyh0Q%40mail.gmail.com</a>.<br />
--001a1145b1be698a5305454accec--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Thu, 05 Jan 2017 08:34:22 -0800
Raw View
Em quarta-feira, 4 de janeiro de 2017, =C3=A0s 12:38:01 PST, kkimdev@gmail.=
com=20
escreveu:
> Personally, I'm creating a custom floating point class that flushes
> subnormal numbers to zero at initialization. with SSE enabled, I can use
> inline assembly to do that more efficiently but that can't be constexpr.
> So being able to distinguish constexpr argument and selecting optimized
> code depending on it will be really useful.
I've been saying that for a couple of years.
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/2529732.makOUjdjQ3%40tjmaciei-mobl1.
.