Topic: Choosing value categories using a specialized
Author: Tony V E <tvaneerd@gmail.com>
Date: Wed, 10 Feb 2016 11:10:34 -0500
Raw View
<html><head></head><body lang=3D"en-US" style=3D"background-color: rgb(255,=
255, 255); line-height: initial;"> =
<div style=3D"width: 100%; fo=
nt-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif=
; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, =
255, 255);">Not a bad idea. </div><div style=3D"width: 100%; font-size=
: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color=
: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 25=
5);"><br></div><div style=3D"width: 100%; font-size: initial; font-family: =
Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text=
-align: initial; background-color: rgb(255, 255, 255);">But I'd rather see =
some kind of language feature for param passing. A "pass by copy if cheap"=
=E2=80=8E syntax. Also a pass by copy-if-write (for cases where the functio=
n body I available to determine that). </div><div style=3D"width: 100%=
; font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-s=
erif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(2=
55, 255, 255);"><br></div><div style=3D"width: 100%; font-size: initial; fo=
nt-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73,=
125); text-align: initial; background-color: rgb(255, 255, 255);">Vaguely =
speaking. </div> =
<=
div style=3D"width: 100%; font-size: initial; font-family: Calibri, 'Slate =
Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-align: initial;=
background-color: rgb(255, 255, 255);"><br style=3D"display:initial"></div=
> =
=
<div style=3D"font-size: init=
ial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(=
31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);">S=
ent from my BlackBerry portable Babbage Devic=
e</div> =
=
<table width=3D"100%" style=3D"backgroun=
d-color:white;border-spacing:0px;"> <tbody><tr><td colspan=3D"2" style=3D"f=
ont-size: initial; text-align: initial; background-color: rgb(255, 255, 255=
);"> <div style=3D"border-style: solid none none;=
border-top-color: rgb(181, 196, 223); border-top-width: 1pt; padding: 3pt =
0in 0in; font-family: Tahoma, 'BB Alpha Sans', 'Slate Pro'; font-size: 10pt=
;"> <div><b>From: </b>Andr=C3=A9</div><div><b>Sent: </b>Wednesday, Februar=
y 10, 2016 10:37 AM</div><div><b>To: </b>ISO C++ Standard - Future Proposal=
s</div><div><b>Reply To: </b>std-proposals@isocpp.org</div><div><b>Subject:=
</b>[std-proposals] Choosing value categories using a specialized traits c=
lass</div></div></td></tr></tbody></table><div style=3D"border-style: solid=
none none; border-top-color: rgb(186, 188, 209); border-top-width: 1pt; fo=
nt-size: initial; text-align: initial; background-color: rgb(255, 255, 255)=
;"></div><br><div id=3D"_originalContent" style=3D""><div dir=3D"ltr">Hello=
everyone,<div><br></div><div>This idea for a proposal comes from discussio=
ns such as <a href=3D"http://stackoverflow.com/questions/3009543/passi=
ng-integers-as-constant-references-versus-copying">this</a> one. There=
are several situations in STL's API in which integral values are passed by=
const reference, such as <a href=3D"http://www.cplusplus.com/referenc=
e/vector/vector/insert/">vector's insert</a> for template parameters o=
f integral types. Consider the following code:</div><div><br></div><div><di=
v 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"pr=
ettyprint"><div class=3D"subprettyprint"><font color=3D"#660066"><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">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">vector</span><span style=3D"color: #080;" =
class=3D"styled-by-prettify"><int></span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> v</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">...</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br><br>v</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">push_back</span><span style=3D"col=
or: #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">);</span></font></div></code></div><br>I'm not sure=
to at what extent do compilers optimize this (if at all) by passing "a" by=
copy instead of using a constant reference. In any case, this idea would s=
olve this problem at the framework level, which seems optimal to me. Consid=
er <a href=3D"http://www.cplusplus.com/reference/vector/vector/push_ba=
ck/">push_back</a>'s signature:<br></div><div><br></div><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"><pre style=3D"color: rgb(0, 128, 0); font-siz=
e: 12px; background-color: rgb(250, 255, 250);"><span style=3D"color: #008;=
" class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> push_back </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">const</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> value_type</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> val</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">);</span></pre></div></code></div><br>This proposal consists in providing=
a template <u>traits</u> class that implements a set of typedefs and =
specializes them to provider cleaner and optimal definitions, regarding mul=
tiple situations. Here's a simplified example:</div><div><br></div><div><di=
v 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"pr=
ettyprint"><div class=3D"subprettyprint"><p class=3D"p1"><span class=3D"s2"=
style=3D"font-family: Arial, Helvetica, sans-serif;"><span style=3D"color:=
#008;" class=3D"styled-by-prettify">template</span></span><span class=3D"s=
1" style=3D"font-family: Arial, Helvetica, sans-serif;"><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;"=
class=3D"styled-by-prettify"><</span></span><span class=3D"s2" style=3D=
"font-family: Arial, Helvetica, sans-serif;"><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">class</span></span><span class=3D"s1" style=3D"=
font-family: Arial, Helvetica, sans-serif;"><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> T</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><span class=3D"s2" style=3D"font-family: Arial,=
Helvetica, sans-serif;"><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">class</span></span><span class=3D"s1" style=3D"font-family: Arial, =
Helvetica, sans-serif;"><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> traits</span></span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span><span class=3D"s1"></span></p><p class=3D"p2"><span c=
lass=3D"s1"><span style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an></span></p><p class=3D"p3"><span class=3D"s1"><span style=3D"color: #008=
;" class=3D"styled-by-prettify">public</span></span><span class=3D"s3"><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">:</span></span></p><p=
class=3D"p1"><span class=3D"s1"><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span></span></p><p class=3D"p2"><span class=
=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify"> &=
nbsp;</span></span><span class=3D"s2"><span style=3D"color: #008;" class=3D=
"styled-by-prettify">typedef</span></span><span class=3D"s1"><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> T value_type</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span></span></p><p class=
=3D"p1"><span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span></span></p><p class=3D"p2"><span class=3D"s1=
"><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span></span><span class=3D"s2"><span style=3D"color: #008;" class=3D"style=
d-by-prettify">typedef</span></span><span class=3D"s1"><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span></span><span class=3D"s4"><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">value_type</span></s=
pan><span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&am=
p;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> referen=
ce</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span>=
</span></p><p class=3D"p2"><span class=3D"s1"><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span></span><span class=3D"s2"=
><span style=3D"color: #008;" class=3D"styled-by-prettify">typedef</span></=
span><span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span></span><span class=3D"s4"><span style=3D"color: #000;" class=
=3D"styled-by-prettify">value_type</span></span><span class=3D"s1"><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"color: #000=
;" class=3D"styled-by-prettify"> pointer</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">;</span></span></p><p class=3D"p1"><span clas=
s=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span></span></p><p class=3D"p2"><span class=3D"s1"><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span></span><span=
class=3D"s2"><span style=3D"color: #008;" class=3D"styled-by-prettify">typ=
edef</span></span><span class=3D"s1"><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span></span><span class=3D"s2"><span style=3D"color:=
#008;" class=3D"styled-by-prettify">const</span></span><span class=3D"s1">=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><s=
pan class=3D"s4"><span style=3D"color: #000;" class=3D"styled-by-prettify">=
value_type</span></span><span class=3D"s1"><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> const_reference</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">;</span></span></p><p class=3D"p2"><span class=3D"s1"><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
></span><span class=3D"s2"><span style=3D"color: #008;" class=3D"styled-by-=
prettify">typedef</span></span><span class=3D"s1"><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span></span><span class=3D"s2"><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">const</span></span><span =
class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan></span><span class=3D"s4"><span style=3D"color: #000;" class=3D"styled-=
by-prettify">value_type</span></span><span class=3D"s1"><span style=3D"colo=
r: #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"> const_pointer</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">;</span></span></p><p class=3D"p2"><span class=3D"=
s1"><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span></sp=
an></p></div></code></div><br>In this case, it doesn't do much other than d=
efining some pretty standard stuff. These definitions can be found immensel=
y in STL. The next step would be to provide some more exotic definitions. S=
ome examples:</div><div><ul><li><span style=3D"line-height: normal;"><b>arg=
ument_type</b> solves the problem described. For integral types this w=
ould evaluate to value_type and for class types it would evaluate to const_=
reference.</span></li><li><span style=3D"line-height: normal;"><b>tag_type<=
/b> the generic template would declare an empty struct (tag_type) and =
a constant (tag) of that type. Useful for implementing <a href=3D"http=
://www.generic-programming.org/languages/cpp/techniques.php#tag_dispatching=
">tag dispatching</a>.</span></li></ul><div>I was actually considering incl=
uding other types in this discussion, such as allocator_type, which would "=
recommend" an allocator, but so far these two proposals seem the strongest =
on the table. For instance, recommending an allocator is not as trivial as =
checking a given type, as it also depends on the container (i.e. a "recomme=
ndable" allocator for int will most likely be different for list<int>=
and vector<int>). Here's what would (probably) be a naive approach t=
o this problem:</div><div><br></div><div><div class=3D"prettyprint" style=
=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background=
-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subp=
rettyprint"><p class=3D"p2"><span class=3D"s2"><span style=3D"color: #008;"=
class=3D"styled-by-prettify">template</span></span><span class=3D"s1"><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><</span></span><span clas=
s=3D"s2"><span style=3D"color: #008;" class=3D"styled-by-prettify">class</s=
pan></span><span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> T</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></span><span class=3D"s2"><span style=3D"color: #008;" class=3D"=
styled-by-prettify">class</span></span><span class=3D"s1"><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> _traits_commons</span></span></p>=
<p class=3D"p2"><span class=3D"s1"><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{</span></span></p><p class=3D"p3"><span class=3D"s1"><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">public</span></span>=
<span class=3D"s3"><span style=3D"color: #660;" class=3D"styled-by-prettify=
">:</span></span></p><p class=3D"p1"><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br> </span><span style=3D"color: #800;" cl=
ass=3D"styled-by-prettify">/* Standard stuff */</span></p><p class=3D"p2"><=
span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span></span><span class=3D"s2"><span style=3D"color: #008;=
" class=3D"styled-by-prettify">typedef</span></span><span class=3D"s1"><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> T value_type</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">;</span></span></p=
><p class=3D"p2"><span class=3D"s1"><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span></span><span class=3D"s2"><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">typedef</span></span><span=
class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span></span><span class=3D"s4"><span style=3D"color: #000;" class=3D"styled=
-by-prettify">value_type</span></span><span class=3D"s1"><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> reference</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">;</span></span></p><p class=3D"p2"><span class=3D=
"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify"> &nbs=
p;</span></span><span class=3D"s2"><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">typedef</span></span><span class=3D"s1"><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span></span><span class=3D"s4">=
<span style=3D"color: #000;" class=3D"styled-by-prettify">value_type</span>=
</span><span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
*</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> pointer<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span></s=
pan></p><p class=3D"p2"><span class=3D"s1"><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span></span><span class=3D"s2"><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">typedef</span></spa=
n><span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span></span><span class=3D"s2"><span style=3D"color: #008;" class=3D=
"styled-by-prettify">const</span></span><span class=3D"s1"><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span></span><span class=3D"s4"=
><span style=3D"color: #000;" class=3D"styled-by-prettify">value_type</span=
></span><span class=3D"s1"><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"> con=
st_reference</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span></span></p><p class=3D"p2"><span class=3D"s1"><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span></span><span cl=
ass=3D"s2"><span style=3D"color: #008;" class=3D"styled-by-prettify">typede=
f</span></span><span class=3D"s1"><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span></span><span class=3D"s2"><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">const</span></span><span class=3D"s1"><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><span=
class=3D"s4"><span style=3D"color: #000;" class=3D"styled-by-prettify">val=
ue_type</span></span><span class=3D"s1"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> const_pointer</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">;</span></span></p><p class=3D"p2"><span class=3D"s1"><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span></span>=
<span class=3D"s2"><span style=3D"color: #008;" class=3D"styled-by-prettify=
">typedef</span></span><span class=3D"s1"><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span></span><span class=3D"s5"><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">std</span></span><span class=3D"s=
1"><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span></spa=
n><span class=3D"s5"><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">ptrdiff_t</span></span><span class=3D"s1"><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> difference_type</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">;</span></span></p><p class=3D"p2"><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br> </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">/* argument_typ=
e as described */</span></p><p class=3D"p2"><span class=3D"s1"><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span></span>=
<span class=3D"s2"><span style=3D"color: #008;" class=3D"styled-by-prettify=
">typedef</span></span><span class=3D"s1"><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span></span><span class=3D"s4"><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">value_type</span></span><span cla=
ss=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify"> argume=
nt_type</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &=
nbsp;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">typed=
ef</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> value_type const_argu=
ment_type</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;=
</span></span></p><p class=3D"p1"><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br> </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">/* Tag dispatching */</span></p><p class=3D"p2"><sp=
an class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span></span><span class=3D"s2"><span style=3D"color: #008;" =
class=3D"styled-by-prettify">typedef</span></span><span class=3D"s1"><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><span cl=
ass=3D"s2"><span style=3D"color: #008;" class=3D"styled-by-prettify">struct=
</span></span><span class=3D"s1"><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
tag_type</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;<=
/span></span></p><p class=3D"p2"><span class=3D"s1"><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span></span><span class=
=3D"s2"><span style=3D"color: #008;" class=3D"styled-by-prettify">static</s=
pan></span><span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span></span><span class=3D"s2"><span style=3D"color: #008;"=
class=3D"styled-by-prettify">const</span></span><span class=3D"s1"><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><span cla=
ss=3D"s4"><span style=3D"color: #000;" class=3D"styled-by-prettify">tag_typ=
e</span></span><span class=3D"s1"><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> tag</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">;</span></span></p><p class=3D"p2"><span class=3D"s1"><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">};</span></span></p><p clas=
s=3D"p1"><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span class=3D"s1"></span></p><p class=3D"p3"><span class=3D"s1"><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">template</span></span><s=
pan class=3D"s3"><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</spa=
n></span><span class=3D"s1"><span style=3D"color: #008;" class=3D"styled-by=
-prettify">class</span></span><span class=3D"s3"><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> T</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><span class=3D"s1"><span style=3D"color: #008=
;" class=3D"styled-by-prettify">class</span></span><span class=3D"s3"><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> E </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span></span><span class=3D"s1"><=
span style=3D"color: #008;" class=3D"styled-by-prettify">void</span></span>=
<span class=3D"s3"><span style=3D"color: #660;" class=3D"styled-by-prettify=
">></span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <br=
></span></span><span class=3D"s1"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">class</span></span><span class=3D"s3"><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> traits</span></span></p><p class=3D"=
p4"><span class=3D"s3"><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span></span><span class=3D"s2"><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">public</span></span><span class=3D"s3"><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span></span><span class=3D"s1"><=
span style=3D"color: #000;" class=3D"styled-by-prettify">_traits_commons</s=
pan></span><span class=3D"s3"><span style=3D"color: #660;" class=3D"styled-=
by-prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&g=
t;</span></span></p><p class=3D"p2"><span class=3D"s1"><span style=3D"color=
: #660;" class=3D"styled-by-prettify">{</span></span></p><p class=3D"p3"><s=
pan class=3D"s1"><span style=3D"color: #008;" class=3D"styled-by-prettify">=
private</span></span><span class=3D"s3"><span style=3D"color: #660;" class=
=3D"styled-by-prettify">:</span></span></p><p class=3D"p1"><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span></p><p class=3D"p2"><s=
pan class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span></span><span class=3D"s2"><span style=3D"color: #008;"=
class=3D"styled-by-prettify">typedef</span></span><span class=3D"s1"><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><span c=
lass=3D"s4"><span style=3D"color: #000;" class=3D"styled-by-prettify">_trai=
ts_commons</span></span><span class=3D"s1"><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">></span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> _base_type</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span></span></p><p class=3D"p1"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span></p><p class=3D"p3"><span class=3D"s1"><=
span style=3D"color: #008;" class=3D"styled-by-prettify">public</span></spa=
n><span class=3D"s3"><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">:</span></span></p><p class=3D"p1"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span></p><p class=3D"p2"><span class=3D"s1"><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n></span><span class=3D"s2"><span style=3D"color: #008;" class=3D"styled-by=
-prettify">typedef</span></span><span class=3D"s1"><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span></span><span class=3D"s2"><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">typename</span></span><s=
pan class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span></span><span class=3D"s4"><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">_base_type</span></span><span class=3D"s1"><span style=3D"=
color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">value_type value_type</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span></span></p><p class=
=3D"p2"><span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span></span><span class=3D"s2"><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">typedef</span></span><span class=3D=
"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span></sp=
an><span class=3D"s2"><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">typename</span></span><span class=3D"s1"><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span></span><span class=3D"s4"><span style=
=3D"color: #000;" class=3D"styled-by-prettify">_base_type</span></span><spa=
n class=3D"s1"><span style=3D"color: #660;" class=3D"styled-by-prettify">::=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">reference =
reference</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;=
</span></span></p><p class=3D"p2"><span class=3D"s1"><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span></span><span class=
=3D"s2"><span style=3D"color: #008;" class=3D"styled-by-prettify">typedef</=
span></span><span class=3D"s1"><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span></span><span class=3D"s2"><span style=3D"color: #008;=
" class=3D"styled-by-prettify">typename</span></span><span class=3D"s1"><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><span=
class=3D"s4"><span style=3D"color: #000;" class=3D"styled-by-prettify">_ba=
se_type</span></span><span class=3D"s1"><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">pointer pointer</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span></span></p><p class=3D"p2"><span class=3D"s1">=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan></span><span class=3D"s2"><span style=3D"color: #008;" class=3D"styled-=
by-prettify">typedef</span></span><span class=3D"s1"><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span></span><span class=3D"s2"><span=
style=3D"color: #008;" class=3D"styled-by-prettify">typename</span></span>=
<span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span></span><span class=3D"s4"><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">_base_type</span></span><span class=3D"s1"><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">const_reference const_reference</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span></span>=
</p><p class=3D"p2"><span class=3D"s1"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span></span><span class=3D"s2"><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">typedef</span></span>=
<span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span></span><span class=3D"s2"><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">typename</span></span><span class=3D"s1"><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span></span><span class=3D"s4=
"><span style=3D"color: #000;" class=3D"styled-by-prettify">_base_type</spa=
n></span><span class=3D"s1"><span style=3D"color: #660;" class=3D"styled-by=
-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">const_pointer const_pointer</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">;</span></span></p><p class=3D"p2"><span class=3D"s1"><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an></span><span class=3D"s2"><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">typedef</span></span><span class=3D"s1"><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span></span><span class=3D"s2"><span =
style=3D"color: #008;" class=3D"styled-by-prettify">typename</span></span><=
span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span></span><span class=3D"s4"><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">_base_type</span></span><span class=3D"s1"><span style=3D=
"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">difference_type difference_type</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">;</span></span></p=
><p class=3D"p2"><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span></p><p class=3D"p2"><span class=3D"s1"><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span></span><span class=3D"=
s2"><span style=3D"color: #008;" class=3D"styled-by-prettify">typedef</span=
></span><span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span></span><span class=3D"s2"><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">typename</span></span><span class=3D"s1"><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><span cla=
ss=3D"s4"><span style=3D"color: #000;" class=3D"styled-by-prettify">_base_t=
ype</span></span><span class=3D"s1"><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">argument_type argument_type</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">typedef</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><font color=3D"#000088"><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> _base_type</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify">const_argument_type const_argument_type</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span></font><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br> <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">typedef</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> _base_type</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">tag_type tag_type</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">;</span></span></p><p cla=
ss=3D"p2"><span class=3D"s1"><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">};</span></span></p><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br></span><p class=3D"p2"><span class=3D"s2"><span style=3D=
"color: #008;" class=3D"styled-by-prettify">template</span></span><span cla=
ss=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span></spa=
n><span class=3D"s2"><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">class</span></span><span class=3D"s1"><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> <br></span></span><span class=3D"s2"><span style=3D"color: #008=
;" class=3D"styled-by-prettify">class</span></span><span class=3D"s1"><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> traits</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span></span><span class=3D"s2"><span style=3D"=
color: #008;" class=3D"styled-by-prettify">typename</span></span><span clas=
s=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
</span><span class=3D"s5"><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">std</span></span><span class=3D"s1"><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">::</span></span><span class=3D"s5"><span style=
=3D"color: #000;" class=3D"styled-by-prettify">enable_if</span></span><span=
class=3D"s1"><span style=3D"color: #660;" class=3D"styled-by-prettify"><=
;</span></span><span class=3D"s5"><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">std</span></span><span class=3D"s1"><span style=3D"color: =
#660;" class=3D"styled-by-prettify">::</span></span><span class=3D"s5"><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">is_class</span></span=
><span class=3D"s1"><span style=3D"color: #660;" class=3D"styled-by-prettif=
y"><</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">>::</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">value</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">>::</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">type</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">></span></span></p><p class=
=3D"p4"><span class=3D"s3"><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-prett=
ify"> </span></span><span class=3D"s2"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">public</span></span><span class=3D"s3"><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><span class=
=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify">_traits_c=
ommons</span></span><span class=3D"s3"><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">></span></span></p><p class=3D"p2"><span class=3D"s1"><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">{</span></span></p><p clas=
s=3D"p3"><span class=3D"s1"><span style=3D"color: #008;" class=3D"styled-by=
-prettify">private</span></span><span class=3D"s3"><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">:</span></span></p><p class=3D"p2"><span =
class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify"> <br=
> </span></span><span class=3D"s2"><span style=3D"color: #008;"=
class=3D"styled-by-prettify">typedef</span></span><span class=3D"s1"><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><span c=
lass=3D"s4"><span style=3D"color: #000;" class=3D"styled-by-prettify">_trai=
ts_commons</span></span><span class=3D"s1"><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">></span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> _base_type</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span></span></p><p class=3D"p1"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span></p><p class=3D"p3"><span class=3D"s1"><=
span style=3D"color: #008;" class=3D"styled-by-prettify">public</span></spa=
n><span class=3D"s3"><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
br></span></span></p><p class=3D"p2"><span class=3D"s1"><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span></span><span cla=
ss=3D"s2"><span style=3D"color: #008;" class=3D"styled-by-prettify">typedef=
</span></span><span class=3D"s1"><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span></span><span class=3D"s2"><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">typename</span></span><span class=3D"s1"><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><sp=
an class=3D"s4"><span style=3D"color: #000;" class=3D"styled-by-prettify">_=
base_type</span></span><span class=3D"s1"><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">value_type value_type</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">;</span></span></p><p class=3D"p2"><span class=
=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify"> &=
nbsp;</span></span><span class=3D"s2"><span style=3D"color: #008;" class=3D=
"styled-by-prettify">typedef</span></span><span class=3D"s1"><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span></span><span class=3D"s=
2"><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span=
></span><span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span></span><span class=3D"s4"><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">_base_type</span></span><span class=3D"s1"><span=
style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">reference reference</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">;</span></span></p>=
<p class=3D"p2"><span class=3D"s1"><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span></span><span class=3D"s2"><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">typedef</span></span><span =
class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan></span><span class=3D"s2"><span style=3D"color: #008;" class=3D"styled-=
by-prettify">typename</span></span><span class=3D"s1"><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span></span><span class=3D"s4"><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">_base_type</span></sp=
an><span class=3D"s1"><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">poi=
nter pointer</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span></span></p><p class=3D"p2"><span class=3D"s1"><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span></span><span cl=
ass=3D"s2"><span style=3D"color: #008;" class=3D"styled-by-prettify">typede=
f</span></span><span class=3D"s1"><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span></span><span class=3D"s2"><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">typename</span></span><span class=3D"s1">=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><s=
pan class=3D"s4"><span style=3D"color: #000;" class=3D"styled-by-prettify">=
_base_type</span></span><span class=3D"s1"><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">const_reference const_reference</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">;</span></span></p><p class=3D"p2"><=
span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span></span><span class=3D"s2"><span style=3D"color: #008;=
" class=3D"styled-by-prettify">typedef</span></span><span class=3D"s1"><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><span =
class=3D"s2"><span style=3D"color: #008;" class=3D"styled-by-prettify">type=
name</span></span><span class=3D"s1"><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span></span><span class=3D"s4"><span style=3D"color:=
#000;" class=3D"styled-by-prettify">_base_type</span></span><span class=3D=
"s1"><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">const_pointer const_=
pointer</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</=
span></span></p><p class=3D"p2"><span class=3D"s1"><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span></span><span class=
=3D"s2"><span style=3D"color: #008;" class=3D"styled-by-prettify">typedef</=
span></span><span class=3D"s1"><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span></span><span class=3D"s2"><span style=3D"color: #008;=
" class=3D"styled-by-prettify">typename</span></span><span class=3D"s1"><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><span=
class=3D"s4"><span style=3D"color: #000;" class=3D"styled-by-prettify">_ba=
se_type</span></span><span class=3D"s1"><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">size_type size_type</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">;</span></span></p><p class=3D"p2"><span class=3D"=
s1"><span style=3D"color: #000;" class=3D"styled-by-prettify">  =
;</span></span><span class=3D"s2"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">typedef</span></span><span class=3D"s1"><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span></span><span class=3D"s2"><=
span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span></s=
pan><span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span></span><span class=3D"s4"><span style=3D"color: #000;" class=
=3D"styled-by-prettify">_base_type</span></span><span class=3D"s1"><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">difference_type difference_type</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span></sp=
an></p><p class=3D"p2"><span class=3D"s1"><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span></span><span class=3D"s2"><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">typedef</span></span=
><span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span></span><span class=3D"s2"><span style=3D"color: #008;" class=3D"=
styled-by-prettify">typename</span></span><span class=3D"s1"><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span></span><span class=3D"s=
4"><span style=3D"color: #000;" class=3D"styled-by-prettify">_base_type</sp=
an></span><span class=3D"s1"><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">return_type return_type</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br><br> </span><span style=3D"color: #800;" class=3D"s=
tyled-by-prettify">/* Enabled if std::is_class<T> (discussible). Noti=
ce that argument_type is now a reference */</span></span></p><p class=3D"p2=
"><span class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span></span><span class=3D"s2"><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">typedef</span></span><span class=3D"s1"><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><sp=
an class=3D"s4"><span style=3D"color: #000;" class=3D"styled-by-prettify">r=
eference</span></span><span class=3D"s1"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> argument_type</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br></span></span></p><p class=3D"p2"><span class=3D"s1"=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">typedef</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><font co=
lor=3D"#000088"><span style=3D"color: #008;" class=3D"styled-by-prettify">c=
onst</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> refer=
ence</span></font><font color=3D"#000088"><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> const_argument_type</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">;</span></font><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span></span></p><p class=3D"p2"><spa=
n class=3D"s1"><span style=3D"color: #000;" class=3D"styled-by-prettify">&n=
bsp; </span></span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">typedef</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">type=
name</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> _base=
_type</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">tag_type tag_=
type</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</spa=
n></p><p class=3D"p2"><span class=3D"s1"><span style=3D"color: #660;" class=
=3D"styled-by-prettify">};</span></span></p></div></code></div><br>This is =
obviously a simplification, but I believe it works to demonstrate my i=
ntents. Getting back to the previous examples, push_back would now be decla=
red like this:</div><div><br></div><div><div class=3D"prettyprint" style=3D=
"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-co=
lor: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subpret=
typrint"><pre style=3D"font-size: 12px; background-color: rgb(250, 255, 250=
);"><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> push_back </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> traits</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify"><</span><font color=3D"#0000=
00"><span style=3D"color: #000;" class=3D"styled-by-prettify">T</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">>::</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">const_argument_type val</s=
pan></font><span style=3D"color: #660;" class=3D"styled-by-prettify">);</sp=
an></pre></div></code></div><br>This would mean a pass-by-copy for non-clas=
s types and a const_reference for class types. By using this approach I bel=
ieve that argument passing can be cleaner and more efficient. Has this been=
proposed before? What do you think? I've been thinking about making a prop=
osal to the C++ committee and though of following their recommendation of p=
osting on the forums first :)</div><div><br></div><div>Thank you immensely =
in advance for your feedback,</div><div>Happy coding!</div><div><br></div><=
/div></div>
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br>
<br><!--end of _originalContent --></div></body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Wed, 10 Feb 2016 10:51:51 -0800
Raw View
On quarta-feira, 10 de fevereiro de 2016 11:10:34 PST Tony V E wrote:
> Not a bad idea.=20
>=20
> But I'd rather see some kind of language feature for param passing. A "pa=
ss
> by copy if cheap"=E2=80=8E syntax. Also a pass by copy-if-write (for case=
s where
> the function body I available to determine that).=20
>=20
> Vaguely speaking.
Agreed.
For my Qt6 QVector, I have:
typedef typename std::conditional<std::is_fundamental<T>::value ||=20
std::is_pointer<T>::value, T, const T &>::type parameter_type;
Which is "good enough", but could be better. It won't catch trivial types t=
hat=20
can be passed in registers, such as structs with size less than a register =
(or=20
two).
Maybe we want a type trait (name TBD) that is true for those types. The=20
standard should say that it is true at least for fundamental types and=20
pointers, the rest to be implementation-defined.
This also goes back to the discussion on relocatable types and the destruct=
ive=20
move.
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--=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 https://groups.google.com/a/isocpp.org/group/std-propos=
als/.
.
Author: =?UTF-8?Q?Andr=C3=A9?= <andre.francisco@tryhype.co>
Date: Wed, 10 Feb 2016 16:33:46 -0800 (PST)
Raw View
------=_Part_130_557186018.1455150826446
Content-Type: multipart/alternative;
boundary="----=_Part_131_987651911.1455150826453"
------=_Part_131_987651911.1455150826453
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
I tend to agree, this would be better if solved at a language level. But=20
isn't there the downside of breaking backwards compatibility? After your=20
feedback I started considering how this could be solved at that level and=
=20
my thoughts go maybe to a new operator. Something like this?
void push_back (const value_type &? val);
This seems quite intuitive (i.e. *is it passing by reference?*) even=20
though this doesn't:
void push_back (value_type &? val);
In this case *val* must always be passed by reference, so the operator kind=
=20
of loses its purpose. Either the operator would imply const or when not=20
const would be the same as passing by reference.
The first thing that comes to mind is how the compiler would parse this and=
=20
whether it would add parse conflicts, but I don't think this could be=20
confused with the ternary operator or something of the sort, although I=20
need to give it some more though first. As you guys know I'm new around=20
here and haven't been following the forum for long, so to what extend is=20
the addition of a new operator OK? Or were you guys referring to something=
=20
else?
Also, I've reconsidered my initial proposal, and if this were to be solved=
=20
at the framework level it could be solved with the first proposed solution=
=20
of a traits class or something less *bloaty*. Instead of a traits class=20
containing all those (most of them unnecessary) definitions, maybe=20
something like this:
void push_back (const typename argument<value_type>::type val);
This seems more intuitive and cleaner than the first approach, still=20
resolving the problem at the framework level. Regarding the issue of tag=20
dispatching it would be solved the same way, but being so much more trivial=
=20
I'm considering the rest first. Regarding exceptional cases such as the=20
ones you guys mentioned, this could always be specialized for them, as=20
could the traits option, specially given Thiago's suggestion for a boolean=
=20
alternative.
Regarding copy-if-write, although it does seem like a great idea, am I=20
wrong thinking that this can (and should?) be solved at a compiler level?=
=20
This can be done statically by each function marking their parameters as=20
either written or not and applying the flag recursively, and I don't see=20
the need for hints by the developer or language additions.
All things considered, I think the operator approach is definitely the=20
best, but using traits classes seems to be more backwards-friendly. What=20
are your thoughts on this?
Again, my appreciation for your feedback.
Best regards,
Andr=C3=A9.
quarta-feira, 10 de Fevereiro de 2016 =C3=A0s 18:51:55 UTC, Thiago Macieira=
=20
escreveu:
>
> On quarta-feira, 10 de fevereiro de 2016 11:10:34 PST Tony V E wrote:=20
> > Not a bad idea.=20
> >=20
> > But I'd rather see some kind of language feature for param passing. A=
=20
> "pass=20
> > by copy if cheap"=E2=80=8E syntax. Also a pass by copy-if-write (for ca=
ses where=20
> > the function body I available to determine that).=20
> >=20
> > Vaguely speaking.=20
>
> Agreed.=20
>
> For my Qt6 QVector, I have:=20
>
> typedef typename std::conditional<std::is_fundamental<T>::value ||=20
> std::is_pointer<T>::value, T, const T &>::type parameter_type;=20
>
> Which is "good enough", but could be better. It won't catch trivial types=
=20
> that=20
> can be passed in registers, such as structs with size less than a registe=
r=20
> (or=20
> two).=20
>
> Maybe we want a type trait (name TBD) that is true for those types. The=
=20
> standard should say that it is true at least for fundamental types and=20
> pointers, the rest to be implementation-defined.=20
>
> This also goes back to the discussion on relocatable types and the=20
> destructive=20
> move.=20
>
> --=20
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org=20
> Software Architect - Intel Open Source Technology Center=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 https://groups.google.com/a/isocpp.org/group/std-propos=
als/.
------=_Part_131_987651911.1455150826453
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I tend to agree, this would be better if solved at a langu=
age level. But isn't there the downside of breaking backwards compatibi=
lity? After your feedback I started considering how this could be solved at=
that level and my thoughts go maybe to a new operator. Something like this=
?<div><br></div><div><div class=3D"prettyprint" style=3D"border: 1px solid =
rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, =
250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><pre style=
=3D"color: rgb(0, 128, 0); font-size: 12px; background-color: rgb(250, 255,=
250);"><span style=3D"color: rgb(0, 0, 136);"><span style=3D"color: #008;"=
class=3D"styled-by-prettify">void</span></span><span style=3D"color: rgb(0=
, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify"> push_b=
ack </span></span><span style=3D"color: rgb(102, 102, 0);"><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span></span><span style=3D"col=
or: rgb(0, 0, 136);"><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">const</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> value_type </span></span><span =
style=3D"color: rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&?</span></span><span style=3D"color: rgb(0, 0, 0);">=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> val</span></span=
><span style=3D"color: rgb(102, 102, 0);"><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">);</span></span></pre></div></code></div><div><br>=
</div>This seems quite intuitive =C2=A0(i.e. <i>is it passing by reference?=
</i>) even though this doesn't:</div><div><br></div><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"><font color=3D"#660066"><span style=3D"color:=
#008;" class=3D"styled-by-prettify">void</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> push_back </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">value_type </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">&?</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> val</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">);</span></font></div></code></div><br>In this case <i>val</=
i> must always be passed by reference, so the operator kind of loses its pu=
rpose. Either the operator would imply const or when not const would be the=
same as passing by reference.</div><div><br></div><div>The first thing tha=
t comes to mind is how the compiler would parse this and whether it would a=
dd parse conflicts, but I don't think this could be confused with the t=
ernary operator or something of the sort, although I need to give it some m=
ore though first. As you guys know I'm new around here and haven't =
been following the forum for long, so to what extend is the addition of a n=
ew operator OK? Or were you guys referring to something else?</div><div><br=
></div><div>Also, I've reconsidered my initial proposal, and if this we=
re to be solved at the framework level it could be solved with the first pr=
oposed solution of a traits class or something less <i>bloaty</i>. Instead =
of a traits class containing all those (most of them unnecessary) definitio=
ns, maybe something like this:</div><div><br></div><div><div class=3D"prett=
yprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-wor=
d; background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div =
class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">void</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> push_back </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">const<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> argument</span><span =
style=3D"color: #080;" class=3D"styled-by-prettify"><</span><font color=
=3D"#000000"><span style=3D"color: #080;" class=3D"styled-by-prettify">valu=
e_type</span></font><span style=3D"color: #080;" class=3D"styled-by-prettif=
y">></span><span style=3D"color: #660;" class=3D"styled-by-prettify">::<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">type val</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span></di=
v></code></div><br>This seems more intuitive and cleaner than the first app=
roach, still resolving the problem at the framework level. Regarding the is=
sue of tag dispatching it would be solved the same way, but being so much m=
ore trivial I'm considering the rest first. Regarding exceptional cases=
such as the ones you guys mentioned, this could always be specialized for =
them, as could the traits option, specially given Thiago's suggestion f=
or a boolean alternative.</div><div><br></div><div>Regarding copy-if-write,=
although it does seem like a great idea, am I wrong thinking that this can=
(and should?) be solved at a compiler level? This can be done statically b=
y each function marking their parameters as either written or not and apply=
ing the flag recursively, and I don't see the need for hints by the dev=
eloper or language additions.</div><div><br></div><div>All things considere=
d, I think the operator approach is definitely the best, but using traits c=
lasses seems to be more backwards-friendly. What are your thoughts on this?=
</div><div><br></div><div>Again, my appreciation for your feedback.</div><d=
iv>Best regards,</div><div>Andr=C3=A9.</div><div><br>quarta-feira, 10 de Fe=
vereiro de 2016 =C3=A0s 18:51:55 UTC, Thiago Macieira escreveu:<blockquote =
class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1p=
x #ccc solid;padding-left: 1ex;">On quarta-feira, 10 de fevereiro de 2016 1=
1:10:34 PST Tony V E wrote:
<br>> Not a bad idea.=20
<br>>=20
<br>> But I'd rather see some kind of language feature for param pas=
sing. A "pass
<br>> by copy if cheap"=E2=80=8E syntax. Also a pass by copy-if-wri=
te (for cases where
<br>> the function body I available to determine that).=20
<br>>=20
<br>> Vaguely speaking.
<br>
<br>Agreed.
<br>
<br>For my Qt6 QVector, I have:
<br>
<br>=C2=A0 =C2=A0 typedef typename std::conditional<std::is_<wbr>fundame=
ntal<T>::value ||=20
<br>std::is_pointer<T>::value, T, const T &>::type parameter_t=
ype;
<br>
<br>Which is "good enough", but could be better. It won't cat=
ch trivial types that=20
<br>can be passed in registers, such as structs with size less than a regis=
ter (or=20
<br>two).
<br>
<br>Maybe we want a type trait (name TBD) that is true for those types. The=
=20
<br>standard should say that it is true at least for fundamental types and=
=20
<br>pointers, the rest to be implementation-defined.
<br>
<br>This also goes back to the discussion on relocatable types and the dest=
ructive=20
<br>move.
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.goo=
gle.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg\75AFQ=
jCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;" onclick=3D"this.href=3D&=
#39;http://www.google.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46snt=
z\0751\46usg\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;">maciei=
ra.info</a> - thiago (AT) <a href=3D"http://kde.org" target=3D"_blank" rel=
=3D"nofollow" onmousedown=3D"this.href=3D'http://www.google.com/url?q\7=
5http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJdo5_JYG1Dowztw=
AHAKs80XSA';return true;" onclick=3D"this.href=3D'http://www.google=
..com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJdo=
5_JYG1DowztwAHAKs80XSA';return true;">kde.org</a>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>
<br></blockquote></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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
------=_Part_131_987651911.1455150826453--
------=_Part_130_557186018.1455150826446--
.
Author: =?UTF-8?Q?Andr=C3=A9?= <andre.francisco@tryhype.co>
Date: Wed, 10 Feb 2016 16:51:18 -0800 (PST)
Raw View
------=_Part_170_660383307.1455151878858
Content-Type: multipart/alternative;
boundary="----=_Part_171_348079167.1455151878859"
------=_Part_171_348079167.1455151878859
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Then again, passing by const reference could also be optimized by the=20
compiler.
quinta-feira, 11 de Fevereiro de 2016 =C3=A0s 00:33:46 UTC, Andr=C3=A9 escr=
eveu:
>
> I tend to agree, this would be better if solved at a language level. But=
=20
> isn't there the downside of breaking backwards compatibility? After your=
=20
> feedback I started considering how this could be solved at that level and=
=20
> my thoughts go maybe to a new operator. Something like this?
>
> void push_back (const value_type &? val);
>
>
> This seems quite intuitive (i.e. *is it passing by reference?*) even=20
> though this doesn't:
>
> void push_back (value_type &? val);
>
> In this case *val* must always be passed by reference, so the operator=20
> kind of loses its purpose. Either the operator would imply const or when=
=20
> not const would be the same as passing by reference.
>
> The first thing that comes to mind is how the compiler would parse this=
=20
> and whether it would add parse conflicts, but I don't think this could be=
=20
> confused with the ternary operator or something of the sort, although I=
=20
> need to give it some more though first. As you guys know I'm new around=
=20
> here and haven't been following the forum for long, so to what extend is=
=20
> the addition of a new operator OK? Or were you guys referring to somethin=
g=20
> else?
>
> Also, I've reconsidered my initial proposal, and if this were to be solve=
d=20
> at the framework level it could be solved with the first proposed solutio=
n=20
> of a traits class or something less *bloaty*. Instead of a traits class=
=20
> containing all those (most of them unnecessary) definitions, maybe=20
> something like this:
>
> void push_back (const typename argument<value_type>::type val);
>
> This seems more intuitive and cleaner than the first approach, still=20
> resolving the problem at the framework level. Regarding the issue of tag=
=20
> dispatching it would be solved the same way, but being so much more trivi=
al=20
> I'm considering the rest first. Regarding exceptional cases such as the=
=20
> ones you guys mentioned, this could always be specialized for them, as=20
> could the traits option, specially given Thiago's suggestion for a boolea=
n=20
> alternative.
>
> Regarding copy-if-write, although it does seem like a great idea, am I=20
> wrong thinking that this can (and should?) be solved at a compiler level?=
=20
> This can be done statically by each function marking their parameters as=
=20
> either written or not and applying the flag recursively, and I don't see=
=20
> the need for hints by the developer or language additions.
>
> All things considered, I think the operator approach is definitely the=20
> best, but using traits classes seems to be more backwards-friendly. What=
=20
> are your thoughts on this?
>
> Again, my appreciation for your feedback.
> Best regards,
> Andr=C3=A9.
>
> quarta-feira, 10 de Fevereiro de 2016 =C3=A0s 18:51:55 UTC, Thiago Maciei=
ra=20
> escreveu:
>>
>> On quarta-feira, 10 de fevereiro de 2016 11:10:34 PST Tony V E wrote:=20
>> > Not a bad idea.=20
>> >=20
>> > But I'd rather see some kind of language feature for param passing. A=
=20
>> "pass=20
>> > by copy if cheap"=E2=80=8E syntax. Also a pass by copy-if-write (for c=
ases=20
>> where=20
>> > the function body I available to determine that).=20
>> >=20
>> > Vaguely speaking.=20
>>
>> Agreed.=20
>>
>> For my Qt6 QVector, I have:=20
>>
>> typedef typename std::conditional<std::is_fundamental<T>::value ||=
=20
>> std::is_pointer<T>::value, T, const T &>::type parameter_type;=20
>>
>> Which is "good enough", but could be better. It won't catch trivial type=
s=20
>> that=20
>> can be passed in registers, such as structs with size less than a=20
>> register (or=20
>> two).=20
>>
>> Maybe we want a type trait (name TBD) that is true for those types. The=
=20
>> standard should say that it is true at least for fundamental types and=
=20
>> pointers, the rest to be implementation-defined.=20
>>
>> This also goes back to the discussion on relocatable types and the=20
>> destructive=20
>> move.=20
>>
>> --=20
>> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org=20
>> Software Architect - Intel Open Source Technology Center=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 https://groups.google.com/a/isocpp.org/group/std-propos=
als/.
------=_Part_171_348079167.1455151878859
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Then again, passing by const reference could also be optim=
ized by the compiler.<br><br>quinta-feira, 11 de Fevereiro de 2016 =C3=A0s =
00:33:46 UTC, Andr=C3=A9 escreveu:<blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div dir=3D"ltr">I tend to agree, this would be better if solved at a=
language level. But isn't there the downside of breaking backwards com=
patibility? After your feedback I started considering how this could be sol=
ved at that level and my thoughts go maybe to a new operator. Something lik=
e this?<div><br></div><div><div style=3D"border:1px solid rgb(187,187,187);=
word-wrap:break-word;background-color:rgb(250,250,250)"><code><div><pre sty=
le=3D"color:rgb(0,128,0);font-size:12px;background-color:rgb(250,255,250)">=
<span style=3D"color:rgb(0,0,136)"><span style=3D"color:#008">void</span></=
span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> push_back=
</span></span><span style=3D"color:rgb(102,102,0)"><span style=3D"color:#6=
60">(</span></span><span style=3D"color:rgb(0,0,136)"><span style=3D"color:=
#008">const</span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"co=
lor:#000"> value_type </span></span><span style=3D"color:rgb(102,102,0)"><s=
pan style=3D"color:#660">&?</span></span><span style=3D"color:rgb(0,0,0=
)"><span style=3D"color:#000"> val</span></span><span style=3D"color:rgb(10=
2,102,0)"><span style=3D"color:#660">);</span></span></pre></div></code></d=
iv><div><br></div>This seems quite intuitive =C2=A0(i.e. <i>is it passing b=
y reference?</i>) even though this doesn't:</div><div><br></div><div><d=
iv style=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;backgrou=
nd-color:rgb(250,250,250)"><code><div><font color=3D"#660066"><span style=
=3D"color:#008">void</span><span style=3D"color:#000"> push_back </span><sp=
an style=3D"color:#660">(</span><span style=3D"color:#000">value_type </spa=
n><span style=3D"color:#660">&?</span><span style=3D"color:#000"> val</=
span><span style=3D"color:#660">);</span></font></div></code></div><br>In t=
his case <i>val</i> must always be passed by reference, so the operator kin=
d of loses its purpose. Either the operator would imply const or when not c=
onst would be the same as passing by reference.</div><div><br></div><div>Th=
e first thing that comes to mind is how the compiler would parse this and w=
hether it would add parse conflicts, but I don't think this could be co=
nfused with the ternary operator or something of the sort, although I need =
to give it some more though first. As you guys know I'm new around here=
and haven't been following the forum for long, so to what extend is th=
e addition of a new operator OK? Or were you guys referring to something el=
se?</div><div><br></div><div>Also, I've reconsidered my initial proposa=
l, and if this were to be solved at the framework level it could be solved =
with the first proposed solution of a traits class or something less <i>blo=
aty</i>. Instead of a traits class containing all those (most of them unnec=
essary) definitions, maybe something like this:</div><div><br></div><div><d=
iv style=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;backgrou=
nd-color:rgb(250,250,250)"><code><div><span style=3D"color:#008">void</span=
><span style=3D"color:#000"> push_back </span><span style=3D"color:#660">(<=
/span><span style=3D"color:#008">const</span><span style=3D"color:#000"> </=
span><span style=3D"color:#008">typename</span><span style=3D"color:#000"> =
argument</span><span style=3D"color:#080"><</span><font color=3D"#000000=
"><span style=3D"color:#080">value_type</span></font><span style=3D"color:#=
080">></span><span style=3D"color:#660">::</span><span style=3D"color:#0=
00">type val</span><span style=3D"color:#660">);</span></div></code></div><=
br>This seems more intuitive and cleaner than the first approach, still res=
olving the problem at the framework level. Regarding the issue of tag dispa=
tching it would be solved the same way, but being so much more trivial I=
9;m considering the rest first. Regarding exceptional cases such as the one=
s you guys mentioned, this could always be specialized for them, as could t=
he traits option, specially given Thiago's suggestion for a boolean alt=
ernative.</div><div><br></div><div>Regarding copy-if-write, although it doe=
s seem like a great idea, am I wrong thinking that this can (and should?) b=
e solved at a compiler level? This can be done statically by each function =
marking their parameters as either written or not and applying the flag rec=
ursively, and I don't see the need for hints by the developer or langua=
ge additions.</div><div><br></div><div>All things considered, I think the o=
perator approach is definitely the best, but using traits classes seems to =
be more backwards-friendly. What are your thoughts on this?</div><div><br><=
/div><div>Again, my appreciation for your feedback.</div><div>Best regards,=
</div><div>Andr=C3=A9.</div><div><br>quarta-feira, 10 de Fevereiro de 2016 =
=C3=A0s 18:51:55 UTC, Thiago Macieira escreveu:<blockquote class=3D"gmail_q=
uote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;paddin=
g-left:1ex">On quarta-feira, 10 de fevereiro de 2016 11:10:34 PST Tony V E =
wrote:
<br>> Not a bad idea.=20
<br>>=20
<br>> But I'd rather see some kind of language feature for param pas=
sing. A "pass
<br>> by copy if cheap"=E2=80=8E syntax. Also a pass by copy-if-wri=
te (for cases where
<br>> the function body I available to determine that).=20
<br>>=20
<br>> Vaguely speaking.
<br>
<br>Agreed.
<br>
<br>For my Qt6 QVector, I have:
<br>
<br>=C2=A0 =C2=A0 typedef typename std::conditional<std::is_<wbr>fundame=
ntal<T>::value ||=20
<br>std::is_pointer<T>::value, T, const T &>::type parameter_t=
ype;
<br>
<br>Which is "good enough", but could be better. It won't cat=
ch trivial types that=20
<br>can be passed in registers, such as structs with size less than a regis=
ter (or=20
<br>two).
<br>
<br>Maybe we want a type trait (name TBD) that is true for those types. The=
=20
<br>standard should say that it is true at least for fundamental types and=
=20
<br>pointers, the rest to be implementation-defined.
<br>
<br>This also goes back to the discussion on relocatable types and the dest=
ructive=20
<br>move.
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" rel=3D"n=
ofollow" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.googl=
e.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg\75AFQjC=
NEswDUBNCNanbu7euhqLn_62FW8ag';return true;" onclick=3D"this.href=3D=
9;http://www.google.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\=
0751\46usg\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;">macieira=
..info</a> - thiago (AT) <a href=3D"http://kde.org" rel=3D"nofollow" target=
=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75h=
ttp%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJdo5_JYG1DowztwAH=
AKs80XSA';return true;" onclick=3D"this.href=3D'http://www.google.c=
om/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJdo5_=
JYG1DowztwAHAKs80XSA';return true;">kde.org</a>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>
<br></blockquote></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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
------=_Part_171_348079167.1455151878859--
------=_Part_170_660383307.1455151878858--
.