Topic: [propagate_const] Implicit conversion to T
Author: joseph.thomson@gmail.com
Date: Thu, 20 Oct 2016 01:33:28 -0700 (PDT)
Raw View
------=_Part_294_275709584.1476952408421
Content-Type: multipart/alternative;
boundary="----=_Part_295_1844605049.1476952408422"
------=_Part_295_1844605049.1476952408422
Content-Type: text/plain; charset=UTF-8
The idea of the proposed propagate_const class template is growing on me,
but it has a few issues, one of which I wish to address here, and one of
which I will raise in another thread.
propagate_const is great for storing raw pointers; take the following
example code:
class container {
public:
int const* get_value() const { return value; }
int* get_value() { return value; }
private:
propagate_const<int*> value;
};
The use of propagate_const has effectively enforced const-correctness on
container: we cannot return value as an int* from the const overload of
get_value. However, if you replace int* with shared_ptr<int> then there is
a problem:
class container {
public:
shared_ptr<int const> get_value() const { return value; } // error:
cannot convert...
shared_ptr<int> get_value() { return value; } // error: cannot convert...
private:
propagate_const<shared_ptr<int*>> value;
};
This is because propagate_const<T> can only implicitly convert to element_type
const* and element_type*; propagate_const<T> *should* support implicit
conversion to T and whatever the const version of T is. Of course, it makes
sense for propagate_const<T> to *also* implicitly convert to element_type
const* and element_type* *if* T is implicitly convertible to element_type
const* and element_type* (which shared_ptr<T> isn't).
One complaint I can imagine is that enabling such a conversion breaks the
const-correctness enforced by propagate_const. This is not true; at least,
it is no more true to say that allowing implicit conversion from
propagate_const<shared_ptr<T>> to shared_ptr<T> breaks const-correctness
than it is to say that allowing implicit conversion from propagate_const<T*>
to T* breaks const-correctness. Bottom line is, propagate_const simply
ensures that container's implementation is const-correct; it's job isn't to
propagate constness outside of the API boundaries.
Another suggestion I anticipate is that this is what get_underlying is for.
But get_underlying *does* break const-correctness. Case in point, this
compiles:
class container {
public:
shared_ptr<int> get_value() const { return get_underlying(value); } //
const-correctness lost
shared_ptr<int> get_value() { return get_underlying(value); }
private:
propagate_const<shared_ptr<int>> value;
};
The current design of propagate_const renders it ineffective for use with
types such as shared_ptr<T>. I believe the solution is to add implicit
conversion operators to T& and the const version of T; for example:
operator T&();
operator const_version_t<T>(); // sample implementation
Note that the second conversion operator will only exist if
const_version_t<T> is not the same as T.
Determining the const version of T* is easy (it's T const*), but how should
it be determined for an arbitrary type? I suggest adding one more
requirement on T: the existence of a T::const_type member type alias. This
can easily be added to the standard library smart pointers (like weak_type
was just added to shared_ptr in C++17). Using a specializable type trait
struct seems like overkill to me, but it's another possibility.
Let me know you thoughts, and please tell me if I've missed something
obvious so that I can slink into the corner feeling very stupid.
--
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/1f43ffe8-b267-4c8c-8834-f3e60035f18d%40isocpp.org.
------=_Part_295_1844605049.1476952408422
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The idea of the proposed <span style=3D"font-family: couri=
er new,monospace;">propagate_const</span> class template is growing on me, =
but it has a few issues, one of which I wish to address here, and one of wh=
ich I will raise in another thread.<br><br><span style=3D"font-family: cour=
ier new,monospace;">propagate_const</span> is great for storing raw pointer=
s; take the following example code:<br><br><div style=3D"background-color: =
rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; =
border-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><code =
class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #=
008;" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> container </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"st=
yled-by-prettify">public</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">const</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> get_value</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">const</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=
">return</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> v=
alue</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">=C2=A0 </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"> get_value</span><span style=3D"color: #660;" class=3D"sty=
led-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><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> value</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify"><code class=3D"prettyprint"><span style=3D"color: #008;" =
class=3D"styled-by-prettify"><br>private</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>=C2=A0 propagate_const</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: #660;" class=
=3D"styled-by-prettify">*></span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> value</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: #008;" class=3D"styled-by-prettify">=
</span></code>};</span></div></code></div><br>The use of <span style=3D"fon=
t-family: courier new,monospace;">propagate_const</span> has effectively en=
forced const-correctness on <span style=3D"font-family: courier new,monospa=
ce;">container</span>: we cannot return <span style=3D"font-family: courier=
new,monospace;">value</span> as an <span style=3D"font-family: courier new=
,monospace;">int*</span> from the <span style=3D"font-family: courier new,m=
onospace;">const</span> overload of <span style=3D"font-family: courier new=
,monospace;">get_value</span>. However, if you replace <span style=3D"font-=
family: courier new,monospace;">int*</span> with <span style=3D"font-family=
: courier new,monospace;">shared_ptr<int></span> then there is a prob=
lem:<br><br><code class=3D"prettyprint"><div style=3D"background-color: rgb=
(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bor=
der-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><code cla=
ss=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008=
;" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> container </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;" class=3D"styled-=
by-prettify">public</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>=C2=A0 shared_ptr</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">int</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: #660;" class=3D"styled-by-prettify">></span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> get_value</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color: #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"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">return</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> value</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">// error: cannot convert...</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 shared_pt=
r</span><span style=3D"color: #080;" class=3D"styled-by-prettify"><int&g=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> get_val=
ue</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> value</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #800;" class=3D"styled-by-prettify">// error: ca=
nnot convert...</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">private</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 propagate_const</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify"><</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">shared_ptr</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y"><</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">*>><=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> value</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">};</span></div></code></div>=
<br></code>This is because <span style=3D"font-family: courier new,monospac=
e;">propagate_const<T></span> can only implicitly convert to <span st=
yle=3D"font-family: courier new,monospace;">element_type const*</span> and =
<span style=3D"font-family: courier new,monospace;">element_type*</span>; <=
span style=3D"font-family: courier new,monospace;">propagate_const<T>=
</span> <i>should</i> support implicit conversion to <span style=3D"font-fa=
mily: courier new,monospace;">T</span> and whatever the <span style=3D"font=
-family: courier new,monospace;">const</span> version of <span style=3D"fon=
t-family: courier new,monospace;">T</span> is. Of course, it makes sense fo=
r <span style=3D"font-family: courier new,monospace;">propagate_const<T&=
gt;</span> to <i>also</i> implicitly convert to <span style=3D"font-family:=
courier new,monospace;">element_type const*</span> and <span style=3D"font=
-family: courier new,monospace;">element_type*</span> <i>if</i> <span style=
=3D"font-family: courier new,monospace;">T</span> is implicitly convertible=
to <span style=3D"font-family: courier new,monospace;">element_type const*=
</span> and <span style=3D"font-family: courier new,monospace;">element_typ=
e*</span> (which <span style=3D"font-family: courier new,monospace;">share=
d_ptr<T></span> isn't).<br><br>One complaint I can imagine is tha=
t enabling such a conversion breaks the const-correctness enforced by <span=
style=3D"font-family: courier new,monospace;">propagate_const</span>. This=
is not true; at least, it is no more true to say that allowing implicit co=
nversion from <span style=3D"font-family: courier new,monospace;">propagate=
_const<shared_ptr<T>></span> to <span style=3D"font-family: cou=
rier new,monospace;">shared_ptr<T></span> breaks const-correctness th=
an it is to say that allowing implicit conversion from <span style=3D"font-=
family: courier new,monospace;">propagate_const<T*></span> to <span s=
tyle=3D"font-family: courier new,monospace;">T*</span> breaks const-correct=
ness. Bottom line is, <span style=3D"font-family: courier new,monospace;">p=
ropagate_const</span> simply ensures that container's implementation is=
const-correct; it's job isn't to propagate constness outside of th=
e API boundaries.<br><br>Another suggestion I anticipate is that this is wh=
at <span style=3D"font-family: courier new,monospace;">get_underlying</span=
> is for. But <span style=3D"font-family: courier new,monospace;">get_under=
lying</span> <i>does</i> break const-correctness. Case in point, this compi=
les:<br><br><div style=3D"background-color: rgb(250, 250, 250); border-colo=
r: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflow-wra=
p: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div clas=
s=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">class</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
container </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">public</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 shared_ptr</span>=
<span style=3D"color: #080;" class=3D"styled-by-prettify"><int></span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> get_value</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" c=
lass=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">return</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> get_underlying</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">value</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">// const-correctness lost</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 shared_ptr<=
/span><span style=3D"color: #080;" class=3D"styled-by-prettify"><int>=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> get_value=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> get_underlying</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">value</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br=
></span><span style=3D"color: #008;" class=3D"styled-by-prettify">private</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 propagate_=
const</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">shared_ptr<=
/span><span style=3D"color: #080;" class=3D"styled-by-prettify"><int>=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">></span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> value</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">};</span></div></code></div><br>Th=
e current design of <span style=3D"font-family: courier new,monospace;">pro=
pagate_const</span> renders it ineffective for use with types such as <span=
style=3D"font-family: courier new,monospace;">shared_ptr<T></span>. =
I believe the solution is to add implicit conversion operators to <span sty=
le=3D"font-family: courier new,monospace;">T&</span> and the const vers=
ion of <span style=3D"font-family: courier new,monospace;">T</span>; for ex=
ample:<br><br><div style=3D"background-color: rgb(250, 250, 250); border-co=
lor: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflow-w=
rap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div cl=
ass=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">operator</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"><br>=C2=
=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">operat=
or</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> const_v=
ersion_t</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&l=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T</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">// sample implementation</sp=
an></div></code></div><br>Note that the second conversion operator will onl=
y exist if <span style=3D"font-family: courier new,monospace;">const_versio=
n_t<T></span> is not the same as <span style=3D"font-family: courier =
new,monospace;">T</span>.<br><br>Determining the const version of <span sty=
le=3D"font-family: courier new,monospace;">T*</span> is easy (it's <spa=
n style=3D"font-family: courier new,monospace;">T const*</span>), but how s=
hould it be determined for an arbitrary type? I suggest adding one more req=
uirement on <span style=3D"font-family: courier new,monospace;">T</span>: t=
he existence of a <span style=3D"font-family: courier new,monospace;">T::co=
nst_type</span> member type alias. This can easily be added to the standard=
library smart pointers (like <span style=3D"font-family: courier new,monos=
pace;">weak_type</span> was just added to <span style=3D"font-family: couri=
er new,monospace;">shared_ptr</span> in C++17). Using a specializable type =
trait struct seems like overkill to me, but it's another possibility.<b=
r><br>Let me know you thoughts, and please tell me if I've missed somet=
hing obvious so that I can slink into the corner feeling very stupid.<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/1f43ffe8-b267-4c8c-8834-f3e60035f18d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1f43ffe8-b267-4c8c-8834-f3e60035f18d=
%40isocpp.org</a>.<br />
------=_Part_295_1844605049.1476952408422--
------=_Part_294_275709584.1476952408421--
.
Author: mihailnajdenov@gmail.com
Date: Thu, 20 Oct 2016 02:33:32 -0700 (PDT)
Raw View
------=_Part_79_1900813879.1476956012554
Content-Type: multipart/alternative;
boundary="----=_Part_80_646981326.1476956012554"
------=_Part_80_646981326.1476956012554
Content-Type: text/plain; charset=UTF-8
On Thursday, October 20, 2016 at 11:33:28 AM UTC+3, joseph....@gmail.com
wrote:
>
> ...
> Another suggestion I anticipate is that this is what get_underlying is
> for. But get_underlying *does* break const-correctness. Case in point,
> this compiles:
>
> class container {
> public:
> shared_ptr<int> get_value() const { return get_underlying(value); } //
> const-correctness lost
> shared_ptr<int> get_value() { return get_underlying(value); }
>
> private:
> propagate_const<shared_ptr<int>> value;
> };
>
>
This is however correct:
class container {
public:
shared_ptr<const int> get_value() const { return get_underlying(value); } //
const-correctness RESTORED
shared_ptr<int> get_value() { return get_underlying(value); }
private:
propagate_const<shared_ptr<int>> value;
};
If you get_value on a const container; it will return to you the
const-correct internal pointer.
And I think the key here is internal.
I think the main purpose of propagate is to be an implementation helper
an you are letting the pointer escape.
If you are letting the pointer escape you can also do
propagate_const<std::shared_ptr<X>> get_value() const { return
get_underlying(m_ptrX); }
This way it is up to caller to decide if the return value is const or not,
enabling this usage.
const auto p = c.get_value();
p->func(); //< calls a void func() const overload
--
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/7f61be69-4f4c-40a5-9199-805edc90b428%40isocpp.org.
------=_Part_80_646981326.1476956012554
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Thursday, October 20, 2016 at 11:33:28 AM UTC+3=
, joseph....@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"mar=
gin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><=
div dir=3D"ltr">...<br>Another suggestion I anticipate is that this is what=
<span style=3D"font-family:courier new,monospace">get_underlying</span> is=
for. But <span style=3D"font-family:courier new,monospace">get_underlying<=
/span> <i>does</i> break const-correctness. Case in point, this compiles:<b=
r><br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,=
187,187);border-style:solid;border-width:1px"><code><div><span style=3D"col=
or:#008">class</span><span style=3D"color:#000"> container </span><span sty=
le=3D"color:#660">{</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">public</span><span style=3D"color:#660">:</span><span style=
=3D"color:#000"><br>=C2=A0 shared_ptr</span><span style=3D"color:#080"><=
int></span><span style=3D"color:#000"> get_value</span><span style=3D"co=
lor:#660">()</span><span style=3D"color:#000"> </span><span style=3D"color:=
#008">const</span><span style=3D"color:#000"> </span><span style=3D"color:#=
660">{</span><span style=3D"color:#000"> </span><span style=3D"color:#008">=
return</span><span style=3D"color:#000"> get_underlying</span><span style=
=3D"color:#660">(</span><span style=3D"color:#000">value</span><span style=
=3D"color:#660">);</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">}</span><span style=3D"color:#000"> </span><span style=3D"color=
:#800">// const-correctness lost</span><span style=3D"color:#000"><br>=C2=
=A0 shared_ptr</span><span style=3D"color:#080"><int></span><span sty=
le=3D"color:#000"> get_value</span><span style=3D"color:#660">()</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#660">{</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">return</span><span sty=
le=3D"color:#000"> get_underlying</span><span style=3D"color:#660">(</span>=
<span style=3D"color:#000">value</span><span style=3D"color:#660">);</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#660">}</span><span=
style=3D"color:#000"><br><br></span><span style=3D"color:#008">private</sp=
an><span style=3D"color:#660">:</span><span style=3D"color:#000"><br>=C2=A0=
propagate_const</span><span style=3D"color:#660"><</span><span style=3D=
"color:#000">shared_ptr</span><span style=3D"color:#080"><<wbr>int></=
span><span style=3D"color:#660">></span><span style=3D"color:#000"> valu=
e</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#660">};</span></div></code></div><br></div></bl=
ockquote><div><br></div><div>This is however correct:</div><div>=C2=A0</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"><=
span class=3D"styled-by-prettify" style=3D"color: #008;">class</span></span=
><span style=3D"color:#000"><span class=3D"styled-by-prettify" style=3D"col=
or: #000;"> container </span></span><span style=3D"color:#660"><span class=
=3D"styled-by-prettify" style=3D"color: #660;">{</span></span><span style=
=3D"color:#000"><span class=3D"styled-by-prettify" style=3D"color: #000;"><=
br></span></span><span style=3D"color:#008"><span class=3D"styled-by-pretti=
fy" style=3D"color: #008;">public</span></span><span style=3D"color:#660"><=
span class=3D"styled-by-prettify" style=3D"color: #660;">:</span></span><sp=
an style=3D"color:#000"><span class=3D"styled-by-prettify" style=3D"color: =
#000;"><br>=C2=A0 shared_ptr</span></span><span style=3D"color:#080"><span =
class=3D"styled-by-prettify" style=3D"color: #660;"><</span><span class=
=3D"styled-by-prettify" style=3D"color: #008;">const</span><span class=3D"s=
tyled-by-prettify" style=3D"color: #000;"> </span><span class=3D"styled-by-=
prettify" style=3D"color: #008;">int</span><span class=3D"styled-by-prettif=
y" style=3D"color: #660;">></span></span><span style=3D"color:#000"><spa=
n class=3D"styled-by-prettify" style=3D"color: #000;"> get_value</span></sp=
an><span style=3D"color:#660"><span class=3D"styled-by-prettify" style=3D"c=
olor: #660;">()</span></span><span style=3D"color:#000"><span class=3D"styl=
ed-by-prettify" style=3D"color: #000;"> </span></span><span style=3D"color:=
#008"><span class=3D"styled-by-prettify" style=3D"color: #008;">const</span=
></span><span style=3D"color:#000"><span class=3D"styled-by-prettify" style=
=3D"color: #000;"> </span></span><span style=3D"color:#660"><span class=3D"=
styled-by-prettify" style=3D"color: #660;">{</span></span><span style=3D"co=
lor:#000"><span class=3D"styled-by-prettify" style=3D"color: #000;"> </span=
></span><span style=3D"color:#008"><span class=3D"styled-by-prettify" style=
=3D"color: #008;">return</span></span><span style=3D"color:#000"><span clas=
s=3D"styled-by-prettify" style=3D"color: #000;"> get_underlying</span></spa=
n><span style=3D"color:#660"><span class=3D"styled-by-prettify" style=3D"co=
lor: #660;">(</span></span><span style=3D"color:#000"><span class=3D"styled=
-by-prettify" style=3D"color: #000;">value</span></span><span style=3D"colo=
r:#660"><span class=3D"styled-by-prettify" style=3D"color: #660;">);</span>=
</span><span style=3D"color:#000"><span class=3D"styled-by-prettify" style=
=3D"color: #000;"> </span></span><span style=3D"color:#660"><span class=3D"=
styled-by-prettify" style=3D"color: #660;">}</span></span><span style=3D"co=
lor:#000"><span class=3D"styled-by-prettify" style=3D"color: #000;"> </span=
></span><span style=3D"color:#800"><span class=3D"styled-by-prettify" style=
=3D"color: #800;">// const-correctness RESTORED</span></span><span style=3D=
"color:#000"><span class=3D"styled-by-prettify" style=3D"color: #000;"><br>=
=C2=A0 shared_ptr</span></span><span style=3D"color:#080"><span class=3D"st=
yled-by-prettify" style=3D"color: #080;"><int></span></span><span sty=
le=3D"color:#000"><span class=3D"styled-by-prettify" style=3D"color: #000;"=
> get_value</span></span><span style=3D"color:#660"><span class=3D"styled-b=
y-prettify" style=3D"color: #660;">()</span></span><span style=3D"color:#00=
0"><span class=3D"styled-by-prettify" style=3D"color: #000;"> </span></span=
><span style=3D"color:#660"><span class=3D"styled-by-prettify" style=3D"col=
or: #660;">{</span></span><span style=3D"color:#000"><span class=3D"styled-=
by-prettify" style=3D"color: #000;"> </span></span><span style=3D"color:#00=
8"><span class=3D"styled-by-prettify" style=3D"color: #008;">return</span><=
/span><span style=3D"color:#000"><span class=3D"styled-by-prettify" style=
=3D"color: #000;"> get_underlying</span></span><span style=3D"color:#660"><=
span class=3D"styled-by-prettify" style=3D"color: #660;">(</span></span><sp=
an style=3D"color:#000"><span class=3D"styled-by-prettify" style=3D"color: =
#000;">value</span></span><span style=3D"color:#660"><span class=3D"styled-=
by-prettify" style=3D"color: #660;">);</span></span><span style=3D"color:#0=
00"><span class=3D"styled-by-prettify" style=3D"color: #000;"> </span></spa=
n><span style=3D"color:#660"><span class=3D"styled-by-prettify" style=3D"co=
lor: #660;">}</span></span><span style=3D"color:#000"><span class=3D"styled=
-by-prettify" style=3D"color: #000;"><br><br></span></span><span style=3D"c=
olor:#008"><span class=3D"styled-by-prettify" style=3D"color: #008;">privat=
e</span></span><span style=3D"color:#660"><span class=3D"styled-by-prettify=
" style=3D"color: #660;">:</span></span><span style=3D"color:#000"><span cl=
ass=3D"styled-by-prettify" style=3D"color: #000;"><br>=C2=A0 propagate_cons=
t</span></span><span style=3D"color:#660"><span class=3D"styled-by-prettify=
" style=3D"color: #660;"><</span></span><span style=3D"color:#000"><span=
class=3D"styled-by-prettify" style=3D"color: #000;">shared_ptr</span></spa=
n><span style=3D"color:#080"><span class=3D"styled-by-prettify" style=3D"co=
lor: #080;"><</span><wbr><span class=3D"styled-by-prettify" style=3D"col=
or: #080;">int></span></span><span style=3D"color:#660"><span class=3D"s=
tyled-by-prettify" style=3D"color: #660;">></span></span><span style=3D"=
color:#000"><span class=3D"styled-by-prettify" style=3D"color: #000;"> valu=
e</span></span><span style=3D"color:#660"><span class=3D"styled-by-prettify=
" style=3D"color: #660;">;</span></span><span style=3D"color:#000"><span cl=
ass=3D"styled-by-prettify" style=3D"color: #000;"><br></span></span><span s=
tyle=3D"color:#660"><span class=3D"styled-by-prettify" style=3D"color: #660=
;">};</span></span></div></code></div><div><br></div><div>If you get_value =
on a const container; it will return to you =C2=A0the const-correct interna=
l pointer.</div><div><br></div><div>And I think the key here=C2=A0is intern=
al. </div><div>I think the main purpose of propagate is to be an implementa=
tion helper an=C2=A0you are=C2=A0letting the pointer escape.</div><div><br>=
</div><div>If you are letting the pointer escape you can also=C2=A0do </div=
><div><br></div><div><div class=3D"prettyprint" style=3D"border: 1px solid =
rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, =
250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span clas=
s=3D"styled-by-prettify" style=3D"color: #000;">propagate_const</span><span=
class=3D"styled-by-prettify" style=3D"color: #660;"><</span><span class=
=3D"styled-by-prettify" style=3D"color: #000;">std</span><span class=3D"sty=
led-by-prettify" style=3D"color: #660;">::</span><span class=3D"styled-by-p=
rettify" style=3D"color: #000;">shared_ptr</span><span class=3D"styled-by-p=
rettify" style=3D"color: #660;"><</span><span class=3D"styled-by-prettif=
y" style=3D"color: #000;">X</span><span class=3D"styled-by-prettify" style=
=3D"color: #660;">>></span><span class=3D"styled-by-prettify" style=
=3D"color: #000;"> get_value</span><span class=3D"styled-by-prettify" style=
=3D"color: #660;">()</span><span class=3D"styled-by-prettify" style=3D"colo=
r: #000;"> </span><span class=3D"styled-by-prettify" style=3D"color: #008;"=
>const</span><span class=3D"styled-by-prettify" style=3D"color: #000;"> </s=
pan><span class=3D"styled-by-prettify" style=3D"color: #660;">{</span><span=
class=3D"styled-by-prettify" style=3D"color: #000;"> </span><span class=3D=
"styled-by-prettify" style=3D"color: #008;">return</span><span class=3D"sty=
led-by-prettify" style=3D"color: #000;"> get_underlying</span><span class=
=3D"styled-by-prettify" style=3D"color: #660;">(</span><span class=3D"style=
d-by-prettify" style=3D"color: #000;">m_ptrX</span><span class=3D"styled-by=
-prettify" style=3D"color: #660;">);</span><span class=3D"styled-by-prettif=
y" style=3D"color: #000;"> </span><span class=3D"styled-by-prettify" style=
=3D"color: #660;">}</span><span class=3D"styled-by-prettify" style=3D"color=
: #000;"> </span></div></code></div>=C2=A0</div><div>This way it is up to c=
aller to decide if the return value is const or not, enabling this usage.</=
div><div><br></div><div><div class=3D"prettyprint" style=3D"border: 1px sol=
id rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 25=
0, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><font c=
olor=3D"rgb(34,34,34)" face=3D"Arial" style=3D"background-color: transparen=
t;"><span class=3D"styled-by-prettify" style=3D"color: #008;">const</span><=
span class=3D"styled-by-prettify" style=3D"color: #000;"> </span><span clas=
s=3D"styled-by-prettify" style=3D"color: #008;">auto</span><span class=3D"s=
tyled-by-prettify" style=3D"color: #000;"> p </span><span class=3D"styled-b=
y-prettify" style=3D"color: #660;">=3D</span><span class=3D"styled-by-prett=
ify" style=3D"color: #000;"> c</span><span class=3D"styled-by-prettify" sty=
le=3D"color: #660;">.</span><span class=3D"styled-by-prettify" style=3D"col=
or: #000;">get_value</span><span class=3D"styled-by-prettify" style=3D"colo=
r: #660;">();</span><span class=3D"styled-by-prettify" style=3D"color: #000=
;"> <br>p</span><span class=3D"styled-by-prettify" style=3D"color: #660;">-=
></span><span class=3D"styled-by-prettify" style=3D"color: #000;">func</=
span><span class=3D"styled-by-prettify" style=3D"color: #660;">();</span><s=
pan class=3D"styled-by-prettify" style=3D"color: #000;"> </span><span class=
=3D"styled-by-prettify" style=3D"color: #800;">//< calls a void func() c=
onst overload</span><span class=3D"styled-by-prettify" style=3D"color: #000=
;"><br></span></font></div></code></div><br></div><div><br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/7f61be69-4f4c-40a5-9199-805edc90b428%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/7f61be69-4f4c-40a5-9199-805edc90b428=
%40isocpp.org</a>.<br />
------=_Part_80_646981326.1476956012554--
------=_Part_79_1900813879.1476956012554--
.
Author: joseph.thomson@gmail.com
Date: Thu, 20 Oct 2016 08:29:03 -0700 (PDT)
Raw View
------=_Part_505_1012659337.1476977343849
Content-Type: multipart/alternative;
boundary="----=_Part_506_1131163073.1476977343850"
------=_Part_506_1131163073.1476977343850
Content-Type: text/plain; charset=UTF-8
On Thursday, 20 October 2016 17:33:32 UTC+8, mihailn...@gmail.com wrote:
>
>
>
> On Thursday, October 20, 2016 at 11:33:28 AM UTC+3, joseph....@gmail.com
> wrote:
>>
>> ...
>> Another suggestion I anticipate is that this is what get_underlying is
>> for. But get_underlying *does* break const-correctness. Case in point,
>> this compiles:
>>
>> class container {
>> public:
>> shared_ptr<int> get_value() const { return get_underlying(value); } //
>> const-correctness lost
>> shared_ptr<int> get_value() { return get_underlying(value); }
>>
>> private:
>> propagate_const<shared_ptr<int>> value;
>> };
>>
>>
> This is however correct:
>
> class container {
> public:
> shared_ptr<const int> get_value() const { return get_underlying(value);
> } // const-correctness RESTORED
> shared_ptr<int> get_value() { return get_underlying(value); }
>
> private:
> propagate_const<shared_ptr<int>> value;
> };
>
> If you get_value on a const container; it will return to you the
> const-correct internal pointer.
>
My point is that you *can* write code that violates the restrictions that
are meant to be enforced by propagate_const. For example, this code will
*not* compile:
class container {
public:
int* get_value() const { return value; } // error: cannot convert...
int* get_value() { return value; }
private:
propagate_const<int*> value;
};
But this code will:
class container {
public:
int* get_value() const { return get_underlying(value); }
int* get_value() { return value; }
private:
propagate_const<int*> value;
};
get_underlying is essentially const_cast for propagate_const; you should
not be using it on a regular basis, but there is currently no other option
when using propagate_const with shared_ptr (which makes this combination
practically useless), hence my suggested adjustments.
And I think the key here is internal.
> I think the main purpose of propagate is to be an implementation helper
> an you are letting the pointer escape.
>
> If you are letting the pointer escape you can also do
>
> propagate_const<std::shared_ptr<X>> get_value() const { return
> get_underlying(m_ptrX); }
>
> This way it is up to caller to decide if the return value is const or not,
> enabling this usage.
>
> const auto p = c.get_value();
> p->func(); //< calls a void func() const overload
>
>
This is certainly not a usage pattern I envisaged with propagate_const. Use
of get_underlying defeats the point of using propagate_const in the first
place, and use of propagate_const in the API seems wrong; as you said, it
is intended as an implementation helper.
--
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/13a71b20-8fd3-4a29-9279-716a2c9082a6%40isocpp.org.
------=_Part_506_1131163073.1476977343850
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, 20 October 2016 17:33:32 UTC+8, mihailn...@gm=
ail.com 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=
"><br><br>On Thursday, October 20, 2016 at 11:33:28 AM UTC+3, <a>joseph....=
@gmail.com</a> wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;ma=
rgin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"lt=
r">...<br>Another suggestion I anticipate is that this is what <span style=
=3D"font-family:courier new,monospace">get_underlying</span> is for. But <s=
pan style=3D"font-family:courier new,monospace">get_underlying</span> <i>do=
es</i> break const-correctness. Case in point, this compiles:<br><br><div s=
tyle=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);bor=
der-style:solid;border-width:1px"><code><div><span style=3D"color:#008">cla=
ss</span><span style=3D"color:#000"> container </span><span style=3D"color:=
#660">{</span><span style=3D"color:#000"><br></span><span style=3D"color:#0=
08">public</span><span style=3D"color:#660">:</span><span style=3D"color:#0=
00"><br>=C2=A0 shared_ptr</span><span style=3D"color:#080"><int></spa=
n><span style=3D"color:#000"> get_value</span><span style=3D"color:#660">()=
</span><span style=3D"color:#000"> </span><span style=3D"color:#008">const<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#660">{</span=
><span style=3D"color:#000"> </span><span style=3D"color:#008">return</span=
><span style=3D"color:#000"> get_underlying</span><span style=3D"color:#660=
">(</span><span style=3D"color:#000">value</span><span style=3D"color:#660"=
>);</span><span style=3D"color:#000"> </span><span style=3D"color:#660">}</=
span><span style=3D"color:#000"> </span><span style=3D"color:#800">// const=
-correctness lost</span><span style=3D"color:#000"><br>=C2=A0 shared_ptr</s=
pan><span style=3D"color:#080"><int></span><span style=3D"color:#000"=
> get_value</span><span style=3D"color:#660">()</span><span style=3D"color:=
#000"> </span><span style=3D"color:#660">{</span><span style=3D"color:#000"=
> </span><span style=3D"color:#008">return</span><span style=3D"color:#000"=
> get_underlying</span><span style=3D"color:#660">(</span><span style=3D"co=
lor:#000">value</span><span style=3D"color:#660">);</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#660">}</span><span style=3D"color:#=
000"><br><br></span><span style=3D"color:#008">private</span><span style=3D=
"color:#660">:</span><span style=3D"color:#000"><br>=C2=A0 propagate_const<=
/span><span style=3D"color:#660"><</span><span style=3D"color:#000">shar=
ed_ptr</span><span style=3D"color:#080"><<wbr>int></span><span style=
=3D"color:#660">></span><span style=3D"color:#000"> value</span><span st=
yle=3D"color:#660">;</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#660">};</span></div></code></div><br></div></blockquote><div><b=
r></div><div>This is however correct:</div><div>=C2=A0</div><div style=3D"b=
order:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(=
250,250,250)"><code><div><span style=3D"color:#008"><span style=3D"color:#0=
08">class</span></span><span style=3D"color:#000"><span style=3D"color:#000=
"> container </span></span><span style=3D"color:#660"><span style=3D"color:=
#660">{</span></span><span style=3D"color:#000"><span style=3D"color:#000">=
<br></span></span><span style=3D"color:#008"><span style=3D"color:#008">pub=
lic</span></span><span style=3D"color:#660"><span style=3D"color:#660">:</s=
pan></span><span style=3D"color:#000"><span style=3D"color:#000"><br>=C2=A0=
shared_ptr</span></span><span style=3D"color:#080"><span style=3D"color:#6=
60"><</span><span style=3D"color:#008">const</span><span style=3D"color:=
#000"> </span><span style=3D"color:#008">int</span><span style=3D"color:#66=
0">></span></span><span style=3D"color:#000"><span style=3D"color:#000">=
get_value</span></span><span style=3D"color:#660"><span style=3D"color:#66=
0">()</span></span><span style=3D"color:#000"><span style=3D"color:#000"> <=
/span></span><span style=3D"color:#008"><span style=3D"color:#008">const</s=
pan></span><span style=3D"color:#000"><span style=3D"color:#000"> </span></=
span><span style=3D"color:#660"><span style=3D"color:#660">{</span></span><=
span style=3D"color:#000"><span style=3D"color:#000"> </span></span><span s=
tyle=3D"color:#008"><span style=3D"color:#008">return</span></span><span st=
yle=3D"color:#000"><span style=3D"color:#000"> get_underlying</span></span>=
<span style=3D"color:#660"><span style=3D"color:#660">(</span></span><span =
style=3D"color:#000"><span style=3D"color:#000">value</span></span><span st=
yle=3D"color:#660"><span style=3D"color:#660">);</span></span><span style=
=3D"color:#000"><span style=3D"color:#000"> </span></span><span style=3D"co=
lor:#660"><span style=3D"color:#660">}</span></span><span style=3D"color:#0=
00"><span style=3D"color:#000"> </span></span><span style=3D"color:#800"><s=
pan style=3D"color:#800">// const-correctness RESTORED</span></span><span s=
tyle=3D"color:#000"><span style=3D"color:#000"><br>=C2=A0 shared_ptr</span>=
</span><span style=3D"color:#080"><span style=3D"color:#080"><int></s=
pan></span><span style=3D"color:#000"><span style=3D"color:#000"> get_value=
</span></span><span style=3D"color:#660"><span style=3D"color:#660">()</spa=
n></span><span style=3D"color:#000"><span style=3D"color:#000"> </span></sp=
an><span style=3D"color:#660"><span style=3D"color:#660">{</span></span><sp=
an style=3D"color:#000"><span style=3D"color:#000"> </span></span><span sty=
le=3D"color:#008"><span style=3D"color:#008">return</span></span><span styl=
e=3D"color:#000"><span style=3D"color:#000"> get_underlying</span></span><s=
pan style=3D"color:#660"><span style=3D"color:#660">(</span></span><span st=
yle=3D"color:#000"><span style=3D"color:#000">value</span></span><span styl=
e=3D"color:#660"><span style=3D"color:#660">);</span></span><span style=3D"=
color:#000"><span style=3D"color:#000"> </span></span><span style=3D"color:=
#660"><span style=3D"color:#660">}</span></span><span style=3D"color:#000">=
<span style=3D"color:#000"><br><br></span></span><span style=3D"color:#008"=
><span style=3D"color:#008">private</span></span><span style=3D"color:#660"=
><span style=3D"color:#660">:</span></span><span style=3D"color:#000"><span=
style=3D"color:#000"><br>=C2=A0 propagate_const</span></span><span style=
=3D"color:#660"><span style=3D"color:#660"><</span></span><span style=3D=
"color:#000"><span style=3D"color:#000">shared_ptr</span></span><span style=
=3D"color:#080"><span style=3D"color:#080"><</span><span style=3D"color:=
#080">int<wbr>></span></span><span style=3D"color:#660"><span style=3D"c=
olor:#660">></span></span><span style=3D"color:#000"><span style=3D"colo=
r:#000"> value</span></span><span style=3D"color:#660"><span style=3D"color=
:#660">;</span></span><span style=3D"color:#000"><span style=3D"color:#000"=
><br></span></span><span style=3D"color:#660"><span style=3D"color:#660">};=
</span></span></div></code></div><div><br></div><div>If you get_value on a =
const container; it will return to you =C2=A0the const-correct internal poi=
nter.</div></div></blockquote><div>=C2=A0<br>My point is that you <i>can</i=
> write code that violates the restrictions that are meant to be enforced b=
y <span style=3D"font-family: courier new,monospace;">propagate_const</span=
>. For example, this code will <i>not</i> compile:<br><br><div style=3D"bac=
kground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border=
-style: solid; border-width: 1px; overflow-wrap: break-word;" class=3D"pret=
typrint"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">class</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> container </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">public</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">int</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> get_value</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">()</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"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> value</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #800;" class=3D"styled-by-prettify">// error: ca=
nnot convert...</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">int</span><span style=3D"color: #660;" class=3D"styled-by-prettify">*=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> get_value=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> value</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">priva=
te</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 propag=
ate_const</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">*></span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> value</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">};</span></div></code></div><br>But th=
is code will:<br><br><div style=3D"background-color: rgb(250, 250, 250); bo=
rder-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; ove=
rflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint">=
<div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-=
by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> container </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: #008;" class=3D"styled-by-prettify">public=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> get_value</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">const</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">return</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> get_underly=
ing</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 style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">int</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> get_value</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> value</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">private</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>=C2=A0 propagate_const</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">int</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">*></span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> value</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><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></co=
de></div><br><span style=3D"font-family: courier new,monospace;">get_underl=
ying</span> is essentially <span style=3D"font-family: courier new,monospac=
e;">const_cast</span> for <span style=3D"font-family: courier new,monospace=
;">propagate_const</span>; you should not be using it on a regular basis, b=
ut there is currently no other option when using <span style=3D"font-family=
: courier new,monospace;">propagate_const</span> with <span style=3D"font-f=
amily: courier new,monospace;">shared_ptr</span> (which makes this combinat=
ion practically useless), hence my suggested adjustments.<br><br></div><blo=
ckquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-=
left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div></div><div>A=
nd I think the key here=C2=A0is internal. </div><div>I think the main purpo=
se of propagate is to be an implementation helper an=C2=A0you are=C2=A0lett=
ing the pointer escape.</div><div><br></div><div>If you are letting the poi=
nter escape you can also=C2=A0do </div><div><br></div><div><div style=3D"bo=
rder:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(2=
50,250,250)"><code><div><span style=3D"color:#000">propagate_const</span><s=
pan style=3D"color:#660"><</span><span style=3D"color:#000">std</span><s=
pan style=3D"color:#660">::</span><span style=3D"color:#000">shared_<wbr>pt=
r</span><span style=3D"color:#660"><</span><span style=3D"color:#000">X<=
/span><span style=3D"color:#660">>></span><span style=3D"color:#000">=
get_value</span><span style=3D"color:#660">()</span><span style=3D"color:#=
000"> </span><span style=3D"color:#008">const</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#660">{</span><span style=3D"color:#000"> =
</span><span style=3D"color:#008">return</span><span style=3D"color:#000"> =
get_underlying</span><span style=3D"color:#660">(</span><span style=3D"colo=
r:#000">m_ptrX</span><span style=3D"color:#660">);</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#660">}</span><span style=3D"color:#0=
00"> </span></div></code></div>=C2=A0</div><div>This way it is up to caller=
to decide if the return value is const or not, enabling this usage.</div><=
div><br></div><div><div style=3D"border:1px solid rgb(187,187,187);word-wra=
p:break-word;background-color:rgb(250,250,250)"><code><div><font style=3D"b=
ackground-color:transparent" color=3D"rgb(34,34,34)" face=3D"Arial"><span s=
tyle=3D"color:#008">const</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#008">auto</span><span style=3D"color:#000"> p </span><span st=
yle=3D"color:#660">=3D</span><span style=3D"color:#000"> c</span><span styl=
e=3D"color:#660">.</span><span style=3D"color:#000">get_value</span><span s=
tyle=3D"color:#660">();</span><span style=3D"color:#000"> <br>p</span><span=
style=3D"color:#660">-></span><span style=3D"color:#000">func</span><sp=
an style=3D"color:#660">();</span><span style=3D"color:#000"> </span><span =
style=3D"color:#800">//< calls a void func() const overload</span><span =
style=3D"color:#000"><br></span></font></div></code></div><br></div></div><=
/blockquote><div>=C2=A0<br>This is certainly not a usage pattern I envisage=
d with <span style=3D"font-family: courier new,monospace;">propagate_const<=
/span>. Use of <span style=3D"font-family: courier new,monospace;">get_unde=
rlying</span> defeats the point of using <span style=3D"font-family: courie=
r new,monospace;">propagate_const</span> in the first place, and use of <sp=
an style=3D"font-family: courier new,monospace;">propagate_const</span> in =
the API seems wrong; as you said, it is intended as an implementation helpe=
r.<br></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/13a71b20-8fd3-4a29-9279-716a2c9082a6%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/13a71b20-8fd3-4a29-9279-716a2c9082a6=
%40isocpp.org</a>.<br />
------=_Part_506_1131163073.1476977343850--
------=_Part_505_1012659337.1476977343849--
.
Author: mihailnajdenov@gmail.com
Date: Thu, 20 Oct 2016 09:40:12 -0700 (PDT)
Raw View
------=_Part_217_190860860.1476981612740
Content-Type: multipart/alternative;
boundary="----=_Part_218_1086358393.1476981612740"
------=_Part_218_1086358393.1476981612740
Content-Type: text/plain; charset=UTF-8
To be honest, this tool is too new to have a strong opinion.
For instance I am not entirely sure why it forbids copy no matter the type
it wraps. This was the reason get_underlying must be used to create new
instance of propagate_const to return to the user. Shouldn't it have the
same copy capability as the underlying type?
Otherwise, I see the problem. It seems it only provides implicate
conversion if underlying is a raw pointer. Probably because, as you said,
the constness is well defined.
--
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/7abb6203-6ca7-4e04-ab6a-dc6a60e223ca%40isocpp.org.
------=_Part_218_1086358393.1476981612740
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>To be honest, this tool is too new to have a strong o=
pinion.</div><div><br></div><div>For instance I am not entirely sure why it=
forbids copy no matter the type it wraps. This was the reason <font color=
=3D"#000000">get_underlying must be used to create new instance of <span st=
yle=3D"color:#000">propagate_const to return to the user. Shouldn't it =
have the same copy capability as the underlying type? </span></font></div><=
div><font color=3D"#000000"><span style=3D"color:#000"><br></span></font></=
div><div><font color=3D"#000000"><span style=3D"color:#000">Otherwise, I se=
e the problem. It seems it only provides implicate conversion if underlying=
is a raw pointer. Probably because, as you said, the constness is well def=
ined. </span></font></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/7abb6203-6ca7-4e04-ab6a-dc6a60e223ca%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/7abb6203-6ca7-4e04-ab6a-dc6a60e223ca=
%40isocpp.org</a>.<br />
------=_Part_218_1086358393.1476981612740--
------=_Part_217_190860860.1476981612740--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Thu, 20 Oct 2016 19:45:49 +0300
Raw View
On 20 October 2016 at 19:40, <mihailnajdenov@gmail.com> wrote:
> For instance I am not entirely sure why it forbids copy no matter the type
> it wraps. This was the reason get_underlying must be used to create new
> instance of propagate_const to return to the user. Shouldn't it have the
> same copy capability as the underlying type?
No, because e.g. for a raw pointer as the underlying type, you can
copy a const pointer to a non-const pointer
every bit as much as you can copy a const int to a non-const int.
Moving is fine because it's fair to assume
that the original const isn't used by anything. The same logic applies
to shared_ptr as the underlying type.
--
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/CAFk2RUZSZ4_mUv8S%3DO5khg9ErDSxJ8vT5R9Z3ULwKLnQqELAVw%40mail.gmail.com.
.
Author: mihailnajdenov@gmail.com
Date: Thu, 20 Oct 2016 13:53:48 -0700 (PDT)
Raw View
------=_Part_483_2147180342.1476996829185
Content-Type: multipart/alternative;
boundary="----=_Part_484_1678696189.1476996829185"
------=_Part_484_1678696189.1476996829185
Content-Type: text/plain; charset=UTF-8
Of course, makes sense.
The constness we care about is the one of the instance, we can't
communicate and "transfer" it on creation or assignment to a new instance.
--
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/60ae1a96-7a31-491d-bcf8-c81590544006%40isocpp.org.
------=_Part_484_1678696189.1476996829185
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Of course, makes sense. </div><div>The constness we c=
are about is the one of the instance, we can't communicate and "tr=
ansfer"=C2=A0it on creation or assignment to a new instance. </div><di=
v><br></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/60ae1a96-7a31-491d-bcf8-c81590544006%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/60ae1a96-7a31-491d-bcf8-c81590544006=
%40isocpp.org</a>.<br />
------=_Part_484_1678696189.1476996829185--
------=_Part_483_2147180342.1476996829185--
.
Author: Jonathan Coe <jbcoe@me.com>
Date: Thu, 20 Oct 2016 22:08:51 +0100
Raw View
--001a114798d22cb5e3053f5255cb
Content-Type: text/plain; charset=UTF-8
Adding `const_type` so that `const propagate_const<T>` is implicitly
convertible to `const_type_t<T>` seems pretty appealing to me.
`get_underlying` is very much like a cast operation, it was added so the
user can discard const_propagation when required.
On 20 October 2016 at 21:53, <mihailnajdenov@gmail.com> wrote:
> Of course, makes sense.
> The constness we care about is the one of the instance, we can't
> communicate and "transfer" it on creation or assignment to a new instance.
>
> --
> 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/60ae1a96-7a31-491d-
> bcf8-c81590544006%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/60ae1a96-7a31-491d-bcf8-c81590544006%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>
--
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/CAAbBDD-Txt57g_XEpKhRaJhW7WXLen%2BemuXKgn2g19DzK5m9Bg%40mail.gmail.com.
--001a114798d22cb5e3053f5255cb
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Adding `const_type` so that `const propagate_const<T>=
;` is implicitly convertible to `const_type_t<T>` seems pretty appeal=
ing to me.<div><br></div><div>`get_underlying` is very much like a cast ope=
ration, it was added so the user can discard const_propagation when require=
d.<br><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On 20 Octob=
er 2016 at 21:53, <span dir=3D"ltr"><<a href=3D"mailto:mihailnajdenov@g=
mail.com" target=3D"_blank">mihailnajdenov@gmail.com</a>></span> wrote:<=
br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>Of course, makes se=
nse. </div><div>The constness we care about is the one of the instance, we =
can't communicate and "transfer"=C2=A0it on creation or assig=
nment to a new instance. </div><div><br></div></div><span class=3D"">
<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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/60ae1a96-7a31-491d-bcf8-c81590544006%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/60ae=
1a96-7a31-491d-<wbr>bcf8-c81590544006%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></div></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/CAAbBDD-Txt57g_XEpKhRaJhW7WXLen%2Bemu=
XKgn2g19DzK5m9Bg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAAbBDD-Txt57g_=
XEpKhRaJhW7WXLen%2BemuXKgn2g19DzK5m9Bg%40mail.gmail.com</a>.<br />
--001a114798d22cb5e3053f5255cb--
.
Author: mihailnajdenov@gmail.com
Date: Fri, 21 Oct 2016 01:36:09 -0700 (PDT)
Raw View
------=_Part_506_953892667.1477038969969
Content-Type: multipart/alternative;
boundary="----=_Part_507_728899757.1477038969969"
------=_Part_507_728899757.1477038969969
Content-Type: text/plain; charset=UTF-8
On Friday, October 21, 2016 at 12:08:54 AM UTC+3, Jonathan Coe wrote:
>
> Adding `const_type` so that `const propagate_const<T>` is implicitly
> convertible to `const_type_t<T>` seems pretty appealing to me.
>
> ...
>
To be honest, I much more worried about the blanket ban on copy.
This makes it unsuitable for standalone use and, even as member - the
moment you put it in you class, you will have to write quite non-standard
copy constructor.
I even think, wouldn't it be possible to have some sort of attribute
instead?
template<class T>
using AutoConstT [[inherit_const]] = T; //< T will be const when it is
accessed from a const pointer
struct C {
AutoConstT<T>* p;
};
const C c;
c.p->func(); //< c is const => p is const => T is const
const std::shared_ptr<AutoConstT<T>> p = getP(); //< AutoConstT will tunnel
down to shared_ptr's _Tp* _M_ptr; // Contained pointer.
p->func(); //< const overload
auto p2 = p; //< not ok
const auto p3 = p; //< ok
All else just works, no wrappers, no conversions, no nothing.
Just adjusting the fundamental rule that const on pointer does not affect
const of the pointed-to.
--
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/3ca3ba5e-e690-412c-b3f5-d85301587adb%40isocpp.org.
------=_Part_507_728899757.1477038969969
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Friday, October 21, 2016 at 12:08:54 AM UTC+3, =
Jonathan Coe wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D=
"ltr">Adding `const_type` so that `const propagate_const<T>` is impli=
citly convertible to `const_type_t<T>` seems pretty appealing to me.<=
div><br></div><div><div>...<br></div></div></div></blockquote><div><br></di=
v><div>To be honest, I much more worried about the blanket ban on copy. </d=
iv><div><br></div><div><br></div><div>This makes it unsuitable for standalo=
ne use and, even as member - the moment =C2=A0you put it in you class, you =
will have to write quite non-standard copy constructor.</div><div><br></div=
><div><br></div><div>I even think, wouldn't it be possible=C2=A0to have=
some sort of attribute instead? </div><div><br></div><div class=3D"prettyp=
rint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word;=
background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><font c=
olor=3D"rgb(0,0,0)"><div class=3D"subprettyprint">template<class T><b=
r>using AutoConstT [[inherit_const]] =3D T; //< T will be const when it =
is accessed from a const pointer</div><div><br></div><div class=3D"subprett=
yprint">struct C {</div><div><br></div><div class=3D"subprettyprint">=C2=A0=
AutoConstT<T>* p;</div><div class=3D"subprettyprint"><br></div><div c=
lass=3D"subprettyprint">};</div><div><br></div><div class=3D"subprettyprint=
">const C c;<br>c.p->func(); //< c is const =3D> p is const =3D>=
; T is const</div><div><br></div><div class=3D"subprettyprint">const std::s=
hared_ptr<AutoConstT<T>> p =3D getP(); //< AutoConstT will t=
unnel down to shared_ptr's=C2=A0_Tp* _M_ptr; // Contained pointer. </di=
v><div><br></div><div class=3D"subprettyprint">p->func(); //< const o=
verload<br><br>auto p2 =3D p; //< not ok<br><br>const auto p3 =3D p;=C2=
=A0//< ok<br><br></div></font></code></div><div><font color=3D"rgb(34,34=
,34)"><br></font></div><div>All else just works, no wrappers, no conversion=
s, no nothing. </div><div>Just adjusting the fundamental rule that const on=
pointer does not affect const of the pointed-to.</div><div><br></div><div>=
<br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/3ca3ba5e-e690-412c-b3f5-d85301587adb%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/3ca3ba5e-e690-412c-b3f5-d85301587adb=
%40isocpp.org</a>.<br />
------=_Part_507_728899757.1477038969969--
------=_Part_506_953892667.1477038969969--
.
Author: joseph.thomson@gmail.com
Date: Fri, 21 Oct 2016 03:51:42 -0700 (PDT)
Raw View
------=_Part_1188_1114561847.1477047102915
Content-Type: multipart/alternative;
boundary="----=_Part_1189_853874482.1477047102915"
------=_Part_1189_853874482.1477047102915
Content-Type: text/plain; charset=UTF-8
The shared_ptr will still be uncopyable, because its copy operations take
the object to copy by reference to const. To allow copying of
propagate_const or types that use it would require formalising a non-const
copyable concept. You can define non-const copy operations, and the
compiler does appear to automatically generate non-const operations if
const versions aren't possible, but it isn't something the standard library
or language supports particularly well. In fact, it isnt possible to define
both const and non-const copy operations simultaneously.
On Friday, 21 October 2016 16:36:10 UTC+8, mihailn...@gmail.com wrote:
>
>
>
> On Friday, October 21, 2016 at 12:08:54 AM UTC+3, Jonathan Coe wrote:
>>
>> Adding `const_type` so that `const propagate_const<T>` is implicitly
>> convertible to `const_type_t<T>` seems pretty appealing to me.
>>
>> ...
>>
>
> To be honest, I much more worried about the blanket ban on copy.
>
>
> This makes it unsuitable for standalone use and, even as member - the
> moment you put it in you class, you will have to write quite non-standard
> copy constructor.
>
>
> I even think, wouldn't it be possible to have some sort of attribute
> instead?
>
> template<class T>
> using AutoConstT [[inherit_const]] = T; //< T will be const when it is
> accessed from a const pointer
>
> struct C {
>
> AutoConstT<T>* p;
>
> };
>
> const C c;
> c.p->func(); //< c is const => p is const => T is const
>
> const std::shared_ptr<AutoConstT<T>> p = getP(); //< AutoConstT will
> tunnel down to shared_ptr's _Tp* _M_ptr; // Contained pointer.
>
> p->func(); //< const overload
>
> auto p2 = p; //< not ok
>
> const auto p3 = p; //< ok
>
>
> All else just works, no wrappers, no conversions, no nothing.
> Just adjusting the fundamental rule that const on pointer does not affect
> const of the pointed-to.
>
>
>
--
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/1c87d59b-e536-40f6-a3fa-a5720640b6dc%40isocpp.org.
------=_Part_1189_853874482.1477047102915
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The shared_ptr will still be uncopyable, because its copy =
operations take the object to copy by reference to const. To allow copying =
of propagate_const or types that use it would require formalising a non-con=
st copyable concept. You can define non-const copy operations, and the comp=
iler does appear to automatically generate non-const operations if const ve=
rsions aren't possible, but it isn't something the standard library=
or language supports particularly well. In fact, it isnt possible to defin=
e both const and non-const copy operations simultaneously.<br><br>On Friday=
, 21 October 2016 16:36:10 UTC+8, mihailn...@gmail.com wrote:<blockquote c=
lass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px=
#ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><br><br>On Friday, October=
21, 2016 at 12:08:54 AM UTC+3, Jonathan Coe wrote:<blockquote class=3D"gma=
il_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;pa=
dding-left:1ex"><div dir=3D"ltr">Adding `const_type` so that `const propaga=
te_const<T>` is implicitly convertible to `const_type_t<T>` see=
ms pretty appealing to me.<div><br></div><div><div>...<br></div></div></div=
></blockquote><div><br></div><div>To be honest, I much more worried about t=
he blanket ban on copy. </div><div><br></div><div><br></div><div>This makes=
it unsuitable for standalone use and, even as member - the moment =C2=A0yo=
u put it in you class, you will have to write quite non-standard copy const=
ructor.</div><div><br></div><div><br></div><div>I even think, wouldn't =
it be possible=C2=A0to have some sort of attribute instead? </div><div><br>=
</div><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;=
background-color:rgb(250,250,250)"><code><font color=3D"rgb(0,0,0)"><div>te=
mplate<class T><br>using AutoConstT [[inherit_const]] =3D T; //< T=
will be const when it is accessed from a const pointer</div><div><br></div=
><div>struct C {</div><div><br></div><div>=C2=A0AutoConstT<T>* p;</di=
v><div><br></div><div>};</div><div><br></div><div>const C c;<br>c.p->fun=
c(); //< c is const =3D> p is const =3D> T is const</div><div><br>=
</div><div>const std::shared_ptr<AutoConstT<T>> p =3D getP(); /=
/< AutoConstT will tunnel down to shared_ptr's=C2=A0_Tp* _M_ptr; // =
Contained pointer. </div><div><br></div><div>p->func(); //< const ove=
rload<br><br>auto p2 =3D p; //< not ok<br><br>const auto p3 =3D p;=C2=A0=
//< ok<br><br></div></font></code></div><div><font color=3D"rgb(34,34,34=
)"><br></font></div><div>All else just works, no wrappers, no conversions, =
no nothing. </div><div>Just adjusting the fundamental rule that const on po=
inter does not affect const of the pointed-to.</div><div><br></div><div><br=
></div></div></blockquote></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/1c87d59b-e536-40f6-a3fa-a5720640b6dc%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1c87d59b-e536-40f6-a3fa-a5720640b6dc=
%40isocpp.org</a>.<br />
------=_Part_1189_853874482.1477047102915--
------=_Part_1188_1114561847.1477047102915--
.
Author: mihailnajdenov@gmail.com
Date: Fri, 21 Oct 2016 06:00:53 -0700 (PDT)
Raw View
------=_Part_547_104677683.1477054853249
Content-Type: multipart/alternative;
boundary="----=_Part_548_1745686103.1477054853250"
------=_Part_548_1745686103.1477054853250
Content-Type: text/plain; charset=UTF-8
On Friday, October 21, 2016 at 1:51:43 PM UTC+3, joseph....@gmail.com wrote:
>
> The shared_ptr will still be uncopyable, because its copy operations take
> the object to copy by reference to const. To allow copying of
> propagate_const or types that use it would require formalising a non-const
> copyable concept. You can define non-const copy operations, and the
> compiler does appear to automatically generate non-const operations if
> const versions aren't possible, but it isn't something the standard library
> or language supports particularly well. In fact, it isnt possible to define
> both const and non-const copy operations simultaneously.
>
>> ...
>>
>>
I think overloads on the assignment and/or construction will pick the
correct one.
struct S
{
S() = default;
S& operator=(const S&) { std::cout << "=const S&" ; return *this; }
S& operator=(S&) { std::cout << "=S&" ; return *this; }
};
int main()
{
const S s;
S ss;
S sss;
ss = s; //< "=const S&"
sss = ss; //< "=S&"
}
Sadly, all this is still not enough to implement the above, even if such a
attribute existed.
There must be a further rule that a copy of AutoConstT* must result in a
const T*.
This is because we cant create/detect instances of objects which are const
on creation.
We can't detect
const S b(other);
VS.
b(other);
Even if 'other' can be detected as const or not,
The ctor is the same, and const is applied to the instance after creation.
So given
struct S
{
AutoConstT* p;
};
when copy constructed from a const S& must become
struct S
{
const T* p;
};
When constructed from S& will still become a
struct S
{
AutoConstT* p;
};
So there are *at least* two requirements to this typedef -
1) access though a const pointer to it will make it const.
2) When a const pointer to this type is copied, the type becomes permanent
const.
--
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/8712c737-7690-4396-8b3b-345bc936a1d7%40isocpp.org.
------=_Part_548_1745686103.1477054853250
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Friday, October 21, 2016 at 1:51:43 PM UTC+3, j=
oseph....@gmail.com 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">The shared_ptr will still be uncopyable, because its copy oper=
ations take the object to copy by reference to const. To allow copying of p=
ropagate_const or types that use it would require formalising a non-const c=
opyable concept. You can define non-const copy operations, and the compiler=
does appear to automatically generate non-const operations if const versio=
ns aren't possible, but it isn't something the standard library or =
language supports particularly well. In fact, it isnt possible to define bo=
th const and non-const copy operations simultaneously.<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr"><div>...<br></div><div><br></div></=
div></blockquote></div></blockquote><div><br></div><div>I think overloads o=
n the assignment and/or construction will pick the correct one.</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"></code><div class=3D"subprettyprint"><code class=3D"=
prettyprint"><font color=3D"rgb(34,34,34)" face=3D"Arial" style=3D"backgrou=
nd-color: transparent;">struct S<br>{<br>=C2=A0 =C2=A0 S() =3D default;<br>=
=C2=A0 =C2=A0 S& operator=3D(const S&) { =C2=A0std::cout << &=
quot;=3Dconst S&" ; return *this; }<br>=C2=A0 =C2=A0 S& operat=
or=3D(S&) { =C2=A0std::cout << "=3DS&" ; return *th=
is; }<br>};<br><br>int main()<br>{<br>=C2=A0 =C2=A0 const S s;<br>=C2=A0 =
=C2=A0 S ss;<br>=C2=A0 =C2=A0 S sss;<code class=3D"prettyprint"><font color=
=3D"rgb(34,34,34)" face=3D"Arial" style=3D"background-color: transparent;">=
</font></code></font><code class=3D"prettyprint"></code></code><code class=
=3D"prettyprint"><font color=3D"rgb(34,34,34)" face=3D"Arial" style=3D"back=
ground-color: transparent;"><code class=3D"prettyprint"></code><br>=C2=A0 =
=C2=A0 <br>=C2=A0 =C2=A0 ss =3D s; =C2=A0//< "=3Dconst S&"=
<br>=C2=A0 =C2=A0 sss =3D ss; //< "=3DS&"<span id=3D"goog_=
456798339"></span></font><font color=3D"rgb(34,34,34)" face=3D"Arial" style=
=3D"background-color: transparent;"><br>}<br>=C2=A0</font></code></div><cod=
e class=3D"prettyprint"></code></div><div><br></div><div><br></div><div>Sad=
ly, all this is still not enough to implement the above, even if such a att=
ribute existed. </div><div><br></div><div>There must be a further rule that=
a copy of AutoConstT* must result in a const T*. </div><div><br></div><div=
>This is because we cant create/detect instances of objects which are const=
on creation.</div><div><br></div><div>We can't detect </div><div><br><=
/div><div>const S b(other);</div><div><br></div><div>VS.</div><div><br></di=
v><div>b(other);</div><div><br></div><div>Even if 'other' can be de=
tected as const or not,</div><div>The ctor is the same, and const is applie=
d to the instance after creation.</div><div><br></div><div>So given</div><d=
iv><br></div><div>struct=C2=A0 S</div><div>{</div><div>=C2=A0 AutoConstT* p=
;</div><div>};</div><div><br></div><div>when copy constructed from a const =
S&=C2=A0must become</div><div><br></div><div><div>struct S</div><div>{<=
/div><div>=C2=A0 const T* p;</div><div>};</div><div><br></div><div>When con=
structed from S& will still become a</div><div><br></div><div><div>stru=
ct=C2=A0 S</div><div>{</div><div>=C2=A0 AutoConstT* p;</div><div>};</div><d=
iv><br></div><div>So there are <i>at least</i> two requirements to=C2=A0thi=
s typedef=C2=A0- </div><div>=C2=A01) access=C2=A0though a const pointer=C2=
=A0to it will make it const.</div><div>=C2=A02) When a const pointer to thi=
s type is copied, the type becomes permanent const. </div><div><br></div></=
div></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/8712c737-7690-4396-8b3b-345bc936a1d7%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/8712c737-7690-4396-8b3b-345bc936a1d7=
%40isocpp.org</a>.<br />
------=_Part_548_1745686103.1477054853250--
------=_Part_547_104677683.1477054853249--
.
Author: joseph.thomson@gmail.com
Date: Fri, 21 Oct 2016 10:22:19 -0700 (PDT)
Raw View
------=_Part_1464_112836723.1477070539556
Content-Type: multipart/alternative;
boundary="----=_Part_1465_729748463.1477070539557"
------=_Part_1465_729748463.1477070539557
Content-Type: text/plain; charset=UTF-8
On Friday, 21 October 2016 05:08:54 UTC+8, Jonathan Coe wrote:
>
> Adding `const_type` so that `const propagate_const<T>` is implicitly
> convertible to `const_type_t<T>` seems pretty appealing to me.
>
> `get_underlying` is very much like a cast operation, it was added so the
> user can discard const_propagation when required.
>
It's worth noting that with this new implicit conversion, the
implementation of get_underlying pretty much becomes a call to const_cast:
template <typename T>
T const& get_underlying(propagate_const<T> const& pc) {
return const_cast<propagate_const<T>&>(pc);
}
template <typename T>
T& get_underlying(propagate_const<T>& pc) {
return pc;
}
--
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/d348adb2-19b5-48f9-8836-adf9c3fa3300%40isocpp.org.
------=_Part_1465_729748463.1477070539557
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Friday, 21 October 2016 05:08:54 UTC+8, Jonathan Coe w=
rote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8e=
x;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Adding `=
const_type` so that `const propagate_const<T>` is implicitly converti=
ble to `const_type_t<T>` seems pretty appealing to me.<div><br></div>=
<div>`get_underlying` is very much like a cast operation, it was added so t=
he user can discard const_propagation when required.<br></div></div></block=
quote><div><br>It's worth noting that with this new implicit conversion=
, the implementation of <span style=3D"font-family: courier new,monospace;"=
>get_underlying</span> pretty much becomes a call to <span style=3D"font-fa=
mily: courier new,monospace;">const_cast</span>:<br><br><div style=3D"backg=
round-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-s=
tyle: solid; border-width: 1px; overflow-wrap: break-word;" class=3D"pretty=
print"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">></span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>T </span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">const</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">&</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> get_underlying</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
propagate_const</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify"><</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"> </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> pc</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>=C2=A0 =C2=A0 </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: #008;" class=3D"styled-by-prettif=
y">const_cast</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y"><</span><span style=3D"color: #000;" class=3D"styled-by-prettify">pro=
pagate_const</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
"><</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">>&>=
(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">pc</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">template</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">typename</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">></span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br>T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&am=
p;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> get_und=
erlying</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">propagate_co=
nst</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</s=
pan><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"> pc</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> pc</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></span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">}</span></div></code></div><br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/d348adb2-19b5-48f9-8836-adf9c3fa3300%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d348adb2-19b5-48f9-8836-adf9c3fa3300=
%40isocpp.org</a>.<br />
------=_Part_1465_729748463.1477070539557--
------=_Part_1464_112836723.1477070539556--
.
Author: mihailnajdenov@gmail.com
Date: Sat, 22 Oct 2016 01:34:54 -0700 (PDT)
Raw View
------=_Part_868_1749200556.1477125294690
Content-Type: multipart/alternative;
boundary="----=_Part_869_890155097.1477125294690"
------=_Part_869_890155097.1477125294690
Content-Type: text/plain; charset=UTF-8
BTW, what is your use case? Or you meant from purely correctness point of
view?
--
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/aeae0bb0-aa8e-4c84-90ea-45cea4aa1b25%40isocpp.org.
------=_Part_869_890155097.1477125294690
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">BTW, what is your use case? Or you meant from purely corre=
ctness point of view?</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/aeae0bb0-aa8e-4c84-90ea-45cea4aa1b25%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/aeae0bb0-aa8e-4c84-90ea-45cea4aa1b25=
%40isocpp.org</a>.<br />
------=_Part_869_890155097.1477125294690--
------=_Part_868_1749200556.1477125294690--
.
Author: joseph.thomson@gmail.com
Date: Sat, 22 Oct 2016 03:02:43 -0700 (PDT)
Raw View
------=_Part_1954_1125249054.1477130563854
Content-Type: multipart/alternative;
boundary="----=_Part_1955_136609730.1477130563854"
------=_Part_1955_136609730.1477130563854
Content-Type: text/plain; charset=UTF-8
On Saturday, 22 October 2016 16:34:54 UTC+8, mihailn...@gmail.com wrote:
>
> BTW, what is your use case? Or you meant from purely correctness point of
> view?
>
My personal use case is std::observer_ptr and the like. You can work around
the limitations of propagate_const with these non-owning wrappers; it's
just a bit of a hassle:
class container {
public:
observer_ptr<int const> get_value() const { return make_observer(value.
get()); }
observer_ptr<int> get_value() { return make_observer(value.get()); }
private:
propagate_const<observer_ptr<int>> value;
};
That's why I chose shared_ptr as an example, because it has no "safe"
workaround, and is therefore somewhat incompatible with propagate_const as
it stands.
--
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/bcba393d-6c88-42ca-88ca-fbda08d49758%40isocpp.org.
------=_Part_1955_136609730.1477130563854
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Saturday, 22 October 2016 16:34:54 UTC+8, mihailn...@gm=
ail.com 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=
">BTW, what is your use case? Or you meant from purely correctness point of=
view?</div></blockquote><div><br>My personal use case is <span style=3D"fo=
nt-family: courier new,monospace;">std::observer_ptr</span> and the like. Y=
ou can work around the limitations of <span style=3D"font-family: courier n=
ew,monospace;">propagate_const</span> with these non-owning wrappers; it=
9;s just a bit of a hassle:<br><br><div style=3D"background-color: rgb(250,=
250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-w=
idth: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><code class=3D=
"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">class</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> container </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">public</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
>=C2=A0 =C2=A0observer_ptr</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">const<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">></span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> get_value</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">const</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </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">return</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> make_observer</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
value</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">get</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">());</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0observer_ptr</span><span sty=
le=3D"color: #080;" class=3D"styled-by-prettify"><int></span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> get_value</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">return</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> make_observer</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">value</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>.</span><span style=3D"color: #008;" class=3D"styled-by-prettify">get</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">());</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"><br><br></span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">private</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0propagate_const</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">observer_ptr</span><span style=3D"=
color: #080;" class=3D"styled-by-prettify"><int></span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">></span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> value</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">};</span></div></code></div><br>That's why I chose <=
span style=3D"font-family: courier new,monospace;">shared_ptr</span> as an =
example, because it has no "safe" workaround, and is therefore so=
mewhat incompatible with <span style=3D"font-family: courier new,monospace;=
">propagate_const</span> as it stands.<br></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/bcba393d-6c88-42ca-88ca-fbda08d49758%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/bcba393d-6c88-42ca-88ca-fbda08d49758=
%40isocpp.org</a>.<br />
------=_Part_1955_136609730.1477130563854--
------=_Part_1954_1125249054.1477130563854--
.
Author: mihailnajdenov@gmail.com
Date: Sat, 22 Oct 2016 06:08:50 -0700 (PDT)
Raw View
------=_Part_625_1982012202.1477141730105
Content-Type: multipart/alternative;
boundary="----=_Part_626_1062329413.1477141730106"
------=_Part_626_1062329413.1477141730106
Content-Type: text/plain; charset=UTF-8
On Saturday, October 22, 2016 at 1:02:43 PM UTC+3, joseph....@gmail.com
wrote:
>
> On Saturday, 22 October 2016 16:34:54 UTC+8, mihailn...@gmail.com wrote:
>>
>> BTW, what is your use case? Or you meant from purely correctness point of
>> view?
>>
>
> My personal use case is std::observer_ptr and the like. You can work
> around the limitations of propagate_const with these non-owning wrappers;
> it's just a bit of a hassle:
>
> class container {
> public:
> observer_ptr<int const> get_value() const { return make_observer(value.
> get()); }
> observer_ptr<int> get_value() { return make_observer(value.get()); }
>
> private:
> propagate_const<observer_ptr<int>> value;
> };
> ...
>
I see.
Too bad we'll end up yet again with duplicated const and non conts
interfaces.
For instance in your case there also should be a
observer_ptr<int const> get_cvalue() const;
Because the user might want to get a const observer from a non-const
instance of the container.
Or do a bit awkward things like
container c;
auto v = std::as_const(c).get_value();
or manually specify a different type
observer_ptr<int const> v = c.get_value();
No matter which of the 3 one thinks is right, the fact there so much
"correct" ways is not a good thing.
Your comments on the other thread really made me think, an observer ptr
should be able propagate const.
This will enable the correct default for objects to be the correct default
for handles-to-objects as well
const auto v = c.get_value();
Sadly, we can't really have that right now :(
--
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/b53d5d2e-35cb-4f55-8ce6-6f7fe926c428%40isocpp.org.
------=_Part_626_1062329413.1477141730106
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Saturday, October 22, 2016 at 1:02:43 PM UTC+3,=
joseph....@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"marg=
in: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><d=
iv dir=3D"ltr">On Saturday, 22 October 2016 16:34:54 UTC+8, <a>mihailn...@g=
mail.com</a> wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;mar=
gin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr=
">BTW, what is your use case? Or you meant from purely correctness point of=
view?</div></blockquote><div><br>My personal use case is <span style=3D"fo=
nt-family:courier new,monospace">std::observer_ptr</span> and the like. You=
can work around the limitations of <span style=3D"font-family:courier new,=
monospace">propagate_const</span> with these non-owning wrappers; it's =
just a bit of a hassle:<br><br><div style=3D"background-color:rgb(250,250,2=
50);border-color:rgb(187,187,187);border-style:solid;border-width:1px"><cod=
e><div><span style=3D"color:#008">class</span><span style=3D"color:#000"> c=
ontainer </span><span style=3D"color:#660">{</span><span style=3D"color:#00=
0"><br></span><span style=3D"color:#008">public</span><span style=3D"color:=
#660">:</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0observer_ptr</spa=
n><span style=3D"color:#660"><</span><span style=3D"color:#008">int</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#008">const</span=
><span style=3D"color:#660">></span><span style=3D"color:#000"> get_valu=
e</span><span style=3D"color:#660">()</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#008">const</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#660">{</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#008">return</span><span style=3D"color:#000"> make_obse=
rver</span><span style=3D"color:#660">(</span><span style=3D"color:#000">va=
lue</span><span style=3D"color:#660">.</span><span style=3D"color:#008">get=
</span><span style=3D"color:#660">());</span><span style=3D"color:#000"> </=
span><span style=3D"color:#660">}</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0observer_ptr</span><span style=3D"color:#080"><int></span><=
span style=3D"color:#000"> get_value</span><span style=3D"color:#660">()</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#660">{</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">return</span><=
span style=3D"color:#000"> make_observer</span><span style=3D"color:#660">(=
</span><span style=3D"color:#000">value</span><span style=3D"color:#660">.<=
/span><span style=3D"color:#008">get</span><span style=3D"color:#660">());<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#660">}</span=
><span style=3D"color:#000"><br><br></span><span style=3D"color:#008">priva=
te</span><span style=3D"color:#660">:</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0propagate_const</span><span style=3D"color:#660"><</span><s=
pan style=3D"color:#000">observer_ptr</span><span style=3D"color:#080"><=
<wbr>int></span><span style=3D"color:#660">></span><span style=3D"col=
or:#000"> value</span><span style=3D"color:#660">;</span><span style=3D"col=
or:#000"><br></span><span style=3D"color:#660">};</span></div></code></div>=
....<br></div></div></blockquote><div><br></div><div>I see. </div><div>Too b=
ad we'll end up yet again=C2=A0with duplicated=C2=A0const and non conts=
interfaces.</div><div><br></div><div>For instance in your case there also =
should be a=C2=A0=C2=A0</div><div><br></div><div class=3D"prettyprint" styl=
e=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; backgroun=
d-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"sub=
prettyprint"><font color=3D"#000000"><span class=3D"styled-by-prettify" sty=
le=3D"color: #000;">observer_ptr</span></font><span style=3D"color:#660"><s=
pan class=3D"styled-by-prettify" style=3D"color: #660;"><</span></span><=
span style=3D"color:#008"><span class=3D"styled-by-prettify" style=3D"color=
: #008;">int</span></span><span style=3D"color:#000"><span class=3D"styled-=
by-prettify" style=3D"color: #000;"> </span></span><span style=3D"color:#00=
8"><span class=3D"styled-by-prettify" style=3D"color: #008;">const</span></=
span><span style=3D"color:#660"><span class=3D"styled-by-prettify" style=3D=
"color: #660;">></span><span class=3D"styled-by-prettify" style=3D"color=
: #000;"> get_cvalue</span><span class=3D"styled-by-prettify" style=3D"colo=
r: #660;">()</span><span class=3D"styled-by-prettify" style=3D"color: #000;=
"> </span><span class=3D"styled-by-prettify" style=3D"color: #008;">const</=
span><span class=3D"styled-by-prettify" style=3D"color: #660;">;</span><spa=
n class=3D"styled-by-prettify" style=3D"color: #000;"><br></span></span><sp=
an style=3D"color:#000"></span></div></code></div><div><b><br></b></div><di=
v>Because the user might want to get a const observer from a non-const inst=
ance of the container. </div><div><br></div><div><br></div><div>Or do a bit=
awkward things like </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"><font color=3D"#222222"><span class=3D"styled-by-prettify" styl=
e=3D"color: #000;">container </span><span style=3D"color:#660"><span class=
=3D"styled-by-prettify" style=3D"color: #000;">c</span><span class=3D"style=
d-by-prettify" style=3D"color: #660;">;</span></span><b><i><u><sub><sup><st=
rike><span class=3D"styled-by-prettify" style=3D"color: #000;"><br></span><=
/strike></sup></sub></u></i></b><span class=3D"styled-by-prettify" style=3D=
"color: #008;">auto</span><span class=3D"styled-by-prettify" style=3D"color=
: #000;"> v </span><span class=3D"styled-by-prettify" style=3D"color: #660;=
">=3D</span><span class=3D"styled-by-prettify" style=3D"color: #000;"> std<=
/span><span class=3D"styled-by-prettify" style=3D"color: #660;">::</span><s=
pan class=3D"styled-by-prettify" style=3D"color: #000;">as_const</span><spa=
n class=3D"styled-by-prettify" style=3D"color: #660;">(</span><span class=
=3D"styled-by-prettify" style=3D"color: #000;">c</span><span class=3D"style=
d-by-prettify" style=3D"color: #660;">).</span><span class=3D"styled-by-pre=
ttify" style=3D"color: #000;">get_value</span><span class=3D"styled-by-pret=
tify" style=3D"color: #660;">();</span></font></div></code></div><div><b><b=
r></b></div><div>or manually specify a different type</div><div><br></div><=
div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); wo=
rd-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=3D"=
prettyprint"><div class=3D"subprettyprint"><font color=3D"rgb(102,102,0)"><=
span class=3D"styled-by-prettify" style=3D"color: #000;">observer_ptr</span=
><span style=3D"color:#660"><span class=3D"styled-by-prettify" style=3D"col=
or: #660;"><</span></span><span style=3D"color:#008"><span class=3D"styl=
ed-by-prettify" style=3D"color: #008;">int</span></span><span style=3D"colo=
r:#000"><span class=3D"styled-by-prettify" style=3D"color: #000;"> </span><=
/span><span style=3D"color:#008"><span class=3D"styled-by-prettify" style=
=3D"color: #008;">const</span></span><span style=3D"color:#660"><span class=
=3D"styled-by-prettify" style=3D"color: #660;">></span><span class=3D"st=
yled-by-prettify" style=3D"color: #000;"> </span></span><span class=3D"styl=
ed-by-prettify" style=3D"color: #000;">v </span><span class=3D"styled-by-pr=
ettify" style=3D"color: #660;">=3D</span><span class=3D"styled-by-prettify"=
style=3D"color: #000;"> c</span><span class=3D"styled-by-prettify" style=
=3D"color: #660;">.</span><span class=3D"styled-by-prettify" style=3D"color=
: #000;">get_value</span><span class=3D"styled-by-prettify" style=3D"color:=
#660;">();</span><span class=3D"styled-by-prettify" style=3D"color: #000;"=
> </span></font></div></code><div class=3D"subprettyprint"><br></div></div>=
<div><br></div><div>No matter which of the 3 one thinks is right, the fact =
there so much "correct" ways is not a good thing.</div><div><br><=
/div><div>Your comments on the other thread really made me think, an observ=
er ptr should be able propagate const.=C2=A0</div><div><br></div><div>This =
will enable the correct=C2=A0default for objects to be the correct default =
for handles-to-objects as well</div><code class=3D"prettyprint"><div><br></=
div><div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187=
, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code=
class=3D"prettyprint"><div class=3D"subprettyprint"><span class=3D"styled-=
by-prettify" style=3D"color: #008;">const</span><span class=3D"styled-by-pr=
ettify" style=3D"color: #000;"> </span><span class=3D"styled-by-prettify" s=
tyle=3D"color: #008;">auto</span><span class=3D"styled-by-prettify" style=
=3D"color: #000;"> v </span><span class=3D"styled-by-prettify" style=3D"col=
or: #660;">=3D</span><span class=3D"styled-by-prettify" style=3D"color: #00=
0;"> c</span><span class=3D"styled-by-prettify" style=3D"color: #660;">.</s=
pan><span class=3D"styled-by-prettify" style=3D"color: #000;">get_value</sp=
an><span class=3D"styled-by-prettify" style=3D"color: #660;">();</span></di=
v></code></div><br></div></code><div class=3D"subprettyprint"><br></div><di=
v>Sadly, we can't really have that right now :(<br></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/b53d5d2e-35cb-4f55-8ce6-6f7fe926c428%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b53d5d2e-35cb-4f55-8ce6-6f7fe926c428=
%40isocpp.org</a>.<br />
------=_Part_626_1062329413.1477141730106--
------=_Part_625_1982012202.1477141730105--
.
Author: joseph.thomson@gmail.com
Date: Sat, 22 Oct 2016 20:09:53 -0700 (PDT)
Raw View
------=_Part_2567_812068324.1477192194044
Content-Type: multipart/alternative;
boundary="----=_Part_2568_482402054.1477192194044"
------=_Part_2568_482402054.1477192194044
Content-Type: text/plain; charset=UTF-8
On Saturday, 22 October 2016 21:08:50 UTC+8, mihailn...@gmail.com wrote:
>
>
>
> On Saturday, October 22, 2016 at 1:02:43 PM UTC+3, joseph....@gmail.com
> wrote:
>>
>> On Saturday, 22 October 2016 16:34:54 UTC+8, mihailn...@gmail.com wrote:
>>>
>>> BTW, what is your use case? Or you meant from purely correctness point
>>> of view?
>>>
>>
>> My personal use case is std::observer_ptr and the like. You can work
>> around the limitations of propagate_const with these non-owning
>> wrappers; it's just a bit of a hassle:
>>
>> class container {
>> public:
>> observer_ptr<int const> get_value() const { return make_observer(value
>> .get()); }
>> observer_ptr<int> get_value() { return make_observer(value.get()); }
>>
>> private:
>> propagate_const<observer_ptr<int>> value;
>> };
>> ...
>>
>
> I see.
> Too bad we'll end up yet again with duplicated const and non conts
> interfaces.
>
> For instance in your case there also should be a
>
> observer_ptr<int const> get_cvalue() const;
>
> Because the user might want to get a const observer from a non-const
> instance of the container.
>
>
> Or do a bit awkward things like
>
> container c;
> auto v = std::as_const(c).get_value();
>
> or manually specify a different type
>
> observer_ptr<int const> v = c.get_value();
>
>
> No matter which of the 3 one thinks is right, the fact there so much
> "correct" ways is not a good thing.
>
I think this problem is somewhat orthogonal to the concerns of
propagate_const. You have made me think about this though. It is annoying
that it is necessary to duplicate code a lot of the time when writing const
versions of things. I may start another thread to have this discussion.
Your comments on the other thread really made me think, an observer ptr
> should be able propagate const.
>
> This will enable the correct default for objects to be the correct default
> for handles-to-objects as well
>
> const auto v = c.get_value();
>
>
> Sadly, we can't really have that right now :(
>
I am increasingly thinking that, without more fundamental changes to the
C++ language, const-propagation works best when kept separate from any
indirection types. For example, if std::shared_ptr had built-in
const-propagation, you would need a special function to allow you to copy
it:
class container {
public:
shared_ptr<int const> get_value() const { return value.copy(); }
shared_ptr<int> get_value() { return value.copy(); }
private:
shared_ptr<int> value;
};
In addition, calls to this API would be required to use this verbose
copying syntax even though they aren't benefiting from the built-in
const-propagation:
shared_ptr<int> v = c.get_value();
shared_ptr<int> w = v.copy(); // why the restriction; v cannot possibly
become const!
Const-propagation only really has value in cases of composition, where you
want to ensure that, when an object is only accessible via a reference to
const, that the constness propagates not only to its data members, but also
any objects those data members indirectly reference. If we restrict our use
of propagate_const to the data members of a class, then we get natural
copying syntax, and callers have the flexibility to do with their copies
what they want.
--
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/a51760a2-b976-4ef6-9214-bba82af80b79%40isocpp.org.
------=_Part_2568_482402054.1477192194044
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Saturday, 22 October 2016 21:08:50 UTC+8, mihailn...@gm=
ail.com 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=
"><br><br>On Saturday, October 22, 2016 at 1:02:43 PM UTC+3, <a>joseph....@=
gmail.com</a> wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;mar=
gin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr=
">On Saturday, 22 October 2016 16:34:54 UTC+8, <a>mihailn...@gmail.com</a> =
wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8e=
x;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">BTW, what i=
s your use case? Or you meant from purely correctness point of view?</div><=
/blockquote><div><br>My personal use case is <span style=3D"font-family:cou=
rier new,monospace">std::observer_ptr</span> and the like. You can work aro=
und the limitations of <span style=3D"font-family:courier new,monospace">pr=
opagate_const</span> with these non-owning wrappers; it's just a bit of=
a hassle:<br><br><div style=3D"background-color:rgb(250,250,250);border-co=
lor:rgb(187,187,187);border-style:solid;border-width:1px"><code><div><span =
style=3D"color:#008">class</span><span style=3D"color:#000"> container </sp=
an><span style=3D"color:#660">{</span><span style=3D"color:#000"><br></span=
><span style=3D"color:#008">public</span><span style=3D"color:#660">:</span=
><span style=3D"color:#000"><br>=C2=A0 =C2=A0observer_ptr</span><span style=
=3D"color:#660"><</span><span style=3D"color:#008">int</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">const</span><span style=
=3D"color:#660">></span><span style=3D"color:#000"> get_value</span><spa=
n style=3D"color:#660">()</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#008">const</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">{</span><span style=3D"color:#000"> </span><span style=3D=
"color:#008">return</span><span style=3D"color:#000"> make_observer</span><=
span style=3D"color:#660">(</span><span style=3D"color:#000">value</span><s=
pan style=3D"color:#660">.</span><span style=3D"color:#008">get</span><span=
style=3D"color:#660">());</span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#660">}</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0obs=
erver_ptr</span><span style=3D"color:#080"><int></span><span style=3D=
"color:#000"> get_value</span><span style=3D"color:#660">()</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#660">{</span><span style=3D=
"color:#000"> </span><span style=3D"color:#008">return</span><span style=3D=
"color:#000"> make_observer</span><span style=3D"color:#660">(</span><span =
style=3D"color:#000">value</span><span style=3D"color:#660">.</span><span s=
tyle=3D"color:#008">get</span><span style=3D"color:#660">());</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#660">}</span><span style=
=3D"color:#000"><br><br></span><span style=3D"color:#008">private</span><sp=
an style=3D"color:#660">:</span><span style=3D"color:#000"><br>=C2=A0 =C2=
=A0propagate_const</span><span style=3D"color:#660"><</span><span style=
=3D"color:#000">observer_ptr</span><span style=3D"color:#080"><<wbr>int&=
gt;</span><span style=3D"color:#660">></span><span style=3D"color:#000">=
value</span><span style=3D"color:#660">;</span><span style=3D"color:#000">=
<br></span><span style=3D"color:#660">};</span></div></code></div>...<br></=
div></div></blockquote><div><br></div><div>I see. </div><div>Too bad we'=
;ll end up yet again=C2=A0with duplicated=C2=A0const and non conts interfac=
es.</div><div><br></div><div>For instance in your case there also should be=
a=C2=A0=C2=A0</div><div><br></div><div style=3D"border:1px solid rgb(187,1=
87,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code><div>=
<font color=3D"#000000"><span style=3D"color:#000">observer_ptr</span></fon=
t><span style=3D"color:#660"><span style=3D"color:#660"><</span></span><=
span style=3D"color:#008"><span style=3D"color:#008">int</span></span><span=
style=3D"color:#000"><span style=3D"color:#000"> </span></span><span style=
=3D"color:#008"><span style=3D"color:#008">const</span></span><span style=
=3D"color:#660"><span style=3D"color:#660">></span><span style=3D"color:=
#000"> get_cvalue</span><span style=3D"color:#660">()</span><span style=3D"=
color:#000"> </span><span style=3D"color:#008">const</span><span style=3D"c=
olor:#660">;</span><span style=3D"color:#000"><br></span></span><span style=
=3D"color:#000"></span></div></code></div><div><b><br></b></div><div>Becaus=
e the user might want to get a const observer from a non-const instance of =
the container. </div><div><br></div><div><br></div><div>Or do a bit awkward=
things like </div><div><br></div><div style=3D"border:1px solid rgb(187,18=
7,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code><div><=
font color=3D"#222222"><span style=3D"color:#000">container </span><span st=
yle=3D"color:#660"><span style=3D"color:#000">c</span><span style=3D"color:=
#660">;</span></span><b><i><u><sub><sup><strike><span style=3D"color:#000">=
<br></span></strike></sup></sub></u></i></b><span style=3D"color:#008">auto=
</span><span style=3D"color:#000"> v </span><span style=3D"color:#660">=3D<=
/span><span style=3D"color:#000"> std</span><span style=3D"color:#660">::</=
span><span style=3D"color:#000">as_const</span><span style=3D"color:#660">(=
</span><span style=3D"color:#000">c</span><span style=3D"color:#660">).</sp=
an><span style=3D"color:#000">get_value</span><span style=3D"color:#660">()=
;</span></font></div></code></div><div><b><br></b></div><div>or manually sp=
ecify a different type</div><div><br></div><div style=3D"border:1px solid r=
gb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><co=
de><div><font color=3D"rgb(102,102,0)"><span style=3D"color:#000">observer_=
ptr</span><span style=3D"color:#660"><span style=3D"color:#660"><</span>=
</span><span style=3D"color:#008"><span style=3D"color:#008">int</span></sp=
an><span style=3D"color:#000"><span style=3D"color:#000"> </span></span><sp=
an style=3D"color:#008"><span style=3D"color:#008">const</span></span><span=
style=3D"color:#660"><span style=3D"color:#660">></span><span style=3D"=
color:#000"> </span></span><span style=3D"color:#000">v </span><span style=
=3D"color:#660">=3D</span><span style=3D"color:#000"> c</span><span style=
=3D"color:#660">.</span><span style=3D"color:#000">get_value</span><span st=
yle=3D"color:#660">();</span><span style=3D"color:#000"> </span></font></di=
v></code><div><br></div></div><div><br></div><div>No matter which of the 3 =
one thinks is right, the fact there so much "correct" ways is not=
a good thing.</div></div></blockquote><div><br>I think this problem is som=
ewhat orthogonal to the concerns of <span style=3D"font-family: courier new=
,monospace;">propagate_const</span>. You have made me think about this thou=
gh. It is annoying that it is necessary to duplicate code a lot of the time=
when writing const versions of things. I may start another thread to have =
this discussion.<br><br></div><blockquote class=3D"gmail_quote" style=3D"ma=
rgin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">=
<div dir=3D"ltr"><div></div><div>Your comments on the other thread really m=
ade me think, an observer ptr should be able propagate const.=C2=A0</div><d=
iv><br></div><div>This will enable the correct=C2=A0default for objects to =
be the correct default for handles-to-objects as well</div><code><div><br><=
/div><div><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-w=
ord;background-color:rgb(250,250,250)"><code><div><span style=3D"color:#008=
">const</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>auto</span><span style=3D"color:#000"> v </span><span style=3D"color:#660"=
>=3D</span><span style=3D"color:#000"> c</span><span style=3D"color:#660">.=
</span><span style=3D"color:#000">get_value</span><span style=3D"color:#660=
">();</span></div></code></div><br></div></code><div><br></div><div>Sadly, =
we can't really have that right now :(<br></div></div></blockquote><div=
><br>I am increasingly thinking that, without more fundamental changes to t=
he C++ language, const-propagation works best when kept separate from any i=
ndirection types. For example, if <span style=3D"font-family: courier new,m=
onospace;">std::shared_ptr</span> had built-in const-propagation, you would=
need a special function to allow you to copy it:<br><br>class container {<=
br>public:<br>=C2=A0=C2=A0 shared_ptr<int const> get_value() const { =
return value.copy(); }<br>=C2=A0=C2=A0 shared_ptr<int> get_value() { =
return value.copy(); }<br><br>private:<br>=C2=A0=C2=A0 shared_ptr<int>=
; value;<br>};<br><br>In addition, calls to this API would be required to u=
se this verbose copying syntax even though they aren't benefiting from =
the built-in const-propagation:<br><br>shared_ptr<int> v =3D c.get_va=
lue();<br>shared_ptr<int> w =3D v.copy(); // why the restriction; v c=
annot possibly become const!<br><br>Const-propagation only really has value=
in cases of composition, where you want to ensure that, when an object is =
only accessible via a reference to const, that the constness propagates not=
only to its data members, but also any objects those data members indirect=
ly reference. If we restrict our use of propagate_const to the data members=
of a class, then we get natural copying syntax, and callers have the flexi=
bility to do with their copies what they want.<br></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/a51760a2-b976-4ef6-9214-bba82af80b79%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a51760a2-b976-4ef6-9214-bba82af80b79=
%40isocpp.org</a>.<br />
------=_Part_2568_482402054.1477192194044--
------=_Part_2567_812068324.1477192194044--
.
Author: Jonathan Coe <jbcoe@me.com>
Date: Sun, 23 Oct 2016 11:00:28 +0100
Raw View
--94eb2c034bfc5b1edb053f855887
Content-Type: text/plain; charset=UTF-8
On 23 October 2016 at 04:09, <joseph.thomson@gmail.com> wrote:
> On Saturday, 22 October 2016 21:08:50 UTC+8, mihailn...@gmail.com wrote:
>>
>>
>>
>> On Saturday, October 22, 2016 at 1:02:43 PM UTC+3, joseph....@gmail.com
>> wrote:
>>>
>>> On Saturday, 22 October 2016 16:34:54 UTC+8, mihailn...@gmail.com wrote:
>>>>
>>>> BTW, what is your use case? Or you meant from purely correctness point
>>>> of view?
>>>>
>>>
>>> My personal use case is std::observer_ptr and the like. You can work
>>> around the limitations of propagate_const with these non-owning
>>> wrappers; it's just a bit of a hassle:
>>>
>>> class container {
>>> public:
>>> observer_ptr<int const> get_value() const { return make_observer(
>>> value.get()); }
>>> observer_ptr<int> get_value() { return make_observer(value.get()); }
>>>
>>> private:
>>> propagate_const<observer_ptr<int>> value;
>>> };
>>> ...
>>>
>>
>> I see.
>> Too bad we'll end up yet again with duplicated const and non conts
>> interfaces.
>>
>> For instance in your case there also should be a
>>
>> observer_ptr<int const> get_cvalue() const;
>>
>> Because the user might want to get a const observer from a non-const
>> instance of the container.
>>
>>
>> Or do a bit awkward things like
>>
>> container c;
>> auto v = std::as_const(c).get_value();
>>
>> or manually specify a different type
>>
>> observer_ptr<int const> v = c.get_value();
>>
>>
>> No matter which of the 3 one thinks is right, the fact there so much
>> "correct" ways is not a good thing.
>>
>
> I think this problem is somewhat orthogonal to the concerns of
> propagate_const. You have made me think about this though. It is annoying
> that it is necessary to duplicate code a lot of the time when writing const
> versions of things. I may start another thread to have this discussion.
>
> Your comments on the other thread really made me think, an observer ptr
>> should be able propagate const.
>>
>> This will enable the correct default for objects to be the correct
>> default for handles-to-objects as well
>>
>> const auto v = c.get_value();
>>
>>
>> Sadly, we can't really have that right now :(
>>
>
> I am increasingly thinking that, without more fundamental changes to the
> C++ language, const-propagation works best when kept separate from any
> indirection types. For example, if std::shared_ptr had built-in
> const-propagation, you would need a special function to allow you to copy
> it:
>
> class container {
> public:
> shared_ptr<int const> get_value() const { return value.copy(); }
> shared_ptr<int> get_value() { return value.copy(); }
>
> private:
> shared_ptr<int> value;
> };
>
> In addition, calls to this API would be required to use this verbose
> copying syntax even though they aren't benefiting from the built-in
> const-propagation:
>
> shared_ptr<int> v = c.get_value();
> shared_ptr<int> w = v.copy(); // why the restriction; v cannot possibly
> become const!
>
> Const-propagation only really has value in cases of composition, where you
> want to ensure that, when an object is only accessible via a reference to
> const, that the constness propagates not only to its data members, but also
> any objects those data members indirectly reference. If we restrict our use
> of propagate_const to the data members of a class, then we get natural
> copying syntax, and callers have the flexibility to do with their copies
> what they want.
>
> `propagate_const` can handle composition well if copies are not required
(shallow copies and const propagation do not work well together).
For composition where copying is required, we are working on
`std::indirect` which does const-propagation and deep copies.
I'll post a link once the pre-Issaquah mailing goes out.
The object relationship being modelled by a class with a shared pointer
member which is externally visible as a shared pointer (it is returned as a
shared_ptr<T> or shared_ptr<const T>) is a bit unclear to me.
> --
> 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/a51760a2-b976-4ef6-
> 9214-bba82af80b79%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a51760a2-b976-4ef6-9214-bba82af80b79%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>
--
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/CAAbBDD-ui6-Yak2E5mOj8L60Hbh61q5AhQzRG%3D0-buj7wEdedA%40mail.gmail.com.
--94eb2c034bfc5b1edb053f855887
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On 23 October 2016 at 04:09, <span dir=3D"ltr"><<a href=3D"mailto:j=
oseph.thomson@gmail.com" target=3D"_blank">joseph.thomson@gmail.com</a>>=
</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px=
0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-=
left-style:solid;padding-left:1ex"><div dir=3D"ltr"><span class=3D"gmail-">=
On Saturday, 22 October 2016 21:08:50 UTC+8, <a href=3D"mailto:mihailn...@g=
mail.com" target=3D"_blank">mihailn...@gmail.com</a> wrote:<blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;=
border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex=
"><div dir=3D"ltr"><br><br>On Saturday, October 22, 2016 at 1:02:43 PM UTC+=
3, <a>joseph....@gmail.com</a> wrote:<blockquote class=3D"gmail_quote" styl=
e=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(2=
04,204,204);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr">On S=
aturday, 22 October 2016 16:34:54 UTC+8, <a>mihailn...@gmail.com</a> wrote=
:<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border=
-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;=
padding-left:1ex"><div dir=3D"ltr">BTW, what is your use case? Or you meant=
from purely correctness point of view?</div></blockquote><div><br>My perso=
nal use case is <span style=3D"font-family:'courier new',monospace"=
>std::observer_ptr</span> and the like. You can work around the limitations=
of <span style=3D"font-family:'courier new',monospace">propagate_c=
onst</span> with these non-owning wrappers; it's just a bit of a hassle=
:<br><br><div style=3D"background-color:rgb(250,250,250);border:1px solid r=
gb(187,187,187)"><code><div><span style=3D"color:rgb(0,0,136)">class</span>=
<span style=3D"color:rgb(0,0,0)"> container </span><span style=3D"color:rgb=
(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br></span><span styl=
e=3D"color:rgb(0,0,136)">public</span><span style=3D"color:rgb(102,102,0)">=
:</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0observer_ptr</spa=
n><span style=3D"color:rgb(102,102,0)"><</span><span style=3D"color:rgb(=
0,0,136)">int</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D=
"color:rgb(0,0,136)">const</span><span style=3D"color:rgb(102,102,0)">><=
/span><span style=3D"color:rgb(0,0,0)"> get_value</span><span style=3D"colo=
r:rgb(102,102,0)">()</span><span style=3D"color:rgb(0,0,0)"> </span><span s=
tyle=3D"color:rgb(0,0,136)">const</span><span style=3D"color:rgb(0,0,0)"> <=
/span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb=
(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">return</span><span styl=
e=3D"color:rgb(0,0,0)"> make_observer</span><span style=3D"color:rgb(102,10=
2,0)">(</span><span style=3D"color:rgb(0,0,0)">value</span><span style=3D"c=
olor:rgb(102,102,0)">.</span><span style=3D"color:rgb(0,0,136)">get</span><=
span style=3D"color:rgb(102,102,0)">());</span><span style=3D"color:rgb(0,0=
,0)"> </span><span style=3D"color:rgb(102,102,0)">}</span><span style=3D"co=
lor:rgb(0,0,0)"><br>=C2=A0 =C2=A0observer_ptr</span><span style=3D"color:rg=
b(0,136,0)"><int></span><span style=3D"color:rgb(0,0,0)"> get_value</=
span><span style=3D"color:rgb(102,102,0)">()</span><span style=3D"color:rgb=
(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">{</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">return</sp=
an><span style=3D"color:rgb(0,0,0)"> make_observer</span><span style=3D"col=
or:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">value</span><sp=
an style=3D"color:rgb(102,102,0)">.</span><span style=3D"color:rgb(0,0,136)=
">get</span><span style=3D"color:rgb(102,102,0)">());</span><span style=3D"=
color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">}</span><spa=
n style=3D"color:rgb(0,0,0)"><br><br></span><span style=3D"color:rgb(0,0,13=
6)">private</span><span style=3D"color:rgb(102,102,0)">:</span><span style=
=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0propagate_const</span><span style=3D=
"color:rgb(102,102,0)"><</span><span style=3D"color:rgb(0,0,0)">observer=
_ptr</span><span style=3D"color:rgb(0,136,0)"><<wbr>int></span><span =
style=3D"color:rgb(102,102,0)">></span><span style=3D"color:rgb(0,0,0)">=
value</span><span style=3D"color:rgb(102,102,0)">;</span><span style=3D"co=
lor:rgb(0,0,0)"><br></span><span style=3D"color:rgb(102,102,0)">};</span></=
div></code></div>...<br></div></div></blockquote><div><br></div><div>I see.=
</div><div>Too bad we'll end up yet again=C2=A0with duplicated=C2=A0co=
nst and non conts interfaces.</div><div><br></div><div>For instance in your=
case there also should be a=C2=A0=C2=A0</div><div><br></div><div style=3D"=
border:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb=
(250,250,250)"><code><div><font color=3D"#000000"><span style=3D"color:rgb(=
0,0,0)">observer_ptr</span></font><span style=3D"color:rgb(102,102,0)"><spa=
n style=3D"color:rgb(102,102,0)"><</span></span><span style=3D"color:rgb=
(0,0,136)"><span style=3D"color:rgb(0,0,136)">int</span></span><span style=
=3D"color:rgb(0,0,0)"><span style=3D"color:rgb(0,0,0)"> </span></span><span=
style=3D"color:rgb(0,0,136)"><span style=3D"color:rgb(0,0,136)">const</spa=
n></span><span style=3D"color:rgb(102,102,0)"><span style=3D"color:rgb(102,=
102,0)">></span><span style=3D"color:rgb(0,0,0)"> get_cvalue</span><span=
style=3D"color:rgb(102,102,0)">()</span><span style=3D"color:rgb(0,0,0)"> =
</span><span style=3D"color:rgb(0,0,136)">const</span><span style=3D"color:=
rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br></span></span>=
<span style=3D"color:rgb(0,0,0)"></span></div></code></div><div><b><br></b>=
</div><div>Because the user might want to get a const observer from a non-c=
onst instance of the container. </div><div><br></div><div><br></div><div>Or=
do a bit awkward things like </div><div><br></div><div style=3D"border:1px=
solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,2=
50)"><code><div><font color=3D"#222222"><span style=3D"color:rgb(0,0,0)">co=
ntainer </span><span style=3D"color:rgb(102,102,0)"><span style=3D"color:rg=
b(0,0,0)">c</span><span style=3D"color:rgb(102,102,0)">;</span></span><b><i=
><u><sub><sup><strike><span style=3D"color:rgb(0,0,0)"><br></span></strike>=
</sup></sub></u></i></b><span style=3D"color:rgb(0,0,136)">auto</span><span=
style=3D"color:rgb(0,0,0)"> v </span><span style=3D"color:rgb(102,102,0)">=
=3D</span><span style=3D"color:rgb(0,0,0)"> std</span><span style=3D"color:=
rgb(102,102,0)">::</span><span style=3D"color:rgb(0,0,0)">as_const</span><s=
pan style=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)"=
>c</span><span style=3D"color:rgb(102,102,0)">).</span><span style=3D"color=
:rgb(0,0,0)">get_value</span><span style=3D"color:rgb(102,102,0)">();</span=
></font></div></code></div><div><b><br></b></div><div>or manually specify a=
different type</div><div><br></div><div style=3D"border:1px solid rgb(187,=
187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code><div=
><font color=3D"rgb(102,102,0)"><span style=3D"color:rgb(0,0,0)">observer_p=
tr</span><span style=3D"color:rgb(102,102,0)"><span style=3D"color:rgb(102,=
102,0)"><</span></span><span style=3D"color:rgb(0,0,136)"><span style=3D=
"color:rgb(0,0,136)">int</span></span><span style=3D"color:rgb(0,0,0)"><spa=
n style=3D"color:rgb(0,0,0)"> </span></span><span style=3D"color:rgb(0,0,13=
6)"><span style=3D"color:rgb(0,0,136)">const</span></span><span style=3D"co=
lor:rgb(102,102,0)"><span style=3D"color:rgb(102,102,0)">></span><span s=
tyle=3D"color:rgb(0,0,0)"> </span></span><span style=3D"color:rgb(0,0,0)">v=
</span><span style=3D"color:rgb(102,102,0)">=3D</span><span style=3D"color=
:rgb(0,0,0)"> c</span><span style=3D"color:rgb(102,102,0)">.</span><span st=
yle=3D"color:rgb(0,0,0)">get_value</span><span style=3D"color:rgb(102,102,0=
)">();</span><span style=3D"color:rgb(0,0,0)"> </span></font></div></code><=
div><br></div></div><div><br></div><div>No matter which of the 3 one thinks=
is right, the fact there so much "correct" ways is not a good th=
ing.</div></div></blockquote></span><div><br>I think this problem is somewh=
at orthogonal to the concerns of <span style=3D"font-family:'courier ne=
w',monospace">propagate_const</span>. You have made me think about this=
though. It is annoying that it is necessary to duplicate code a lot of the=
time when writing const versions of things. I may start another thread to =
have this discussion.<br><br></div><span class=3D"gmail-"><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;bo=
rder-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">=
<div dir=3D"ltr"><div></div><div>Your comments on the other thread really m=
ade me think, an observer ptr should be able propagate const.=C2=A0</div><d=
iv><br></div><div>This will enable the correct=C2=A0default for objects to =
be the correct default for handles-to-objects as well</div><code><div><br><=
/div><div><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-w=
ord;background-color:rgb(250,250,250)"><code><div><span style=3D"color:rgb(=
0,0,136)">const</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(0,0,136)">auto</span><span style=3D"color:rgb(0,0,0)"> v </sp=
an><span style=3D"color:rgb(102,102,0)">=3D</span><span style=3D"color:rgb(=
0,0,0)"> c</span><span style=3D"color:rgb(102,102,0)">.</span><span style=
=3D"color:rgb(0,0,0)">get_value</span><span style=3D"color:rgb(102,102,0)">=
();</span></div></code></div><br></div></code><div><br></div><div>Sadly, we=
can't really have that right now :(<br></div></div></blockquote></span=
><div><br>I am increasingly thinking that, without more fundamental changes=
to the C++ language, const-propagation works best when kept separate from =
any indirection types. For example, if <span style=3D"font-family:'cour=
ier new',monospace">std::shared_ptr</span> had built-in const-propagati=
on, you would need a special function to allow you to copy it:<br><br>class=
container {<br>public:<br>=C2=A0=C2=A0 shared_ptr<int const> get_val=
ue() const { return value.copy(); }<br>=C2=A0=C2=A0 shared_ptr<int> g=
et_value() { return value.copy(); }<br><br>private:<br>=C2=A0=C2=A0 shared_=
ptr<int> value;<br>};<br><br>In addition, calls to this API would be =
required to use this verbose copying syntax even though they aren't ben=
efiting from the built-in const-propagation:<br><br>shared_ptr<int> v=
=3D c.get_value();<br>shared_ptr<int> w =3D v.copy(); // why the res=
triction; v cannot possibly become const!<br><br>Const-propagation only rea=
lly has value in cases of composition, where you want to ensure that, when =
an object is only accessible via a reference to const, that the constness p=
ropagates not only to its data members, but also any objects those data mem=
bers indirectly reference. If we restrict our use of propagate_const to the=
data members of a class, then we get natural copying syntax, and callers h=
ave the flexibility to do with their copies what they want.<br></div></div>=
<span class=3D"gmail-">
<p></p>
</span></blockquote><div>`propagate_const` can handle composition well if c=
opies are not required (shallow copies and const propagation do not work we=
ll together).=C2=A0<br></div><div><br></div><div>For composition where copy=
ing is required, we are working on `std::indirect` which does const-propaga=
tion and deep copies.</div><div>I'll post a link once the pre-Issaquah =
mailing goes out.</div><div><br></div><div>The object relationship being mo=
delled by a class with a shared pointer member which is externally visible =
as a shared pointer (it is returned as a shared_ptr<T> or shared_ptr&=
lt;const T>) is a bit unclear to me.=C2=A0</div><div>=C2=A0</div><blockq=
uote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-wi=
dth:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-=
left:1ex"><span class=3D"gmail-">-- <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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a51760a2-b976-4ef6-9214-bba82af80b79%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/a517=
60a2-b976-4ef6-<wbr>9214-bba82af80b79%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/CAAbBDD-ui6-Yak2E5mOj8L60Hbh61q5AhQzR=
G%3D0-buj7wEdedA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAAbBDD-ui6-Yak=
2E5mOj8L60Hbh61q5AhQzRG%3D0-buj7wEdedA%40mail.gmail.com</a>.<br />
--94eb2c034bfc5b1edb053f855887--
.
Author: mihailnajdenov@gmail.com
Date: Sun, 23 Oct 2016 03:12:00 -0700 (PDT)
Raw View
------=_Part_900_55946508.1477217520702
Content-Type: multipart/alternative;
boundary="----=_Part_901_1734623081.1477217520702"
------=_Part_901_1734623081.1477217520702
Content-Type: text/plain; charset=UTF-8
On Sunday, October 23, 2016 at 6:09:54 AM UTC+3, joseph....@gmail.com wrote:
>
> On Saturday, 22 October 2016 21:08:50 UTC+8, mihailn...@gmail.com wrote:
>>
>> ...
>>
>> Const-propagation only really has value in cases of composition, where
>> you want to ensure that, when an object is only accessible via a reference
>> to const, that the constness propagates not only to its data members, but
>> also any objects those data members indirectly reference. If we restrict
>> our use of propagate_const to the data members of a class, then we get
>> natural copying syntax, and callers have the flexibility to do with their
>> copies what they want.
>>
>
Even if we restrict it to members only, the facts it forbids copy,
kills "natural copying syntax" - one will have to write a copy ctor and
assignment op, fiddling with get_underlying and what not.
struct S
{
propagate_const<shared_ptr<int>> p;
};
VS
struct S
{
S() = default;
S(S&&) = default;
S& operator=(S&&) = default;
S(const S& o) : _p(get_underlying(o._p)) {}
S& operator=(const S& o) { if(&o != this) { _p = get_underlying(o._p); }
return *this; };
propagate_const<shared_ptr<int>> _p;
};
And this is just for a single propagator! I reckon this is hard to teach
and reserved to non-junior programmers.
And of course, assignment const on non-const is possible.
Basically propagate_const will work correctly only if there is a deep copy
or probably copy on write.
--
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/bebb500d-5b71-48e5-8878-0e5fae129c41%40isocpp.org.
------=_Part_901_1734623081.1477217520702
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Sunday, October 23, 2016 at 6:09:54 AM UTC+3, j=
oseph....@gmail.com 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">On Saturday, 22 October 2016 21:08:50 UTC+8, <a>mihailn...@gma=
il.com</a> wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margi=
n-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">=
....<br><br>Const-propagation only really has value in cases of composition,=
where you want to ensure that, when an object is only accessible via a ref=
erence to const, that the constness propagates not only to its data members=
, but also any objects those data members indirectly reference. If we restr=
ict our use of propagate_const to the data members of a class, then we get =
natural copying syntax, and callers have the flexibility to do with their c=
opies what they want.<br></div></blockquote></div></blockquote><div><br></d=
iv><div>Even if we restrict it to members only, the facts it forbids copy, =
kills=C2=A0"natural copying syntax" - one will have to write a co=
py ctor and assignment op, fiddling with get_underlying and what not. </div=
><div><br></div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(1=
87, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);=
"><code class=3D"prettyprint"><div class=3D"subprettyprint"><font color=3D"=
rgb(0,0,0)"><span class=3D"styled-by-prettify" style=3D"color: #008;">struc=
t</span><span class=3D"styled-by-prettify" style=3D"color: #000;"> S<br></s=
pan><span class=3D"styled-by-prettify" style=3D"color: #660;">{</span><span=
class=3D"styled-by-prettify" style=3D"color: #000;"><br>=C2=A0propagate_co=
nst</span><span style=3D"color:#660"><span class=3D"styled-by-prettify" sty=
le=3D"color: #660;"><</span></span><span style=3D"color:#000"><span clas=
s=3D"styled-by-prettify" style=3D"color: #000;">shared_ptr</span></span><sp=
an style=3D"color:#080"><span class=3D"styled-by-prettify" style=3D"color: =
#080;"><</span><wbr><span class=3D"styled-by-prettify" style=3D"color: #=
080;">int></span></span><span style=3D"color:#660"><span class=3D"styled=
-by-prettify" style=3D"color: #660;">></span></span><span style=3D"color=
:#000"><span class=3D"styled-by-prettify" style=3D"color: #000;"> p</span><=
span class=3D"styled-by-prettify" style=3D"color: #660;">;</span></span><sp=
an style=3D"color:#660"></span><span class=3D"styled-by-prettify" style=3D"=
color: #000;"><br></span><span class=3D"styled-by-prettify" style=3D"color:=
#660;">};</span><span class=3D"styled-by-prettify" style=3D"color: #000;">=
<br></span></font></div></code></div><div><font color=3D"rgb(0,0,0)"><br></=
font></div><div>VS</div><div><br></div><div><div class=3D"prettyprint" styl=
e=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; backgroun=
d-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"sub=
prettyprint"><font color=3D"rgb(0,0,0)"><span class=3D"styled-by-prettify" =
style=3D"color: #008;"><font color=3D"rgb(0,0,0)">struct S<br>{<br>=C2=A0S(=
) =3D default;<br>=C2=A0S(S&&) =3D default;<br>=C2=A0S& operato=
r=3D(S&&) =3D default;<br>=C2=A0S(const S& o) : _p(get_underlyi=
ng(o._p)) {}<br>=C2=A0S& operator=3D(const S& o) { if(&o !=3D t=
his) { _p =3D get_underlying(o._p); } return *this; };</font></span></font>=
</div><div><br></div><div class=3D"subprettyprint"><font color=3D"rgb(0,0,0=
)"><span class=3D"styled-by-prettify" style=3D"color: #008;"><font color=3D=
"rgb(0,0,0)">=C2=A0propagate_const<shared_ptr<int>> _p;<br>};</=
font></span><span class=3D"styled-by-prettify" style=3D"color: #000;"><br><=
/span></font></div></code></div><font color=3D"rgb(0,0,0)"></font><br></div=
><div>And this is just for a single propagator! I reckon this is hard to te=
ach and reserved to non-junior programmers.</div><div><br></div><div>And of=
course, assignment const on non-const is possible.</div><div>Basically <fo=
nt color=3D"#000000">propagate_const will work correctly only if there is a=
deep copy or probably copy on write. </font><br></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/bebb500d-5b71-48e5-8878-0e5fae129c41%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/bebb500d-5b71-48e5-8878-0e5fae129c41=
%40isocpp.org</a>.<br />
------=_Part_901_1734623081.1477217520702--
------=_Part_900_55946508.1477217520702--
.
Author: joseph.thomson@gmail.com
Date: Sun, 23 Oct 2016 04:24:37 -0700 (PDT)
Raw View
------=_Part_2969_1458986395.1477221877646
Content-Type: multipart/alternative;
boundary="----=_Part_2970_1391305396.1477221877647"
------=_Part_2970_1391305396.1477221877647
Content-Type: text/plain; charset=UTF-8
On Sunday, 23 October 2016 18:00:30 UTC+8, Jonathan Coe wrote:
>
>
>
> On 23 October 2016 at 04:09, <joseph....@gmail.com <javascript:>> wrote:
>
>> On Saturday, 22 October 2016 21:08:50 UTC+8, mihailn...@gmail.com wrote:
>>>
>>>
>>>
>>> On Saturday, October 22, 2016 at 1:02:43 PM UTC+3, joseph....@gmail.com
>>> wrote:
>>>>
>>>> On Saturday, 22 October 2016 16:34:54 UTC+8, mihailn...@gmail.com
>>>> wrote:
>>>>>
>>>>> BTW, what is your use case? Or you meant from purely correctness point
>>>>> of view?
>>>>>
>>>>
>>>> My personal use case is std::observer_ptr and the like. You can work
>>>> around the limitations of propagate_const with these non-owning
>>>> wrappers; it's just a bit of a hassle:
>>>>
>>>> class container {
>>>> public:
>>>> observer_ptr<int const> get_value() const { return make_observer(
>>>> value.get()); }
>>>> observer_ptr<int> get_value() { return make_observer(value.get()); }
>>>>
>>>> private:
>>>> propagate_const<observer_ptr<int>> value;
>>>> };
>>>> ...
>>>>
>>>
>>> I see.
>>> Too bad we'll end up yet again with duplicated const and non conts
>>> interfaces.
>>>
>>> For instance in your case there also should be a
>>>
>>> observer_ptr<int const> get_cvalue() const;
>>>
>>> Because the user might want to get a const observer from a non-const
>>> instance of the container.
>>>
>>>
>>> Or do a bit awkward things like
>>>
>>> container c;
>>> auto v = std::as_const(c).get_value();
>>>
>>> or manually specify a different type
>>>
>>> observer_ptr<int const> v = c.get_value();
>>>
>>>
>>> No matter which of the 3 one thinks is right, the fact there so much
>>> "correct" ways is not a good thing.
>>>
>>
>> I think this problem is somewhat orthogonal to the concerns of
>> propagate_const. You have made me think about this though. It is
>> annoying that it is necessary to duplicate code a lot of the time when
>> writing const versions of things. I may start another thread to have this
>> discussion.
>>
>> Your comments on the other thread really made me think, an observer ptr
>>> should be able propagate const.
>>>
>>> This will enable the correct default for objects to be the correct
>>> default for handles-to-objects as well
>>>
>>> const auto v = c.get_value();
>>>
>>>
>>> Sadly, we can't really have that right now :(
>>>
>>
>> I am increasingly thinking that, without more fundamental changes to the
>> C++ language, const-propagation works best when kept separate from any
>> indirection types. For example, if std::shared_ptr had built-in
>> const-propagation, you would need a special function to allow you to copy
>> it:
>>
>> class container {
>> public:
>> shared_ptr<int const> get_value() const { return value.copy(); }
>> shared_ptr<int> get_value() { return value.copy(); }
>>
>> private:
>> shared_ptr<int> value;
>> };
>>
>> In addition, calls to this API would be required to use this verbose
>> copying syntax even though they aren't benefiting from the built-in
>> const-propagation:
>>
>> shared_ptr<int> v = c.get_value();
>> shared_ptr<int> w = v.copy(); // why the restriction; v cannot possibly
>> become const!
>>
>> Const-propagation only really has value in cases of composition, where
>> you want to ensure that, when an object is only accessible via a reference
>> to const, that the constness propagates not only to its data members, but
>> also any objects those data members indirectly reference. If we restrict
>> our use of propagate_const to the data members of a class, then we get
>> natural copying syntax, and callers have the flexibility to do with their
>> copies what they want.
>>
>> `propagate_const` can handle composition well if copies are not required
> (shallow copies and const propagation do not work well together).
>
> For composition where copying is required, we are working on
> `std::indirect` which does const-propagation and deep copies.
> I'll post a link once the pre-Issaquah mailing goes out.
>
Look forward to it. I can't readily imagine what such a function/class
would do.
> The object relationship being modelled by a class with a shared pointer
> member which is externally visible as a shared pointer (it is returned as a
> shared_ptr<T> or shared_ptr<const T>) is a bit unclear to me.
>
If it's possible, you can be sure that someone, somewhere will want to do
it. And they might even have good reason to do so :)
--
>> You received this message because you are subscribed to the Google Groups
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a51760a2-b976-4ef6-9214-bba82af80b79%40isocpp.org
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a51760a2-b976-4ef6-9214-bba82af80b79%40isocpp.org?utm_medium=email&utm_source=footer>
>> .
>>
>
>
--
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/d568c662-8912-45f4-af39-979cc559c1ae%40isocpp.org.
------=_Part_2970_1391305396.1477221877647
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Sunday, 23 October 2016 18:00:30 UTC+8, Jonatha=
n Coe wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
<br><div><br><div class=3D"gmail_quote">On 23 October 2016 at 04:09, <span=
dir=3D"ltr"><<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-m=
ailto=3D"LUQhGaZ9AAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'jav=
ascript:';return true;" onclick=3D"this.href=3D'javascript:';re=
turn true;">joseph....@gmail.com</a>></span> wrote:<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;bo=
rder-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">=
<div dir=3D"ltr"><span>On Saturday, 22 October 2016 21:08:50 UTC+8, <a>miha=
iln...@gmail.com</a> wrote:<blockquote class=3D"gmail_quote" style=3D"marg=
in:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,20=
4);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr"><br><br>On Sa=
turday, October 22, 2016 at 1:02:43 PM UTC+3, <a>joseph....@gmail.com</a> w=
rote:<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bo=
rder-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:so=
lid;padding-left:1ex"><div dir=3D"ltr">On Saturday, 22 October 2016 16:34:5=
4 UTC+8, <a>mihailn...@gmail.com</a> wrote:<blockquote class=3D"gmail_quot=
e" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-colo=
r:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir=3D"lt=
r">BTW, what is your use case? Or you meant from purely correctness point o=
f view?</div></blockquote><div><br>My personal use case is <span style=3D"f=
ont-family:'courier new',monospace">std::observer_ptr</span> and th=
e like. You can work around the limitations of <span style=3D"font-family:&=
#39;courier new',monospace">propagate_const</span> with these non-ownin=
g wrappers; it's just a bit of a hassle:<br><br><div style=3D"backgroun=
d-color:rgb(250,250,250);border:1px solid rgb(187,187,187)"><code><div><spa=
n style=3D"color:rgb(0,0,136)">class</span><span style=3D"color:rgb(0,0,0)"=
> container </span><span style=3D"color:rgb(102,102,0)">{</span><span style=
=3D"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(0,0,136)">public<=
/span><span style=3D"color:rgb(102,102,0)">:</span><span style=3D"color:rgb=
(0,0,0)"><br>=C2=A0 =C2=A0observer_ptr</span><span style=3D"color:rgb(102,1=
02,0)"><</span><span style=3D"color:rgb(0,0,136)">int</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">const</spa=
n><span style=3D"color:rgb(102,102,0)">></span><span style=3D"color:rgb(=
0,0,0)"> get_value</span><span style=3D"color:rgb(102,102,0)">()</span><spa=
n style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">con=
st</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(=
102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D=
"color:rgb(0,0,136)">return</span><span style=3D"color:rgb(0,0,0)"> make_ob=
server</span><span style=3D"color:rgb(102,102,0)">(</span><span style=3D"co=
lor:rgb(0,0,0)">value</span><span style=3D"color:rgb(102,102,0)">.</span><s=
pan style=3D"color:rgb(0,0,136)">get</span><span style=3D"color:rgb(102,102=
,0)">());</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"col=
or:rgb(102,102,0)">}</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=
=A0observer_ptr</span><span style=3D"color:rgb(0,136,0)"><int></span>=
<span style=3D"color:rgb(0,0,0)"> get_value</span><span style=3D"color:rgb(=
102,102,0)">()</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"> </span>=
<span style=3D"color:rgb(0,0,136)">return</span><span style=3D"color:rgb(0,=
0,0)"> make_observer</span><span style=3D"color:rgb(102,102,0)">(</span><sp=
an style=3D"color:rgb(0,0,0)">value</span><span style=3D"color:rgb(102,102,=
0)">.</span><span style=3D"color:rgb(0,0,136)">get</span><span style=3D"col=
or:rgb(102,102,0)">());</span><span style=3D"color:rgb(0,0,0)"> </span><spa=
n style=3D"color:rgb(102,102,0)">}</span><span style=3D"color:rgb(0,0,0)"><=
br><br></span><span style=3D"color:rgb(0,0,136)">private</span><span style=
=3D"color:rgb(102,102,0)">:</span><span style=3D"color:rgb(0,0,0)"><br>=C2=
=A0 =C2=A0propagate_const</span><span style=3D"color:rgb(102,102,0)"><</=
span><span style=3D"color:rgb(0,0,0)">observer_ptr</span><span style=3D"col=
or:rgb(0,136,0)"><<wbr>int></span><span style=3D"color:rgb(102,102,0)=
">></span><span style=3D"color:rgb(0,0,0)"> value</span><span style=3D"c=
olor:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br></span><s=
pan style=3D"color:rgb(102,102,0)">};</span></div></code></div>...<br></div=
></div></blockquote><div><br></div><div>I see. </div><div>Too bad we'll=
end up yet again=C2=A0with duplicated=C2=A0const and non conts interfaces.=
</div><div><br></div><div>For instance in your case there also should be a=
=C2=A0=C2=A0</div><div><br></div><div style=3D"border:1px solid rgb(187,187=
,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code><div><f=
ont color=3D"#000000"><span style=3D"color:rgb(0,0,0)">observer_ptr</span><=
/font><span style=3D"color:rgb(102,102,0)"><span style=3D"color:rgb(102,102=
,0)"><</span></span><span style=3D"color:rgb(0,0,136)"><span style=3D"co=
lor:rgb(0,0,136)">int</span></span><span style=3D"color:rgb(0,0,0)"><span s=
tyle=3D"color:rgb(0,0,0)"> </span></span><span style=3D"color:rgb(0,0,136)"=
><span style=3D"color:rgb(0,0,136)">const</span></span><span style=3D"color=
:rgb(102,102,0)"><span style=3D"color:rgb(102,102,0)">></span><span styl=
e=3D"color:rgb(0,0,0)"> get_cvalue</span><span style=3D"color:rgb(102,102,0=
)">()</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:r=
gb(0,0,136)">const</span><span style=3D"color:rgb(102,102,0)">;</span><span=
style=3D"color:rgb(0,0,0)"><br></span></span><span style=3D"color:rgb(0,0,=
0)"></span></div></code></div><div><b><br></b></div><div>Because the user m=
ight want to get a const observer from a non-const instance of the containe=
r. </div><div><br></div><div><br></div><div>Or do a bit awkward things like=
</div><div><br></div><div style=3D"border:1px solid rgb(187,187,187);word-=
wrap:break-word;background-color:rgb(250,250,250)"><code><div><font color=
=3D"#222222"><span style=3D"color:rgb(0,0,0)">container </span><span style=
=3D"color:rgb(102,102,0)"><span style=3D"color:rgb(0,0,0)">c</span><span st=
yle=3D"color:rgb(102,102,0)">;</span></span><b><i><u><sub><sup><strike><spa=
n style=3D"color:rgb(0,0,0)"><br></span></strike></sup></sub></u></i></b><s=
pan style=3D"color:rgb(0,0,136)">auto</span><span style=3D"color:rgb(0,0,0)=
"> v </span><span style=3D"color:rgb(102,102,0)">=3D</span><span style=3D"c=
olor:rgb(0,0,0)"> std</span><span style=3D"color:rgb(102,102,0)">::</span><=
span style=3D"color:rgb(0,0,0)">as_const</span><span style=3D"color:rgb(102=
,102,0)">(</span><span style=3D"color:rgb(0,0,0)">c</span><span style=3D"co=
lor:rgb(102,102,0)">).</span><span style=3D"color:rgb(0,0,0)">get_value</sp=
an><span style=3D"color:rgb(102,102,0)">();</span></font></div></code></div=
><div><b><br></b></div><div>or manually specify a different type</div><div>=
<br></div><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-w=
ord;background-color:rgb(250,250,250)"><code><div><font color=3D"rgb(102,10=
2,0)"><span style=3D"color:rgb(0,0,0)">observer_ptr</span><span style=3D"co=
lor:rgb(102,102,0)"><span style=3D"color:rgb(102,102,0)"><</span></span>=
<span style=3D"color:rgb(0,0,136)"><span style=3D"color:rgb(0,0,136)">int</=
span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:rgb(0,0,0=
)"> </span></span><span style=3D"color:rgb(0,0,136)"><span style=3D"color:r=
gb(0,0,136)">const</span></span><span style=3D"color:rgb(102,102,0)"><span =
style=3D"color:rgb(102,102,0)">></span><span style=3D"color:rgb(0,0,0)">=
</span></span><span style=3D"color:rgb(0,0,0)">v </span><span style=3D"col=
or:rgb(102,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> c</span><spa=
n style=3D"color:rgb(102,102,0)">.</span><span style=3D"color:rgb(0,0,0)">g=
et_value</span><span style=3D"color:rgb(102,102,0)">();</span><span style=
=3D"color:rgb(0,0,0)"> </span></font></div></code><div><br></div></div><div=
><br></div><div>No matter which of the 3 one thinks is right, the fact ther=
e so much "correct" ways is not a good thing.</div></div></blockq=
uote></span><div><br>I think this problem is somewhat orthogonal to the con=
cerns of <span style=3D"font-family:'courier new',monospace">propag=
ate_const</span>. You have made me think about this though. It is annoying =
that it is necessary to duplicate code a lot of the time when writing const=
versions of things. I may start another thread to have this discussion.<br=
><br></div><span><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px =
0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-l=
eft-style:solid;padding-left:1ex"><div dir=3D"ltr"><div></div><div>Your com=
ments on the other thread really made me think, an observer ptr should be a=
ble propagate const.=C2=A0</div><div><br></div><div>This will enable the co=
rrect=C2=A0default for objects to be the correct default for handles-to-obj=
ects as well</div><code><div><br></div><div><div style=3D"border:1px solid =
rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><c=
ode><div><span style=3D"color:rgb(0,0,136)">const</span><span style=3D"colo=
r:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">auto</span><span s=
tyle=3D"color:rgb(0,0,0)"> v </span><span style=3D"color:rgb(102,102,0)">=
=3D</span><span style=3D"color:rgb(0,0,0)"> c</span><span style=3D"color:rg=
b(102,102,0)">.</span><span style=3D"color:rgb(0,0,0)">get_value</span><spa=
n style=3D"color:rgb(102,102,0)">();</span></div></code></div><br></div></c=
ode><div><br></div><div>Sadly, we can't really have that right now :(<b=
r></div></div></blockquote></span><div><br>I am increasingly thinking that,=
without more fundamental changes to the C++ language, const-propagation wo=
rks best when kept separate from any indirection types. For example, if <sp=
an style=3D"font-family:'courier new',monospace">std::shared_ptr</s=
pan> had built-in const-propagation, you would need a special function to a=
llow you to copy it:<br><br>class container {<br>public:<br>=C2=A0=C2=A0 sh=
ared_ptr<int const> get_value() const { return value.copy(); }<br>=C2=
=A0=C2=A0 shared_ptr<int> get_value() { return value.copy(); }<br><br=
>private:<br>=C2=A0=C2=A0 shared_ptr<int> value;<br>};<br><br>In addi=
tion, calls to this API would be required to use this verbose copying synta=
x even though they aren't benefiting from the built-in const-propagatio=
n:<br><br>shared_ptr<int> v =3D c.get_value();<br>shared_ptr<int&g=
t; w =3D v.copy(); // why the restriction; v cannot possibly become const!<=
br><br>Const-propagation only really has value in cases of composition, whe=
re you want to ensure that, when an object is only accessible via a referen=
ce to const, that the constness propagates not only to its data members, bu=
t also any objects those data members indirectly reference. If we restrict =
our use of propagate_const to the data members of a class, then we get natu=
ral copying syntax, and callers have the flexibility to do with their copie=
s what they want.<br></div></div><span>
<p></p>
</span></blockquote><div>`propagate_const` can handle composition well if c=
opies are not required (shallow copies and const propagation do not work we=
ll together).=C2=A0<br></div><div><br></div><div>For composition where copy=
ing is required, we are working on `std::indirect` which does const-propaga=
tion and deep copies.</div><div>I'll post a link once the pre-Issaquah =
mailing goes out.</div></div></div></div></blockquote><div><br>Look forward=
to it. I can't readily imagine what such a function/class would do.<br=
>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
<div><div class=3D"gmail_quote"><div></div><div>The object relationship bei=
ng modelled by a class with a shared pointer member which is externally vis=
ible as a shared pointer (it is returned as a shared_ptr<T> or shared=
_ptr<const T>) is a bit unclear to me.=C2=A0</div></div></div></div><=
/blockquote><div><br>If it's possible, you can be sure that someone, so=
mewhere will want to do it. And they might even have good reason to do so :=
)<br><br></div><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=
"><div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(20=
4,204,204);border-left-style:solid;padding-left:1ex"><span>-- <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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
LUQhGaZ9AAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:&=
#39;;return true;" onclick=3D"this.href=3D'javascript:';return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"LUQhGaZ9AAAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'=
;javascript:';return true;">std-pr...@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a51760a2-b976-4ef6-9214-bba82af80b79%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D'https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/a51760a2-b976-4ef6-9214-bba82af80b79%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter';return true;" on=
click=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/a51760a2-b976-4ef6-9214-bba82af80b79%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter';return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/a51760a2-b976-4ef6-<wbr>9214-=
bba82af80b79%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></div></div>
</blockquote></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/d568c662-8912-45f4-af39-979cc559c1ae%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d568c662-8912-45f4-af39-979cc559c1ae=
%40isocpp.org</a>.<br />
------=_Part_2970_1391305396.1477221877647--
------=_Part_2969_1458986395.1477221877646--
.
Author: joseph.thomson@gmail.com
Date: Sun, 23 Oct 2016 06:59:57 -0700 (PDT)
Raw View
------=_Part_346_1470453046.1477231197266
Content-Type: multipart/alternative;
boundary="----=_Part_347_321216756.1477231197266"
------=_Part_347_321216756.1477231197266
Content-Type: text/plain; charset=UTF-8
On Sunday, 23 October 2016 18:12:00 UTC+8, mihailn...@gmail.com wrote:
>
>
>
> On Sunday, October 23, 2016 at 6:09:54 AM UTC+3, joseph....@gmail.com
> wrote:
>>
>> On Saturday, 22 October 2016 21:08:50 UTC+8, mihailn...@gmail.com wrote:
>>>
>>> ...
>>>
>>> Const-propagation only really has value in cases of composition, where
>>> you want to ensure that, when an object is only accessible via a reference
>>> to const, that the constness propagates not only to its data members, but
>>> also any objects those data members indirectly reference. If we restrict
>>> our use of propagate_const to the data members of a class, then we get
>>> natural copying syntax, and callers have the flexibility to do with their
>>> copies what they want.
>>>
>>
> Even if we restrict it to members only, the facts it forbids copy,
> kills "natural copying syntax" - one will have to write a copy ctor and
> assignment op, fiddling with get_underlying and what not.
>
> struct S
> {
> propagate_const<shared_ptr<int>> p;
> };
>
> VS
>
> struct S
> {
> S() = default;
> S(S&&) = default;
> S& operator=(S&&) = default;
> S(const S& o) : _p(get_underlying(o._p)) {}
> S& operator=(const S& o) { if(&o != this) { _p = get_underlying(o._p); }
> return *this; };
>
> propagate_const<shared_ptr<int>> _p;
> };
>
> And this is just for a single propagator! I reckon this is hard to teach
> and reserved to non-junior programmers.
>
> And of course, assignment const on non-const is possible.
> Basically propagate_const will work correctly only if there is a deep
> copy or probably copy on write.
>
The fact that you need to call get_underlying shows that you are breaking
the restrictions imposed by propagate_const. If propagate_const were
implicitly convertible to T, you *could* implement the non-const copy
constructor and assignment operator with no problem. But as stated, they
wouldn't work too well with the existing C++ language and library features.
container(container& other) :
value(other.value) {
}
container& operator=(container& other) {
value = other.value;
return *this;
}
Deep copying wouldn't be a problem. I'm just having a hard time figuring
out what exactly a deep-copying indirect type would do or how it would be
useful. I guess I'll have to wait for the details of this std::indirect.
--
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/5c682d18-9cf2-4a80-9e58-6b8fae2cf7e8%40isocpp.org.
------=_Part_347_321216756.1477231197266
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Sunday, 23 October 2016 18:12:00 UTC+8, mihailn...@gmai=
l.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
<br><br>On Sunday, October 23, 2016 at 6:09:54 AM UTC+3, <a>joseph....@gmai=
l.com</a> 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">On=
Saturday, 22 October 2016 21:08:50 UTC+8, <a>mihailn...@gmail.com</a> wro=
te:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">...<br><br>Cons=
t-propagation only really has value in cases of composition, where you want=
to ensure that, when an object is only accessible via a reference to const=
, that the constness propagates not only to its data members, but also any =
objects those data members indirectly reference. If we restrict our use of =
propagate_const to the data members of a class, then we get natural copying=
syntax, and callers have the flexibility to do with their copies what they=
want.<br></div></blockquote></div></blockquote><div><br></div><div>Even if=
we restrict it to members only, the facts it forbids copy, kills=C2=A0&quo=
t;natural copying syntax" - one will have to write a copy ctor and ass=
ignment op, fiddling with get_underlying and what not. </div><div><br></div=
><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;backg=
round-color:rgb(250,250,250)"><code><div><font color=3D"rgb(0,0,0)"><span s=
tyle=3D"color:#008">struct</span><span style=3D"color:#000"> S<br></span><s=
pan style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0propa=
gate_const</span><span style=3D"color:#660"><span style=3D"color:#660"><=
</span></span><span style=3D"color:#000"><span style=3D"color:#000">shared_=
ptr</span></span><span style=3D"color:#080"><span style=3D"color:#080"><=
</span><span style=3D"color:#080">in<wbr>t></span></span><span style=3D"=
color:#660"><span style=3D"color:#660">></span></span><span style=3D"col=
or:#000"><span style=3D"color:#000"> p</span><span style=3D"color:#660">;</=
span></span><span style=3D"color:#660"></span><span style=3D"color:#000"><b=
r></span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br=
></span></font></div></code></div><div><font color=3D"rgb(0,0,0)"><br></fon=
t></div><div>VS</div><div><br></div><div><div style=3D"border:1px solid rgb=
(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code=
><div><font color=3D"rgb(0,0,0)"><span style=3D"color:#008"><font color=3D"=
rgb(0,0,0)">struct S<br>{<br>=C2=A0S() =3D default;<br>=C2=A0S(S&&)=
=3D default;<br>=C2=A0S& operator=3D(S&&) =3D default;<br>=C2=
=A0S(const S& o) : _p(get_underlying(o._p)) {}<br>=C2=A0S& operator=
=3D(const S& o) { if(&o !=3D this) { _p =3D get_underlying(o._p); }=
return *this; };</font></span></font></div><div><br></div><div><font color=
=3D"rgb(0,0,0)"><span style=3D"color:#008"><font color=3D"rgb(0,0,0)">=C2=
=A0propagate_const<shared_ptr<<wbr>int>> _p;<br>};</font></span=
><span style=3D"color:#000"><br></span></font></div></code></div><font colo=
r=3D"rgb(0,0,0)"></font><br></div><div>And this is just for a single propag=
ator! I reckon this is hard to teach and reserved to non-junior programmers=
..</div><div><br></div><div>And of course, assignment const on non-const is =
possible.</div><div>Basically <font color=3D"#000000">propagate_const will =
work correctly only if there is a deep copy or probably copy on write. </fo=
nt></div></div></blockquote><div><br>The fact that you need to call <span s=
tyle=3D"font-family: courier new,monospace;">get_underlying</span> shows th=
at you are breaking the restrictions imposed by <span style=3D"font-family:=
courier new,monospace;">propagate_const</span>. If <span style=3D"font-fam=
ily: courier new,monospace;">propagate_const</span> were implicitly convert=
ible to <span style=3D"font-family: courier new,monospace;">T</span>, you <=
i>could</i> implement the non-const copy constructor and assignment operato=
r with no problem. But as stated, they wouldn't work too well with the =
existing C++ language and library features.<br><br><div style=3D"background=
-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style:=
solid; border-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint=
"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"=
color: #000;" class=3D"styled-by-prettify">=C2=A0 container</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">container</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">&</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> other</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br>=C2=A0 =C2=A0 value</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">other</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">value</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</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"><br>=C2=A0 </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br>=C2=A0 container</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: #008;" cla=
ss=3D"styled-by-prettify">operator</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D(</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">container</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> other</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: #660;" class=3D"styled-by-prettify">{</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 v=
alue </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> other</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">value</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">*</span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">this</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>=C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br></span></div></code></div><br>Deep copying wouldn't be a problem.=
I'm just having a hard time figuring out what exactly a deep-copying i=
ndirect type would do or how it would be useful. I guess I'll have to w=
ait for the details of this <span style=3D"font-family: courier new,monospa=
ce;">std::indirect</span>.<br></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/5c682d18-9cf2-4a80-9e58-6b8fae2cf7e8%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/5c682d18-9cf2-4a80-9e58-6b8fae2cf7e8=
%40isocpp.org</a>.<br />
------=_Part_347_321216756.1477231197266--
------=_Part_346_1470453046.1477231197266--
.
Author: mihailnajdenov@gmail.com
Date: Sun, 23 Oct 2016 08:59:58 -0700 (PDT)
Raw View
------=_Part_954_767909723.1477238398818
Content-Type: multipart/alternative;
boundary="----=_Part_955_4426408.1477238398818"
------=_Part_955_4426408.1477238398818
Content-Type: text/plain; charset=UTF-8
On Sunday, October 23, 2016 at 4:59:57 PM UTC+3, joseph....@gmail.com wrote:
>
> ...
> Deep copying wouldn't be a problem. I'm just having a hard time figuring
> out what exactly a deep-copying indirect type would do or how it would be
> useful. I guess I'll have to wait for the details of this std::indirect.
>
I meant, if the copy ctor and assign do a deep copy propagate_const is all
you need, no downsides - new data + new propagate_const instance.
struct S
{
S() : _p(std::make_unique<X>()) {}
S(S&&) = default;
S& operator=(S&&) = default;
S(const S& o) : _p(std::make_unique<X>(*o._p)) {}
S& operator=(const S& o) { if(&o != this) { _p =
std::make_unique<X>(*o._p); } return *this; };
propagate_const<std::unique_ptr<X>> _p;
};
In this scenario propagate_const will behave completely correct.
In the shared_ptr scenario, copy-on-write is the only way to make the
"casting-const" copying safe, Qt style.
So, no-copy, or deep-copy are the only two ways to use propagate_const in
composition in another object.
One might argue, these are *the only ways* to do any const propagation in
general, at least without some magic language support.
--
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/c431c094-9a24-481f-aaea-e66950a7ccb9%40isocpp.org.
------=_Part_955_4426408.1477238398818
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Sunday, October 23, 2016 at 4:59:57 PM UTC+3, j=
oseph....@gmail.com 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"><div>...<br>Deep copying wouldn't be a problem. I'm ju=
st having a hard time figuring out what exactly a deep-copying indirect typ=
e would do or how it would be useful. I guess I'll have to wait for the=
details of this <span style=3D"font-family:courier new,monospace">std::ind=
irect</span>.<br></div></div></blockquote><div><br></div><div>I meant, if t=
he copy ctor and assign do a=C2=A0=C2=A0deep copy <span style=3D"font-famil=
y:courier new,monospace">propagate_const</span> is all you need, no downsid=
es=C2=A0- new data + new propagate_const instance<span style=3D"font-family=
:courier new,monospace">.</span></div><div><span style=3D"font-family:couri=
er new,monospace"><br></span></div><span style=3D"font-family:courier new,m=
onospace"><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 18=
7, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><cod=
e class=3D"prettyprint"><div class=3D"subprettyprint"><span class=3D"styled=
-by-prettify" style=3D"color: #606;"><font color=3D"rgb(34,34,34)" style=3D=
"background-color: transparent;">struct S<br>{<br>=C2=A0S() : _p(std::make_=
unique<X>()) {}<br>=C2=A0S(S&&) =3D default;<br>=C2=A0S& =
operator=3D(S&&) =3D default;<br>=C2=A0S(const S& o) : _p(std::=
make_unique<X>(*o._p)) {}<br>=C2=A0S& operator=3D(const S& o)=
{ if(&o !=3D this) { _p =3D std::make_unique<X>(*o._p); } return=
*this; };</font></span></div><div><br></div><div class=3D"subprettyprint">=
<span class=3D"styled-by-prettify" style=3D"color: #606;"><font color=3D"rg=
b(34,34,34)" style=3D"background-color: transparent;">=C2=A0propagate_const=
<std::unique_ptr<X>> _p;<br>};</font></span><span class=3D"styl=
ed-by-prettify" style=3D"color: #660;"></span></div></code></div><div><br><=
/div><div>In this scenario propagate_const will behave completely=C2=A0corr=
ect. </div><div><br></div><div>In the shared_ptr scenario, copy-on-write is=
the only way to make the "casting-const" copying safe, Qt style.=
</div><div><br></div><div>So, no-copy, or deep-copy are the only two ways =
to use propagate_const in composition=C2=A0in another object. </div><div>On=
e might argue, these are <b>the only ways</b> to do any const propagation i=
n general, at least without some=C2=A0magic language support.=C2=A0</div><d=
iv><br></div><div><br></div></span></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/c431c094-9a24-481f-aaea-e66950a7ccb9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/c431c094-9a24-481f-aaea-e66950a7ccb9=
%40isocpp.org</a>.<br />
------=_Part_955_4426408.1477238398818--
------=_Part_954_767909723.1477238398818--
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Sun, 23 Oct 2016 12:10:02 -0400
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);">I would say propagate_const *implies* ownership which implies d=
eep-copy. (or no copy). </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>=
</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: i=
nitial; background-color: rgb(255, 255, 255);">I would be suspect of situat=
ions that use propagate_const <span style=3D"font-size: initial; line-heigh=
t: initial; text-align: initial;">=E2=80=8Ebut don't have ownership semanti=
cs. </span></div><div style=3D"width: 100%; font-size: initial; font-f=
amily: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125=
); text-align: initial; background-color: rgb(255, 255, 255);"><span style=
=3D"font-size: initial; text-align: initial; line-height: initial;"><br></s=
pan></div><div style=3D"width: 100%; font-size: initial; font-family: Calib=
ri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-alig=
n: initial; background-color: rgb(255, 255, 255);"><span style=3D"font-size=
: initial; text-align: initial; line-height: initial;"><br></span></div> =
=
=
<div style=3D"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);">Sent&=
nbsp;from my BlackBerry portable Babbage Device</d=
iv> =
=
<table width=3D"100%" style=3D"background-co=
lor:white;border-spacing:0px;"> <tbody><tr><td colspan=3D"2" style=3D"font-=
size: initial; text-align: initial; background-color: rgb(255, 255, 255);">=
<div style=3D"border-style: solid none none; bor=
der-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>mihailnajdenov@gmail.com</div><div><b>Sent: </b>Sunday, =
October 23, 2016 12:00 PM</div><div><b>To: </b>ISO C++ Standard - Future Pr=
oposals</div><div><b>Reply To: </b>std-proposals@isocpp.org</div><div><b>Cc=
: </b>jbcoe@me.com; joseph.thomson@gmail.com; mihailnajdenov@gmail.com</div=
><div><b>Subject: </b>Re: [std-proposals] Re: [propagate_const] Implicit co=
nversion to T</div></div></td></tr></tbody></table><div style=3D"border-sty=
le: solid none none; border-top-color: rgb(186, 188, 209); border-top-width=
: 1pt; font-size: initial; text-align: initial; background-color: rgb(255, =
255, 255);"></div><br><div id=3D"_originalContent" style=3D""><div dir=3D"l=
tr"><br><br>On Sunday, October 23, 2016 at 4:59:57 PM UTC+3, joseph....@gma=
il.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
<div>...<br>Deep copying wouldn't be a problem. I'm just having a hard time=
figuring out what exactly a deep-copying indirect type would do or how it =
would be useful. I guess I'll have to wait for the details of this <span st=
yle=3D"font-family:courier new,monospace">std::indirect</span>.<br></div></=
div></blockquote><div><br></div><div>I meant, if the copy ctor and assign d=
o a deep copy <span style=3D"font-family:courier new,monospace">=
propagate_const</span> is all you need, no downsides - new data + new =
propagate_const instance<span style=3D"font-family:courier new,monospace">.=
</span></div><div><span style=3D"font-family:courier new,monospace"><br></s=
pan></div><span style=3D"font-family:courier new,monospace"><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 class=3D"styled-by-prettify" style=3D"co=
lor: #606;"><font color=3D"rgb(34,34,34)" style=3D"background-color: transp=
arent;">struct S<br>{<br> S() : _p(std::make_unique<X>()) {}<br>=
S(S&&) =3D default;<br> S& operator=3D(S&&) =
=3D default;<br> S(const S& o) : _p(std::make_unique<X>(*o._=
p)) {}<br> S& operator=3D(const S& o) { if(&o !=3D this) {=
_p =3D std::make_unique<X>(*o._p); } return *this; };</font></span><=
/div><div><br></div><div class=3D"subprettyprint"><span class=3D"styled-by-=
prettify" style=3D"color: #606;"><font color=3D"rgb(34,34,34)" style=3D"bac=
kground-color: transparent;"> propagate_const<std::unique_ptr<X&=
gt;> _p;<br>};</font></span><span class=3D"styled-by-prettify" style=3D"=
color: #660;"></span></div></code></div><div><br></div><div>In this scenari=
o propagate_const will behave completely correct. </div><div><br></div=
><div>In the shared_ptr scenario, copy-on-write is the only way to make the=
"casting-const" copying safe, Qt style. </div><div><br></div><div>So, no-c=
opy, or deep-copy are the only two ways to use propagate_const in compositi=
on in another object. </div><div>One might argue, these are <b>the onl=
y ways</b> to do any const propagation in general, at least without some&nb=
sp;magic language support. </div><div><br></div><div><br></div></span>=
</div>
<p></p>
-- <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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/c431c094-9a24-481f-aaea-e66950a7ccb9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/c431c094-9a24-481f-aaea-e66950a7=
ccb9%40isocpp.org</a>.<br>
<br><!--end of _originalContent --></div></body></html>
<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/20161023161002.4911185.19138.19005%40=
gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com=
/a/isocpp.org/d/msgid/std-proposals/20161023161002.4911185.19138.19005%40gm=
ail.com</a>.<br />
.
Author: joseph.thomson@gmail.com
Date: Sun, 23 Oct 2016 10:52:19 -0700 (PDT)
Raw View
------=_Part_2707_345458151.1477245139437
Content-Type: multipart/alternative;
boundary="----=_Part_2708_1386296347.1477245139437"
------=_Part_2708_1386296347.1477245139437
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Monday, 24 October 2016 00:10:06 UTC+8, Tony V E wrote:
>
> I would say propagate_const *implies* ownership which implies deep-copy.=
=20
> (or no copy).=20
>
> I would be suspect of situations that use propagate_const =E2=80=8Ebut do=
n't have=20
> ownership semantics.=20
>
=20
I'd say propagate_const implies *value*. const implies that you can't=20
change an object's value (even if it doesn't guarantee it in practice).=20
Lack of propagate_const is like the mutable keyword: it is an indication=20
that some part of an object's representation does not affect its value, and=
=20
can therefore be changed even if the object is const. propagate_const=20
*requires* deep-copy or no copy simply because C++ copy operations take=20
references to const. There is no logical reason why non-const objects using=
=20
propagate_const shouldn't be copied; it just isn't supported well by C++.=
=20
Ownership is a separate matter (though unique ownership by itself requires=
=20
deep-copy or no copy).
=20
> Sent from my BlackBerry portable Babbage Device
> *From: *mihailn...@gmail.com <javascript:>
> *Sent: *Sunday, October 23, 2016 12:00 PM
> *To: *ISO C++ Standard - Future Proposals
> *Reply To: *std-pr...@isocpp.org <javascript:>
> *Cc: *jb...@me.com <javascript:>; joseph....@gmail.com <javascript:>;=20
> mihailn...@gmail.com <javascript:>
> *Subject: *Re: [std-proposals] Re: [propagate_const] Implicit conversion=
=20
> to T
>
>
>
> On Sunday, October 23, 2016 at 4:59:57 PM UTC+3, joseph....@gmail.com=20
> wrote:
>>
>> ...
>> Deep copying wouldn't be a problem. I'm just having a hard time figuring=
=20
>> out what exactly a deep-copying indirect type would do or how it would b=
e=20
>> useful. I guess I'll have to wait for the details of this std::indirect.
>>
>
> I meant, if the copy ctor and assign do a deep copy propagate_const is=
=20
> all you need, no downsides - new data + new propagate_const instance.
>
> struct S
> {
> S() : _p(std::make_unique<X>()) {}
> S(S&&) =3D default;
> S& operator=3D(S&&) =3D default;
> S(const S& o) : _p(std::make_unique<X>(*o._p)) {}
> S& operator=3D(const S& o) { if(&o !=3D this) { _p =3D=20
> std::make_unique<X>(*o._p); } return *this; };
>
> propagate_const<std::unique_ptr<X>> _p;
> };
>
> In this scenario propagate_const will behave completely correct.=20
>
> In the shared_ptr scenario, copy-on-write is the only way to make the=20
> "casting-const" copying safe, Qt style.=20
>
> So, no-copy, or deep-copy are the only two ways to use propagate_const in=
=20
> composition in another object.=20
> One might argue, these are *the only ways* to do any const propagation in=
=20
> general, at least without some magic language support.=20
>
>
> --=20
> You received this message because you are subscribed to the Google Groups=
=20
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an=
=20
> email to std-proposal...@isocpp.org <javascript:>.
> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
> To view this discussion on the web visit=20
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/c431c094-9a2=
4-481f-aaea-e66950a7ccb9%40isocpp.org=20
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/c431c094-9a=
24-481f-aaea-e66950a7ccb9%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>
>
--=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/08231f25-9d2b-40be-a79e-92225a0b0336%40isocpp.or=
g.
------=_Part_2708_1386296347.1477245139437
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Monday, 24 October 2016 00:10:06 UTC+8, Tony V E wrote=
:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bo=
rder-left: 1px #ccc solid;padding-left: 1ex;"><div style=3D"background-colo=
r:rgb(255,255,255);line-height:initial" lang=3D"en-US"> =
<div styl=
e=3D"width:100%;font-size:initial;font-family:Calibri,'Slate Pro',s=
ans-serif,sans-serif;color:rgb(31,73,125);text-align:initial;background-col=
or:rgb(255,255,255)">I would say propagate_const *implies* ownership which =
implies deep-copy. (or no copy). </div><div style=3D"width:100%;font-size:i=
nitial;font-family:Calibri,'Slate Pro',sans-serif,sans-serif;color:=
rgb(31,73,125);text-align:initial;background-color:rgb(255,255,255)"><br></=
div><div style=3D"width:100%;font-size:initial;font-family:Calibri,'Sla=
te Pro',sans-serif,sans-serif;color:rgb(31,73,125);text-align:initial;b=
ackground-color:rgb(255,255,255)">I would be suspect of situations that use=
propagate_const <span style=3D"font-size:initial;line-height:initial;text-=
align:initial">=E2=80=8Ebut don't have ownership semantics. <br></span>=
</div></div></blockquote><div>=C2=A0<br>I'd say <span style=3D"font-fam=
ily: courier new,monospace;">propagate_const</span> implies <i>value</i>. <=
span style=3D"font-family: courier new,monospace;">const</span> implies tha=
t you can't change an object's value (even if it doesn't guaran=
tee it in practice). Lack of <span style=3D"font-family: courier new,monosp=
ace;">propagate_const</span> is like the <span style=3D"font-family: courie=
r new,monospace;">mutable</span> keyword: it is an indication that some par=
t of an object's representation does not affect its value, and can ther=
efore be changed even if the object i<span style=3D"font-family: arial,sans=
-serif;">s const. </span><span style=3D"font-family: courier new,monospace;=
"><span style=3D"font-family: arial,sans-serif;">p</span>ropagate_const</sp=
an> <i>requires</i> deep-copy or no copy simply because C++ copy operations=
take references to const. There is no logical reason why non-const objects=
using <span style=3D"font-family: courier new,monospace;">propagate_const<=
/span> shouldn't be copied; it just isn't supported well by C++. Ow=
nership is a separate matter (though unique ownership by itself requires de=
ep-copy or no copy).<br>=C2=A0</div><blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div style=3D"background-color:rgb(255,255,255);line-height:initial" =
lang=3D"en-US"><div style=3D"width:100%;font-size:initial;font-family:Calib=
ri,'Slate Pro',sans-serif,sans-serif;color:rgb(31,73,125);text-alig=
n:initial;background-color:rgb(255,255,255)"><span style=3D"font-size:initi=
al;text-align:initial;line-height:initial"></span></div> =
=
=
<div style=3D"font-size:initial;font-family:Calib=
ri,'Slate Pro',sans-serif,sans-serif;color:rgb(31,73,125);text-alig=
n:initial;background-color:rgb(255,255,255)">Sent=C2=A0from=C2=A0my=C2=A0Bl=
ackBerry=C2=A0<wbr>portable=C2=A0Babbage=C2=A0Device</div> =
=
=
<table style=3D"background-color:white;border-spacing:0px" width=
=3D"100%"> <tbody><tr><td colspan=3D"2" style=3D"font-size:initial;text-ali=
gn:initial;background-color:rgb(255,255,255)"> <d=
iv 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 S=
ans','Slate Pro';font-size:10pt"> <div><b>From: </b><a href=3D=
"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"sGwUaNGRAAAJ" rel=
=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';return true;=
" onclick=3D"this.href=3D'javascript:';return true;">mihailn...@gma=
il.com</a></div><div><b>Sent: </b>Sunday, October 23, 2016 12:00 PM</div><d=
iv><b>To: </b>ISO C++ Standard - Future Proposals</div><div><b>Reply To: </=
b><a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"sGwUaN=
GRAAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';r=
eturn true;" onclick=3D"this.href=3D'javascript:';return true;">std=
-pr...@isocpp.org</a></div><div><b>Cc: </b><a href=3D"javascript:" target=
=3D"_blank" gdf-obfuscated-mailto=3D"sGwUaNGRAAAJ" rel=3D"nofollow" onmouse=
down=3D"this.href=3D'javascript:';return true;" onclick=3D"this.hre=
f=3D'javascript:';return true;">jb...@me.com</a>; <a href=3D"javasc=
ript:" target=3D"_blank" gdf-obfuscated-mailto=3D"sGwUaNGRAAAJ" rel=3D"nofo=
llow" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">joseph....@gmail.com</=
a>; <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"sGwU=
aNGRAAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:'=
;return true;" onclick=3D"this.href=3D'javascript:';return true;">m=
ihailn...@gmail.com</a></div><div><b>Subject: </b>Re: [std-proposals] Re: [=
propagate_const] Implicit conversion to T</div></div></td></tr></tbody></ta=
ble><div style=3D"border-style:solid none none;border-top-color:rgb(186,188=
,209);border-top-width:1pt;font-size:initial;text-align:initial;background-=
color:rgb(255,255,255)"></div><br><div><div dir=3D"ltr"><br><br>On Sunday, =
October 23, 2016 at 4:59:57 PM UTC+3, <a>joseph....@gmail.com</a> wrote:<bl=
ockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-l=
eft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>...<br>Deep copy=
ing wouldn't be a problem. I'm just having a hard time figuring out=
what exactly a deep-copying indirect type would do or how it would be usef=
ul. I guess I'll have to wait for the details of this <span style=3D"fo=
nt-family:courier new,monospace">std::indirect</span>.<br></div></div></blo=
ckquote><div><br></div><div>I meant, if the copy ctor and assign do a=C2=A0=
=C2=A0deep copy <span style=3D"font-family:courier new,monospace">propagate=
_const</span> is all you need, no downsides=C2=A0- new data + new propagate=
_const instance<span style=3D"font-family:courier new,monospace">.</span></=
div><div><span style=3D"font-family:courier new,monospace"><br></span></div=
><span style=3D"font-family:courier new,monospace"><div style=3D"border:1px=
solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,2=
50)"><code><div><span style=3D"color:#606"><font style=3D"background-color:=
transparent" color=3D"rgb(34,34,34)">struct S<br>{<br>=C2=A0S() : _p(std::m=
ake_unique<X>()) {}<br>=C2=A0S(S&&) =3D default;<br>=C2=A0S&a=
mp; operator=3D(S&&) =3D default;<br>=C2=A0S(const S& o) : _p(s=
td::make_unique<X>(*o._p)) {}<br>=C2=A0S& operator=3D(const S&=
; o) { if(&o !=3D this) { _p =3D std::make_unique<X>(*o._p); } re=
turn *this; };</font></span></div><div><br></div><div><span style=3D"color:=
#606"><font style=3D"background-color:transparent" color=3D"rgb(34,34,34)">=
=C2=A0propagate_const<std::unique_<wbr>ptr<X>> _p;<br>};</font>=
</span><span style=3D"color:#660"></span></div></code></div><div><br></div>=
<div>In this scenario propagate_const will behave completely=C2=A0correct. =
</div><div><br></div><div>In the shared_ptr scenario, copy-on-write is the =
only way to make the "casting-const" copying safe, Qt style. </di=
v><div><br></div><div>So, no-copy, or deep-copy are the only two ways to us=
e propagate_const in composition=C2=A0in another object. </div><div>One mig=
ht argue, these are <b>the only ways</b> to do any const propagation in gen=
eral, at least without some=C2=A0magic language support.=C2=A0</div><div><b=
r></div><div><br></div></span></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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
sGwUaNGRAAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:&=
#39;;return true;" onclick=3D"this.href=3D'javascript:';return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"sGwUaNGRAAAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'=
;javascript:';return true;">std-pr...@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/c431c094-9a24-481f-aaea-e66950a7ccb9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D'https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/c431c094-9a24-481f-aaea-e66950a7ccb9%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter';return true;" on=
click=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/c431c094-9a24-481f-aaea-e66950a7ccb9%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter';return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/c431c094-9a24-481f-<wbr>aaea-=
e66950a7ccb9%40isocpp.org</a><wbr>.<br>
<br></div></div>
</blockquote></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/08231f25-9d2b-40be-a79e-92225a0b0336%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/08231f25-9d2b-40be-a79e-92225a0b0336=
%40isocpp.org</a>.<br />
------=_Part_2708_1386296347.1477245139437--
------=_Part_2707_345458151.1477245139437--
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Sun, 23 Oct 2016 13:57:10 -0400
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);">Yes, value semantics is more accurate. </div> =
=
<div style=3D"width: 100%; font-siz=
e: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; colo=
r: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 2=
55);"><br style=3D"display:initial"></div> =
=
=
<div style=3D"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);">Sent from my BlackBe=
rry portable Babbage Device</div> =
=
=
<table width=3D"100%" style=3D"background-color:white;border-spacing:0px;"=
> <tbody><tr><td colspan=3D"2" style=3D"font-size: initial; text-align: ini=
tial; background-color: rgb(255, 255, 255);"> <di=
v style=3D"border-style: solid none none; border-top-color: rgb(181, 196, 2=
23); border-top-width: 1pt; padding: 3pt 0in 0in; font-family: Tahoma, 'BB =
Alpha Sans', 'Slate Pro'; font-size: 10pt;"> <div><b>From: </b>joseph.thom=
son@gmail.com</div><div><b>Sent: </b>Sunday, October 23, 2016 1:52 PM</div>=
<div><b>To: </b>ISO C++ Standard - Future Proposals</div><div><b>Reply To: =
</b>std-proposals@isocpp.org</div><div><b>Cc: </b>jbcoe@me.com; joseph.thom=
son@gmail.com; mihailnajdenov@gmail.com</div><div><b>Subject: </b>Re: [std-=
proposals] Re: [propagate_const] Implicit conversion to T</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; font-size: initial; text=
-align: initial; background-color: rgb(255, 255, 255);"></div><br><div id=
=3D"_originalContent" style=3D""><div dir=3D"ltr">On Monday, 24 October 201=
6 00:10:06 UTC+8, Tony V E wrote:<blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div style=3D"background-color:rgb(255,255,255);line-height:initial" =
lang=3D"en-US"> =
<div style=3D"width:100%;font-size:initial;font-f=
amily:Calibri,'Slate Pro',sans-serif,sans-serif;color:rgb(31,73,125);text-a=
lign:initial;background-color:rgb(255,255,255)">I would say propagate_const=
*implies* ownership which implies deep-copy. (or no copy). </div><div styl=
e=3D"width:100%;font-size:initial;font-family:Calibri,'Slate Pro',sans-seri=
f,sans-serif;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;font-fami=
ly:Calibri,'Slate Pro',sans-serif,sans-serif;color:rgb(31,73,125);text-alig=
n:initial;background-color:rgb(255,255,255)">I would be suspect of situatio=
ns that use propagate_const <span style=3D"font-size:initial;line-height:in=
itial;text-align:initial">=E2=80=8Ebut don't have ownership semantics. <br>=
</span></div></div></blockquote><div> <br>I'd say <span style=3D"font-=
family: courier new,monospace;">propagate_const</span> implies <i>value</i>=
.. <span style=3D"font-family: courier new,monospace;">const</span> implies =
that you can't change an object's value (even if it doesn't guarantee it in=
practice). Lack of <span style=3D"font-family: courier new,monospace;">pro=
pagate_const</span> is like the <span style=3D"font-family: courier new,mon=
ospace;">mutable</span> keyword: it is an indication that some part of an o=
bject's representation does not affect its value, and can therefore be chan=
ged even if the object i<span style=3D"font-family: arial,sans-serif;">s co=
nst. </span><span style=3D"font-family: courier new,monospace;"><span style=
=3D"font-family: arial,sans-serif;">p</span>ropagate_const</span> <i>requir=
es</i> deep-copy or no copy simply because C++ copy operations take referen=
ces to const. There is no logical reason why non-const objects using <span =
style=3D"font-family: courier new,monospace;">propagate_const</span> should=
n't be copied; it just isn't supported well by C++. Ownership is a separate=
matter (though unique ownership by itself requires deep-copy or no copy).<=
br> </div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-=
left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div style=3D"b=
ackground-color:rgb(255,255,255);line-height:initial" lang=3D"en-US"><div s=
tyle=3D"width:100%;font-size:initial;font-family:Calibri,'Slate Pro',sans-s=
erif,sans-serif;color:rgb(31,73,125);text-align:initial;background-color:rg=
b(255,255,255)"><span style=3D"font-size:initial;text-align:initial;line-he=
ight:initial"></span></div> =
=
<di=
v style=3D"font-size:initial;font-family:Calibri,'Slate Pro',sans-serif,san=
s-serif;color:rgb(31,73,125);text-align:initial;background-color:rgb(255,25=
5,255)">Sent from my BlackBerry <wbr>portable Babb=
age Device</div> =
=
<table style=3D"background=
-color:white;border-spacing:0px" width=3D"100%"> <tbody><tr><td colspan=3D"=
2" style=3D"font-size:initial;text-align:initial;background-color:rgb(255,2=
55,255)"> <div style=3D"border-style:solid none n=
one;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><a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=
=3D"sGwUaNGRAAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:'=
;return true;" onclick=3D"this.href=3D'javascript:';return true;">mihailn..=
..@gmail.com</a></div><div><b>Sent: </b>Sunday, October 23, 2016 12:00 PM</d=
iv><div><b>To: </b>ISO C++ Standard - Future Proposals</div><div><b>Reply T=
o: </b><a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"s=
GwUaNGRAAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';retu=
rn true;" onclick=3D"this.href=3D'javascript:';return true;">std-pr...@isoc=
pp.org</a></div><div><b>Cc: </b><a href=3D"javascript:" target=3D"_blank" g=
df-obfuscated-mailto=3D"sGwUaNGRAAAJ" rel=3D"nofollow" onmousedown=3D"this.=
href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';ret=
urn true;">jb...@me.com</a>; <a href=3D"javascript:" target=3D"_blank" gdf-=
obfuscated-mailto=3D"sGwUaNGRAAAJ" rel=3D"nofollow" onmousedown=3D"this.hre=
f=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';return=
true;">joseph....@gmail.com</a>; <a href=3D"javascript:" target=3D"_blank"=
gdf-obfuscated-mailto=3D"sGwUaNGRAAAJ" rel=3D"nofollow" onmousedown=3D"thi=
s.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';r=
eturn true;">mihailn...@gmail.com</a></div><div><b>Subject: </b>Re: [std-pr=
oposals] Re: [propagate_const] Implicit conversion to T</div></div></td></t=
r></tbody></table><div style=3D"border-style:solid none none;border-top-col=
or:rgb(186,188,209);border-top-width:1pt;font-size:initial;text-align:initi=
al;background-color:rgb(255,255,255)"></div><br><div><div dir=3D"ltr"><br><=
br>On Sunday, October 23, 2016 at 4:59:57 PM UTC+3, <a>joseph....@gmail.com=
</a> 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"><div>..=
..<br>Deep copying wouldn't be a problem. I'm just having a hard time figuri=
ng out what exactly a deep-copying indirect type would do or how it would b=
e useful. I guess I'll have to wait for the details of this <span style=3D"=
font-family:courier new,monospace">std::indirect</span>.<br></div></div></b=
lockquote><div><br></div><div>I meant, if the copy ctor and assign do a&nbs=
p; deep copy <span style=3D"font-family:courier new,monospace">propaga=
te_const</span> is all you need, no downsides - new data + new propaga=
te_const instance<span style=3D"font-family:courier new,monospace">.</span>=
</div><div><span style=3D"font-family:courier new,monospace"><br></span></d=
iv><span style=3D"font-family:courier new,monospace"><div style=3D"border:1=
px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250=
,250)"><code><div><span style=3D"color:#606"><font style=3D"background-colo=
r:transparent" color=3D"rgb(34,34,34)">struct S<br>{<br> S() : _p(std:=
:make_unique<X>()) {}<br> S(S&&) =3D default;<br> S=
& operator=3D(S&&) =3D default;<br> S(const S& o) : _p=
(std::make_unique<X>(*o._p)) {}<br> S& operator=3D(const S&a=
mp; o) { if(&o !=3D this) { _p =3D std::make_unique<X>(*o._p); } =
return *this; };</font></span></div><div><br></div><div><span style=3D"colo=
r:#606"><font style=3D"background-color:transparent" color=3D"rgb(34,34,34)=
"> propagate_const<std::unique_<wbr>ptr<X>> _p;<br>};</fon=
t></span><span style=3D"color:#660"></span></div></code></div><div><br></di=
v><div>In this scenario propagate_const will behave completely correct=
.. </div><div><br></div><div>In the shared_ptr scenario, copy-on-write is th=
e only way to make the "casting-const" copying safe, Qt style. </div><div><=
br></div><div>So, no-copy, or deep-copy are the only two ways to use propag=
ate_const in composition in another object. </div><div>One might argue=
, these are <b>the only ways</b> to do any const propagation in general, at=
least without some magic language support. </div><div><br></div>=
<div><br></div></span></div>
<p></p>
-- <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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
sGwUaNGRAAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';ret=
urn true;" onclick=3D"this.href=3D'javascript:';return true;">std-proposal.=
...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"sGwUaNGRAAAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:=
';return true;">std-pr...@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/c431c094-9a24-481f-aaea-e66950a7ccb9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D'https://groups.google.com/a/is=
ocpp.org/d/msgid/std-proposals/c431c094-9a24-481f-aaea-e66950a7ccb9%40isocp=
p.org?utm_medium\x3demail\x26utm_source\x3dfooter';return true;" onclick=3D=
"this.href=3D'https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/=
c431c094-9a24-481f-aaea-e66950a7ccb9%40isocpp.org?utm_medium\x3demail\x26ut=
m_source\x3dfooter';return true;">https://groups.google.com/a/<wbr>isocpp.o=
rg/d/msgid/std-<wbr>proposals/c431c094-9a24-481f-<wbr>aaea-e66950a7ccb9%40i=
socpp.org</a><wbr>.<br>
<br></div></div>
</blockquote></div>
<p></p>
-- <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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/08231f25-9d2b-40be-a79e-92225a0b0336%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/08231f25-9d2b-40be-a79e-92225a0b=
0336%40isocpp.org</a>.<br>
<br><!--end of _originalContent --></div></body></html>
<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/20161023175710.4911185.4764.19015%40g=
mail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/20161023175710.4911185.4764.19015%40gmai=
l.com</a>.<br />
.
Author: Jonathan <jonathanbcoe@gmail.com>
Date: Mon, 24 Oct 2016 07:40:55 +0100
Raw View
--Apple-Mail-6978693D-21D6-41BB-84B7-531BEEC89C2A
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
> On 23 Oct 2016, at 18:57, Tony V E <tvaneerd@gmail.com> wrote:
>=20
> Yes, value semantics is more accurate.
>=20
> Sent from my BlackBerry portable Babbage Device
> From: joseph.thomson@gmail.com
> Sent: Sunday, October 23, 2016 1:52 PM
> To: ISO C++ Standard - Future Proposals
> Reply To: std-proposals@isocpp.org
> Cc: jbcoe@me.com; joseph.thomson@gmail.com; mihailnajdenov@gmail.com
> Subject: Re: [std-proposals] Re: [propagate_const] Implicit conversion to=
T
>=20
>> On Monday, 24 October 2016 00:10:06 UTC+8, Tony V E wrote:
>> I would say propagate_const *implies* ownership which implies deep-copy.=
(or no copy).
>>=20
As promised, here is 'indirect' which gives const-propagation and deep-copy=
..
http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0201r1.pdf
>> I would be suspect of situations that use propagate_const =E2=80=8Ebut d=
on't have ownership semantics.=20
> =20
> I'd say propagate_const implies value. const implies that you can't chang=
e an object's value (even if it doesn't guarantee it in practice). Lack of =
propagate_const is like the mutable keyword: it is an indication that some =
part of an object's representation does not affect its value, and can there=
fore be changed even if the object is const. propagate_const requires deep-=
copy or no copy simply because C++ copy operations take references to const=
.. There is no logical reason why non-const objects using propagate_const sh=
ouldn't be copied; it just isn't supported well by C++. Ownership is a sepa=
rate matter (though unique ownership by itself requires deep-copy or no cop=
y).
> =20
>> Sent from my BlackBerry portable Babbage Device
>> From: mihailn...@gmail.com
>> Sent: Sunday, October 23, 2016 12:00 PM
>> To: ISO C++ Standard - Future Proposals
>> Reply To: std-pr...@isocpp.org
>> Cc: jb...@me.com; joseph....@gmail.com; mihailn...@gmail.com
>> Subject: Re: [std-proposals] Re: [propagate_const] Implicit conversion t=
o T
>>=20
>>=20
>>=20
>>> On Sunday, October 23, 2016 at 4:59:57 PM UTC+3, joseph....@gmail.com w=
rote:
>>> ...
>>> Deep copying wouldn't be a problem. I'm just having a hard time figurin=
g out what exactly a deep-copying indirect type would do or how it would be=
useful. I guess I'll have to wait for the details of this std::indirect.
>>=20
>> I meant, if the copy ctor and assign do a deep copy propagate_const is =
all you need, no downsides - new data + new propagate_const instance.
>>=20
>> struct S
>> {
>> S() : _p(std::make_unique<X>()) {}
>> S(S&&) =3D default;
>> S& operator=3D(S&&) =3D default;
>> S(const S& o) : _p(std::make_unique<X>(*o._p)) {}
>> S& operator=3D(const S& o) { if(&o !=3D this) { _p =3D std::make_unique=
<X>(*o._p); } return *this; };
>>=20
>> propagate_const<std::unique_ptr<X>> _p;
>> };
>>=20
>> In this scenario propagate_const will behave completely correct.
>>=20
>> In the shared_ptr scenario, copy-on-write is the only way to make the "c=
asting-const" copying safe, Qt style.
>>=20
>> So, no-copy, or deep-copy are the only two ways to use propagate_const i=
n composition in another object.
>> One might argue, these are the only ways to do any const propagation in =
general, at least without some magic language support.=20
>>=20
>>=20
>> --=20
>> You received this message because you are subscribed to the Google Group=
s "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n email to std-proposal...@isocpp.org.
>> To post to this group, send email to std-pr...@isocpp.org.
>> To view this discussion on the web visit https://groups.google.com/a/iso=
cpp.org/d/msgid/std-proposals/c431c094-9a24-481f-aaea-e66950a7ccb9%40isocpp=
..org.
>>=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=
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/isoc=
pp.org/d/msgid/std-proposals/08231f25-9d2b-40be-a79e-92225a0b0336%40isocpp.=
org.
>=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=
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/isoc=
pp.org/d/msgid/std-proposals/20161023175710.4911185.4764.19015%40gmail.com.
--=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/8EE69808-0C9A-4825-B834-375CDBA8FAC5%40gmail.com=
..
--Apple-Mail-6978693D-21D6-41BB-84B7-531BEEC89C2A
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=
=3Dutf-8"></head><body dir=3D"auto"><div></div><div><br></div><div><br>On 2=
3 Oct 2016, at 18:57, Tony V E <<a href=3D"mailto:tvaneerd@gmail.com">tv=
aneerd@gmail.com</a>> wrote:<br><br></div><blockquote type=3D"cite"><div=
> =
<div style=3D"width: 100%; font-size: initial; font-family: Cal=
ibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-al=
ign: initial; background-color: rgb(255, 255, 255);">Yes, value semantics i=
s more accurate. </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: i=
nitial; background-color: rgb(255, 255, 255);"><br style=3D"display:initial=
"></div> =
=
<div style=3D"font-siz=
e: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; colo=
r: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 2=
55);">Sent from my BlackBerry portable Babbage&nbs=
p;Device</div> =
=
<table width=3D"100%" style=3D"ba=
ckground-color:white;border-spacing:0px;"> <tbody><tr><td colspan=3D"2" sty=
le=3D"font-size: initial; text-align: initial; background-color: rgb(255, 2=
55, 255);"> <div style=3D"border-style: solid non=
e none; border-top-color: rgb(181, 196, 223); border-top-width: 1pt; paddin=
g: 3pt 0in 0in; font-family: Tahoma, 'BB Alpha Sans', 'Slate Pro'; font-siz=
e: 10pt;"> <div><b>From: </b><a href=3D"mailto:joseph.thomson@gmail.com">j=
oseph.thomson@gmail.com</a></div><div><b>Sent: </b>Sunday, October 23, 2016=
1:52 PM</div><div><b>To: </b>ISO C++ Standard - Future Proposals</div><div=
><b>Reply To: </b><a href=3D"mailto:std-proposals@isocpp.org">std-proposals=
@isocpp.org</a></div><div><b>Cc: </b><a href=3D"mailto:jbcoe@me.com">jbcoe@=
me.com</a>; <a href=3D"mailto:joseph.thomson@gmail.com">joseph.thomson@gmai=
l.com</a>; <a href=3D"mailto:mihailnajdenov@gmail.com">mihailnajdenov@gmail=
..com</a></div><div><b>Subject: </b>Re: [std-proposals] Re: [propagate_const=
] Implicit conversion to T</div></div></td></tr></tbody></table><div style=
=3D"border-style: solid none none; border-top-color: rgb(186, 188, 209); bo=
rder-top-width: 1pt; font-size: initial; text-align: initial; background-co=
lor: rgb(255, 255, 255);"></div><br><div id=3D"_originalContent" style=3D""=
><div dir=3D"ltr">On Monday, 24 October 2016 00:10:06 UTC+8, Tony V E wrot=
e:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;b=
order-left: 1px #ccc solid;padding-left: 1ex;"><div style=3D"background-col=
or:rgb(255,255,255);line-height:initial" lang=3D"en-US"> =
<div sty=
le=3D"width:100%;font-size:initial;font-family:Calibri,'Slate Pro',sans-ser=
if,sans-serif;color:rgb(31,73,125);text-align:initial;background-color:rgb(=
255,255,255)">I would say propagate_const *implies* ownership which implies=
deep-copy. (or no copy). </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></div></div></blo=
ckquote></div></div></div></blockquote><div><br></div><div>As promised, her=
e is 'indirect' which gives const-propagation and deep-copy.</div><div><br>=
</div><div><a href=3D"http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/p=
0201r1.pdf">http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0201r1.pdf=
</a></div><div><br></div><br><blockquote type=3D"cite"><div><div id=3D"_ori=
ginalContent" style=3D""><div dir=3D"ltr"><blockquote class=3D"gmail_quote"=
style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-=
left: 1ex;"><div style=3D"background-color:rgb(255,255,255);line-height:ini=
tial" lang=3D"en-US"><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)">I would be suspect of situations=
that use propagate_const <span style=3D"font-size:initial;line-height:init=
ial;text-align:initial">=E2=80=8Ebut don't have ownership semantics. <br></=
span></div></div></blockquote><div> <br>I'd say <span style=3D"font-fa=
mily: courier new,monospace;">propagate_const</span> implies <i>value</i>. =
<span style=3D"font-family: courier new,monospace;">const</span> implies th=
at you can't change an object's value (even if it doesn't guarantee it in p=
ractice). Lack of <span style=3D"font-family: courier new,monospace;">propa=
gate_const</span> is like the <span style=3D"font-family: courier new,monos=
pace;">mutable</span> keyword: it is an indication that some part of an obj=
ect's representation does not affect its value, and can therefore be change=
d even if the object i<span style=3D"font-family: arial,sans-serif;">s cons=
t. </span><span style=3D"font-family: courier new,monospace;"><span style=
=3D"font-family: arial,sans-serif;">p</span>ropagate_const</span> <i>requir=
es</i> deep-copy or no copy simply because C++ copy operations take referen=
ces to const. There is no logical reason why non-const objects using <span =
style=3D"font-family: courier new,monospace;">propagate_const</span> should=
n't be copied; it just isn't supported well by C++. Ownership is a separate=
matter (though unique ownership by itself requires deep-copy or no copy).<=
br> </div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-=
left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div style=3D"b=
ackground-color:rgb(255,255,255);line-height:initial" lang=3D"en-US"><div s=
tyle=3D"width:100%;font-size:initial;font-family:Calibri,'Slate Pro',sans-s=
erif,sans-serif;color:rgb(31,73,125);text-align:initial;background-color:rg=
b(255,255,255)"><span style=3D"font-size:initial;text-align:initial;line-he=
ight:initial"></span></div> =
=
<di=
v style=3D"font-size:initial;font-family:Calibri,'Slate Pro',sans-serif,san=
s-serif;color:rgb(31,73,125);text-align:initial;background-color:rgb(255,25=
5,255)">Sent from my BlackBerry <wbr>portable Babb=
age Device</div> =
=
<table style=3D"background=
-color:white;border-spacing:0px" width=3D"100%"> <tbody><tr><td colspan=3D"=
2" style=3D"font-size:initial;text-align:initial;background-color:rgb(255,2=
55,255)"> <div style=3D"border-style:solid none n=
one;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><a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=
=3D"sGwUaNGRAAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:'=
;return true;" onclick=3D"this.href=3D'javascript:';return true;">mihailn..=
..@gmail.com</a></div><div><b>Sent: </b>Sunday, October 23, 2016 12:00 PM</d=
iv><div><b>To: </b>ISO C++ Standard - Future Proposals</div><div><b>Reply T=
o: </b><a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"s=
GwUaNGRAAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';retu=
rn true;" onclick=3D"this.href=3D'javascript:';return true;">std-pr...@isoc=
pp.org</a></div><div><b>Cc: </b><a href=3D"javascript:" target=3D"_blank" g=
df-obfuscated-mailto=3D"sGwUaNGRAAAJ" rel=3D"nofollow" onmousedown=3D"this.=
href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';ret=
urn true;">jb...@me.com</a>; <a href=3D"javascript:" target=3D"_blank" gdf-=
obfuscated-mailto=3D"sGwUaNGRAAAJ" rel=3D"nofollow" onmousedown=3D"this.hre=
f=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';return=
true;">joseph....@gmail.com</a>; <a href=3D"javascript:" target=3D"_blank"=
gdf-obfuscated-mailto=3D"sGwUaNGRAAAJ" rel=3D"nofollow" onmousedown=3D"thi=
s.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';r=
eturn true;">mihailn...@gmail.com</a></div><div><b>Subject: </b>Re: [std-pr=
oposals] Re: [propagate_const] Implicit conversion to T</div></div></td></t=
r></tbody></table><div style=3D"border-style:solid none none;border-top-col=
or:rgb(186,188,209);border-top-width:1pt;font-size:initial;text-align:initi=
al;background-color:rgb(255,255,255)"></div><br><div><div dir=3D"ltr"><br><=
br>On Sunday, October 23, 2016 at 4:59:57 PM UTC+3, <a>joseph....@gmail.com=
</a> 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"><div>..=
..<br>Deep copying wouldn't be a problem. I'm just having a hard time figuri=
ng out what exactly a deep-copying indirect type would do or how it would b=
e useful. I guess I'll have to wait for the details of this <span style=3D"=
font-family:courier new,monospace">std::indirect</span>.<br></div></div></b=
lockquote><div><br></div><div>I meant, if the copy ctor and assign do a&nbs=
p; deep copy <span style=3D"font-family:courier new,monospace">propaga=
te_const</span> is all you need, no downsides - new data + new propaga=
te_const instance<span style=3D"font-family:courier new,monospace">.</span>=
</div><div><span style=3D"font-family:courier new,monospace"><br></span></d=
iv><span style=3D"font-family:courier new,monospace"><div style=3D"border:1=
px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250=
,250)"><code><div><span style=3D"color:#606"><font style=3D"background-colo=
r:transparent" color=3D"rgb(34,34,34)">struct S<br>{<br> S() : _p(std:=
:make_unique<X>()) {}<br> S(S&&) =3D default;<br> S=
& operator=3D(S&&) =3D default;<br> S(const S& o) : _p=
(std::make_unique<X>(*o._p)) {}<br> S& operator=3D(const S&a=
mp; o) { if(&o !=3D this) { _p =3D std::make_unique<X>(*o._p); } =
return *this; };</font></span></div><div><br></div><div><span style=3D"colo=
r:#606"><font style=3D"background-color:transparent" color=3D"rgb(34,34,34)=
"> propagate_const<std::unique_<wbr>ptr<X>> _p;<br>};</fon=
t></span><span style=3D"color:#660"></span></div></code></div><div><br></di=
v><div>In this scenario propagate_const will behave completely correct=
.. </div><div><br></div><div>In the shared_ptr scenario, copy-on-write is th=
e only way to make the "casting-const" copying safe, Qt style. </div><div><=
br></div><div>So, no-copy, or deep-copy are the only two ways to use propag=
ate_const in composition in another object. </div><div>One might argue=
, these are <b>the only ways</b> to do any const propagation in general, at=
least without some magic language support. </div><div><br></div>=
<div><br></div></span></div>
<p></p>
-- <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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
sGwUaNGRAAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';ret=
urn true;" onclick=3D"this.href=3D'javascript:';return true;">std-proposal.=
...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"sGwUaNGRAAAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:=
';return true;">std-pr...@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/c431c094-9a24-481f-aaea-e66950a7ccb9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D'https://groups.google.com/a/is=
ocpp.org/d/msgid/std-proposals/c431c094-9a24-481f-aaea-e66950a7ccb9%40isocp=
p.org?utm_medium\x3demail\x26utm_source\x3dfooter';return true;" onclick=3D=
"this.href=3D'https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/=
c431c094-9a24-481f-aaea-e66950a7ccb9%40isocpp.org?utm_medium\x3demail\x26ut=
m_source\x3dfooter';return true;">https://groups.google.com/a/<wbr>isocpp.o=
rg/d/msgid/std-<wbr>proposals/c431c094-9a24-481f-<wbr>aaea-e66950a7ccb9%40i=
socpp.org</a><wbr>.<br>
<br></div></div>
</blockquote></div>
<p></p>
-- <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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/08231f25-9d2b-40be-a79e-92225a0b0336%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/08231f25-9d2b-40be-a79e-92225a0b=
0336%40isocpp.org</a>.<br>
<br><!--end of _originalContent --></div>
<p></p>
-- <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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/20161023175710.4911185.4764.19015%40g=
mail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/20161023175710.4911185.4764.19015%40=
gmail.com</a>.<br>
</div></blockquote></body></html>
<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/8EE69808-0C9A-4825-B834-375CDBA8FAC5%=
40gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/8EE69808-0C9A-4825-B834-375CDBA8FAC5%=
40gmail.com</a>.<br />
--Apple-Mail-6978693D-21D6-41BB-84B7-531BEEC89C2A--
.
Author: mihailnajdenov@gmail.com
Date: Mon, 24 Oct 2016 02:10:40 -0700 (PDT)
Raw View
------=_Part_1190_1041417735.1477300240909
Content-Type: multipart/alternative;
boundary="----=_Part_1191_1249826522.1477300240909"
------=_Part_1191_1249826522.1477300240909
Content-Type: text/plain; charset=UTF-8
On Monday, October 24, 2016 at 9:40:59 AM UTC+3, Jonathan Coe wrote:
>
>
> ...
> As promised, here is 'indirect' which gives const-propagation and
> deep-copy.
>
> http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0201r1.pdf
>
> ..
>
>
This is indeed a handy tool - we have all written at least one "poor man's"
version of it in our code.
*However* I am worried people will use it even if cheaper alternatives
are sufficient, just because it is *easier*.
The type-erasing control block is a price people will pay even if they
don't have to, and without being aware of it.
Some other comments:
- I believe the move-ctor and move-assignment (line 193 and 254) cannot be
noexcept - they create a new control block.
And the fact that move-ops are not non-throwing is a considerable drawback.
- I am not a fan of the name indirect<> - it is very vague.
May I suggest deep_ptr, or even deep_copy_ptr, because in the end it does
model a pointer to object and it is about its lifetime.
It is an extension of pointers, not on basic vocabulary types. Where
shared_ptr and unique_ptr handle new and delete only, this one adds copy as
well.
Basic vocabulary types are created from values even if they alloc and
manage mem internally, like vector.
This one is created from a pointer - thus it a pointer management class,
not a basic type.
- Again, I think it is handily tool, but easily overused - it makes you
*not* think about copies of big objects, which will lead to too may of
them.
Not unlike how std::vector and std::string are used by unexperienced
programmers or ones coming from a different language like Java or C#.
Everything will be an indirect<> to solve all memory management discomforts.
Value sematic are great, but low number of copies is also great. I am
afraid this will lead to explosion (hidden) copies of big objects in user
code.
--
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/f88b96df-e3b2-4845-98d9-05c216cf47c3%40isocpp.org.
------=_Part_1191_1249826522.1477300240909
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Monday, October 24, 2016 at 9:40:59 AM UTC+3, J=
onathan Coe wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"=
auto"><div></div><div><br></div><div>...<br></div><div>As promised, here is=
'indirect' which gives const-propagation and deep-copy.</div><div>=
<br></div><div><a onmousedown=3D"this.href=3D'http://www.google.com/url=
?q\x3dhttp%3A%2F%2Fopen-std.org%2FJTC1%2FSC22%2FWG21%2Fdocs%2Fpapers%2F2016=
%2Fp0201r1.pdf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEw-dD03A2HwSOMFD1XO5=
1yMA9D7w';return true;" onclick=3D"this.href=3D'http://www.google.c=
om/url?q\x3dhttp%3A%2F%2Fopen-std.org%2FJTC1%2FSC22%2FWG21%2Fdocs%2Fpapers%=
2F2016%2Fp0201r1.pdf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEw-dD03A2HwSOM=
FD1XO51yMA9D7w';return true;" href=3D"http://open-std.org/JTC1/SC22/WG2=
1/docs/papers/2016/p0201r1.pdf" target=3D"_blank" rel=3D"nofollow">http://o=
pen-std.org/JTC1/SC22/<wbr>WG21/docs/papers/2016/p0201r1.<wbr>pdf</a></div>=
<div><br></div><blockquote type=3D"cite"><div>..<br></div></blockquote></di=
v></blockquote><div><br></div><div>This is indeed a handy tool -=C2=A0we ha=
ve=C2=A0all written at least one "poor man's" version of it i=
n our code. </div><div><br></div><div><i>However</i> I am worried people wi=
ll use it even if cheaper alternatives are=C2=A0sufficient, just because it=
is <i>easier</i>. </div><div>The type-erasing control block is a price peo=
ple will pay even if they don't have to, and without being aware of it.=
</div><div><br></div><div>Some other comments:</div><div><br></div><div>=C2=
=A0-=C2=A0I believe the move-ctor and move-assignment (line=C2=A0193 and 25=
4)=C2=A0cannot be noexcept - they create a new control block. </div><div><b=
r></div><div>And=C2=A0the fact that move-ops are not non-throwing is a cons=
iderable drawback.</div><div><br></div><div>=C2=A0-=C2=A0I am not a fan of =
the name indirect<> - it is very vague. </div><div><br></div><div>May=
I suggest deep_ptr, or even deep_copy_ptr, because in the end it does mode=
l a pointer to object and it is about its lifetime.</div><div>It is an exte=
nsion of pointers, not on basic vocabulary types. Where shared_ptr and uniq=
ue_ptr handle new and delete only, this one adds copy as well. </div><div><=
br></div><div>Basic vocabulary types=C2=A0are created from values even if t=
hey alloc and manage mem internally, like vector. </div><div>This one is cr=
eated from a pointer -=C2=A0thus it=C2=A0a pointer management class, not a =
basic type.</div><div><br></div><div>=C2=A0- Again, I think it is handily t=
ool, but easily overused - it makes you <i>not</i> think about=C2=A0copies =
of big objects, which will lead to too=C2=A0may of them. </div><div>Not unl=
ike how std::vector and std::string are used by unexperienced programmers o=
r ones coming from a different language like Java or C#.</div><div><br></di=
v><div>Everything will be an indirect<> to solve all memory managemen=
t=C2=A0<span>discomforts</span>. </div><div>Value sematic are great, but lo=
w number of copies is also great. I am afraid this will lead to explosion (=
hidden)=C2=A0copies of big objects=C2=A0in user code. =C2=A0</div><div><br>=
</div><div><br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/f88b96df-e3b2-4845-98d9-05c216cf47c3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/f88b96df-e3b2-4845-98d9-05c216cf47c3=
%40isocpp.org</a>.<br />
------=_Part_1191_1249826522.1477300240909--
------=_Part_1190_1041417735.1477300240909--
.
Author: Jonathan Coe <jbcoe@me.com>
Date: Mon, 24 Oct 2016 10:34:05 +0100
Raw View
--001a113bf6bee0462f053f991710
Content-Type: text/plain; charset=UTF-8
On 24 October 2016 at 10:10, <mihailnajdenov@gmail.com> wrote:
>
>
> On Monday, October 24, 2016 at 9:40:59 AM UTC+3, Jonathan Coe wrote:
>>
>>
>> ...
>> As promised, here is 'indirect' which gives const-propagation and
>> deep-copy.
>>
>> http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0201r1.pdf
>>
>> ..
>>
>>
> This is indeed a handy tool - we have all written at least one "poor
> man's" version of it in our code.
>
> *However* I am worried people will use it even if cheaper alternatives
> are sufficient, just because it is *easier*.
> The type-erasing control block is a price people will pay even if they
> don't have to, and without being aware of it.
>
> Some other comments:
>
> - I believe the move-ctor and move-assignment (line 193 and 254) cannot
> be noexcept - they create a new control block.
>
>
Fixed in the impl.
> And the fact that move-ops are not non-throwing is a considerable drawback.
>
>
move-construction and assignment of `indirect<T>` from another
`indirect<T>` can be noexcept. Only when the template type is different do
we need to allocate.
> - I am not a fan of the name indirect<> - it is very vague.
>
> May I suggest deep_ptr, or even deep_copy_ptr, because in the end it does
> model a pointer to object and it is about its lifetime.
> It is an extension of pointers, not on basic vocabulary types. Where
> shared_ptr and unique_ptr handle new and delete only, this one adds copy as
> well.
>
>
LEWG requested a non-pointer-based name (initially it was cloned_ptr) as
it's not a pointer. I'm sure we'll discuss naming further in Issaquah.
> Basic vocabulary types are created from values even if they alloc and
> manage mem internally, like vector.
> This one is created from a pointer - thus it a pointer management class,
> not a basic type.
>
> - Again, I think it is handily tool, but easily overused - it makes you
> *not* think about copies of big objects, which will lead to too may of
> them.
> Not unlike how std::vector and std::string are used by unexperienced
> programmers or ones coming from a different language like Java or C#.
>
> Everything will be an indirect<> to solve all memory management
> discomforts.
> Value sematic are great, but low number of copies is also great. I am
> afraid this will lead to explosion (hidden) copies of big objects in user
> code.
>
>
>
Agreed, this is a potentially useful tool, not a silver bullet.
`propagate_const` is cheaper (free) when copying is not required.
> --
> 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/f88b96df-e3b2-4845-
> 98d9-05c216cf47c3%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f88b96df-e3b2-4845-98d9-05c216cf47c3%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>
--
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/CAAbBDD-V%3D349D4YFS26_Z2Fg-0tDKvCdtKxcJgf3in9yaUEf0g%40mail.gmail.com.
--001a113bf6bee0462f053f991710
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On 24 October 2016 at 10:10, <span dir=3D"ltr"><<a href=3D"mailto:m=
ihailnajdenov@gmail.com" target=3D"_blank">mihailnajdenov@gmail.com</a>>=
</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .=
8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><br>O=
n Monday, October 24, 2016 at 9:40:59 AM UTC+3, Jonathan Coe wrote:<blockqu=
ote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div dir=3D"auto"><div></div><div><br></div=
><div>...<br></div><span class=3D""><div>As promised, here is 'indirect=
' which gives const-propagation and deep-copy.</div><div><br></div><div=
><a href=3D"http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0201r1.pdf=
" rel=3D"nofollow" target=3D"_blank">http://open-std.org/JTC1/SC22/<wbr>WG2=
1/docs/papers/2016/p0201r1.<wbr>pdf</a></div><div><br></div></span><blockqu=
ote type=3D"cite"><div>..<br></div></blockquote></div></blockquote><div><br=
></div><div>This is indeed a handy tool -=C2=A0we have=C2=A0all written at =
least one "poor man's" version of it in our code. </div><div>=
<br></div><div><i>However</i> I am worried people will use it even if cheap=
er alternatives are=C2=A0sufficient, just because it is <i>easier</i>. </di=
v><div>The type-erasing control block is a price people will pay even if th=
ey don't have to, and without being aware of it.</div><div><br></div><d=
iv>Some other comments:</div><div><br></div><div>=C2=A0-=C2=A0I believe the=
move-ctor and move-assignment (line=C2=A0193 and 254)=C2=A0cannot be noexc=
ept - they create a new control block. </div><div><br></div></div></blockqu=
ote><div><br></div><div>Fixed in the impl.</div><div>=C2=A0</div><blockquot=
e class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc sol=
id;padding-left:1ex"><div dir=3D"ltr"><div></div><div>And=C2=A0the fact tha=
t move-ops are not non-throwing is a considerable drawback.</div><div><br><=
/div></div></blockquote><div><br></div><div>move-construction and assignmen=
t of `indirect<T>` from another `indirect<T>` can be noexcept. =
Only when the template type is different do we need to allocate.=C2=A0</div=
><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .=
8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div></di=
v><div>=C2=A0-=C2=A0I am not a fan of the name indirect<> - it is ver=
y vague. </div><div><br></div><div>May I suggest deep_ptr, or even deep_cop=
y_ptr, because in the end it does model a pointer to object and it is about=
its lifetime.</div><div>It is an extension of pointers, not on basic vocab=
ulary types. Where shared_ptr and unique_ptr handle new and delete only, th=
is one adds copy as well. </div><div><br></div></div></blockquote><div><br>=
</div><div>LEWG requested a non-pointer-based name (initially it was cloned=
_ptr) as it's not a pointer. I'm sure we'll discuss naming furt=
her in Issaquah.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div =
dir=3D"ltr"><div></div><div>Basic vocabulary types=C2=A0are created from va=
lues even if they alloc and manage mem internally, like vector. </div><div>=
This one is created from a pointer -=C2=A0thus it=C2=A0a pointer management=
class, not a basic type.</div><div><br></div><div>=C2=A0- Again, I think i=
t is handily tool, but easily overused - it makes you <i>not</i> think abou=
t=C2=A0copies of big objects, which will lead to too=C2=A0may of them. </di=
v><div>Not unlike how std::vector and std::string are used by unexperienced=
programmers or ones coming from a different language like Java or C#.</div=
><div><br></div><div>Everything will be an indirect<> to solve all me=
mory management=C2=A0<span>discomforts</span>. </div><div>Value sematic are=
great, but low number of copies is also great. I am afraid this will lead =
to explosion (hidden)=C2=A0copies of big objects=C2=A0in user code. =C2=A0<=
/div><div><br></div><div><br></div></div></blockquote><div><br></div><div>A=
greed, this is a potentially useful tool, not a silver bullet. `propagate_c=
onst` is cheaper (free) when copying is not required.</div><div>=C2=A0</div=
><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div></div></div><span cla=
ss=3D"">
<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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/f88b96df-e3b2-4845-98d9-05c216cf47c3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/f88b=
96df-e3b2-4845-<wbr>98d9-05c216cf47c3%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/CAAbBDD-V%3D349D4YFS26_Z2Fg-0tDKvCdtK=
xcJgf3in9yaUEf0g%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAAbBDD-V%3D349=
D4YFS26_Z2Fg-0tDKvCdtKxcJgf3in9yaUEf0g%40mail.gmail.com</a>.<br />
--001a113bf6bee0462f053f991710--
.
Author: mihailnajdenov@gmail.com
Date: Mon, 24 Oct 2016 05:57:04 -0700 (PDT)
Raw View
------=_Part_1192_1963010133.1477313824170
Content-Type: multipart/alternative;
boundary="----=_Part_1193_1451462731.1477313824170"
------=_Part_1193_1451462731.1477313824170
Content-Type: text/plain; charset=UTF-8
On Monday, October 24, 2016 at 12:34:08 PM UTC+3, Jonathan Coe wrote:
>
>
>
> On 24 October 2016 at 10:10, <mihailn...@gmail.com <javascript:>> wrote:
>
>>
>>
>> On Monday, October 24, 2016 at 9:40:59 AM UTC+3, Jonathan Coe wrote:
>>>
>>>
>>> ...
>>> As promised, here is 'indirect' which gives const-propagation and
>>> deep-copy.
>>>
>>> http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0201r1.pdf
>>>
>>> ..
>>>
>>>
>> This is indeed a handy tool - we have all written at least one "poor
>> man's" version of it in our code.
>>
>> *However* I am worried people will use it even if cheaper alternatives
>> are sufficient, just because it is *easier*.
>> The type-erasing control block is a price people will pay even if they
>> don't have to, and without being aware of it.
>> ...
>>
>
Are there plans to make use of small object optimization?
It seems delegating_control_block is always a fixed size one
unique_ptr (~16 bytes)
and pointer_control_block is the same + copier + deleter (which will
probably be zero size most of the time).
These two are heap allocated only for the type erasure to work.
Having SOO will make this class much, much, much more attractive to use!
I should not pay extra for std::indirect<char>( (char*)malloc(...), memcpy,
free) to do the right thing, else I'll still have to write my own version
like I do today.
P.S Another suggestion for a name - remote. It is a remote value - a value,
not stored as part of the instance variable.
Also, the instance variable acts as a "remote control" on the value.
--
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/307e6fba-91d2-44ca-91d5-a97657691277%40isocpp.org.
------=_Part_1193_1451462731.1477313824170
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Monday, October 24, 2016 at 12:34:08 PM UTC+3, =
Jonathan Coe wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D=
"ltr"><br><div><br><div class=3D"gmail_quote">On 24 October 2016 at 10:10, =
<span dir=3D"ltr"><<a onmousedown=3D"this.href=3D'javascript:';=
return true;" onclick=3D"this.href=3D'javascript:';return true;" hr=
ef=3D"javascript:" target=3D"_blank" rel=3D"nofollow" gdf-obfuscated-mailto=
=3D"l_v-PsrKAAAJ">mihailn...@gmail.com</a>></span> wrote:<br><blockquote=
class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc soli=
d;padding-left:1ex"><div dir=3D"ltr"><br><br>On Monday, October 24, 2016 at=
9:40:59 AM UTC+3, Jonathan Coe wrote:<blockquote class=3D"gmail_quote" sty=
le=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1e=
x"><div dir=3D"auto"><div></div><div><br></div><div>...<br></div><span><div=
>As promised, here is 'indirect' which gives const-propagation and =
deep-copy.</div><div><br></div><div><a onmousedown=3D"this.href=3D'http=
://www.google.com/url?q\x3dhttp%3A%2F%2Fopen-std.org%2FJTC1%2FSC22%2FWG21%2=
Fdocs%2Fpapers%2F2016%2Fp0201r1.pdf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjC=
NEw-dD03A2HwSOMFD1XO51yMA9D7w';return true;" onclick=3D"this.href=3D=
9;http://www.google.com/url?q\x3dhttp%3A%2F%2Fopen-std.org%2FJTC1%2FSC22%2F=
WG21%2Fdocs%2Fpapers%2F2016%2Fp0201r1.pdf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3=
dAFQjCNEw-dD03A2HwSOMFD1XO51yMA9D7w';return true;" href=3D"http://open-=
std.org/JTC1/SC22/WG21/docs/papers/2016/p0201r1.pdf" target=3D"_blank" rel=
=3D"nofollow">http://open-std.org/JTC1/SC22/<wbr>WG21/docs/papers/2016/p020=
1r1.<wbr>pdf</a></div><div><br></div></span><blockquote type=3D"cite"><div>=
...<br></div></blockquote></div></blockquote><div><br></div><div>This is ind=
eed a handy tool -=C2=A0we have=C2=A0all written at least one "poor ma=
n's" version of it in our code. </div><div><br></div><div><i>Howev=
er</i> I am worried people will use it even if cheaper alternatives are=C2=
=A0sufficient, just because it is <i>easier</i>. </div><div>The type-erasin=
g control block is a price people will pay even if they don't have to, =
and without being aware of it.</div><div>...</div></div></blockquote></div>=
</div></div></blockquote><div>=C2=A0</div><div>Are there plans to make use =
of=C2=A0small object optimization? </div><div><br></div><div>It seems deleg=
ating_control_block is always a fixed size=C2=A0one unique_ptr=C2=A0(~16 by=
tes)</div><div>and pointer_control_block is the same + copier + deleter (wh=
ich will probably be zero size=C2=A0most of the time).</div><div><br></div>=
<div>These two=C2=A0are=C2=A0heap allocated only for the type erasure to wo=
rk.</div><div><br></div><div>Having SOO will=C2=A0make=C2=A0this class=C2=
=A0much, much, much=C2=A0more attractive=C2=A0to use!</div><div><br></div><=
div>I should not pay extra for std::indirect<char>( (char*)malloc(...=
),=C2=A0memcpy, free) to do the right thing, else I'll still have to=C2=
=A0write my own version like I do today.</div><div><br></div><div><br></div=
><div>P.S Another suggestion for a name - remote. It is a=C2=A0remote value=
- a value, not stored as part of the instance variable. </div><div>Also, t=
he instance variable acts as a "remote control" on the value.</di=
v><div><br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/307e6fba-91d2-44ca-91d5-a97657691277%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/307e6fba-91d2-44ca-91d5-a97657691277=
%40isocpp.org</a>.<br />
------=_Part_1193_1451462731.1477313824170--
------=_Part_1192_1963010133.1477313824170--
.
Author: joseph.thomson@gmail.com
Date: Wed, 26 Oct 2016 10:54:41 -0700 (PDT)
Raw View
------=_Part_167_2085292732.1477504481193
Content-Type: multipart/alternative;
boundary="----=_Part_168_2077745130.1477504481193"
------=_Part_168_2077745130.1477504481193
Content-Type: text/plain; charset=UTF-8
On Monday, 24 October 2016 17:34:08 UTC+8, Jonathan Coe wrote:
>
>
>
> On 24 October 2016 at 10:10, <mihailn...@gmail.com <javascript:>> wrote:
>
>>
>>
>> On Monday, October 24, 2016 at 9:40:59 AM UTC+3, Jonathan Coe wrote:
>>>
>>>
>>> ...
>>> As promised, here is 'indirect' which gives const-propagation and
>>> deep-copy.
>>>
>>> http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0201r1.pdf
>>>
>>> ..
>>>
>>>
>> This is indeed a handy tool - we have all written at least one "poor
>> man's" version of it in our code.
>>
>> *However* I am worried people will use it even if cheaper alternatives
>> are sufficient, just because it is *easier*.
>> The type-erasing control block is a price people will pay even if they
>> don't have to, and without being aware of it.
>>
>> Some other comments:
>>
>>
> - I believe the move-ctor and move-assignment (line 193 and 254) cannot
>> be noexcept - they create a new control block.
>>
>>
> Fixed in the impl.
>
>
>> And the fact that move-ops are not non-throwing is a considerable
>> drawback.
>>
>>
> move-construction and assignment of `indirect<T>` from another
> `indirect<T>` can be noexcept. Only when the template type is different do
> we need to allocate.
>
>
>> - I am not a fan of the name indirect<> - it is very vague.
>>
>> May I suggest deep_ptr, or even deep_copy_ptr, because in the end it does
>> model a pointer to object and it is about its lifetime.
>> It is an extension of pointers, not on basic vocabulary types. Where
>> shared_ptr and unique_ptr handle new and delete only, this one adds copy as
>> well.
>>
>>
> LEWG requested a non-pointer-based name (initially it was cloned_ptr) as
> it's not a pointer. I'm sure we'll discuss naming further in Issaquah.
>
>
>> Basic vocabulary types are created from values even if they alloc and
>> manage mem internally, like vector.
>> This one is created from a pointer - thus it a pointer management class,
>> not a basic type.
>>
>> - Again, I think it is handily tool, but easily overused - it makes you
>> *not* think about copies of big objects, which will lead to too may of
>> them.
>> Not unlike how std::vector and std::string are used by unexperienced
>> programmers or ones coming from a different language like Java or C#.
>>
>> Everything will be an indirect<> to solve all memory management
>> discomforts.
>> Value sematic are great, but low number of copies is also great. I am
>> afraid this will lead to explosion (hidden) copies of big objects in user
>> code.
>>
>>
>>
> Agreed, this is a potentially useful tool, not a silver bullet.
> `propagate_const` is cheaper (free) when copying is not required.
>
>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f88b96df-e3b2-4845-98d9-05c216cf47c3%40isocpp.org
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f88b96df-e3b2-4845-98d9-05c216cf47c3%40isocpp.org?utm_medium=email&utm_source=footer>
>> .
>>
>
I like the idea of a polymorphic value-like type. However, I believe that
the proposed design is stuck in limbo between a pointer-like and value-like
type:
- An indirect is constructed from a pointer that it takes ownership of.
Ideally, a value-like type would hide all memory management under the hood.
Sure, make_indirect exists, but the smart pointer-esque,
ownership-transferring constructor is still visible.
- An indirect can be empty. Emptiness/nullness is a very pointer-like
trait. Being able to convert a value-like type to bool to test for
emptiness is very odd. A value-like type should always have a value.
- Moving an indirect doesn't move the underlying object. Copying invokes
the copy constructor, so why doesn't moving invoke the move constructor? I
realize you gain noexcept status if you just move the internal pointer,
but this isn't very value-like behaviour.
- Deleters and copiers smell of resource management.
I suggest the following:
- indirect should not use deleters or other special resource management
functors.
- The default constructor of indirect<T> should default construct a T
(or not exist if T is not default constructible)
- The copy and move constructors and assignment operators of indirect
should copy and move the underlying objects (T must be copyable and
movable)
- An indirect<T> should be copy and move constructible and assignable
from T.
- The in_place technique can be used to construct indirect efficiently
from other arguments (no additional copies; no adopted pointer).
- indirect should not be convertible to bool. In fact, with this design
it can no longer be in an empty state, so there is no reason for such a
conversion to exist.
- Since indirect implicitly upcasts, static_indirect_cast and
dynamic_indirect_cast should be available for downcasting. However,
const and reinterpret casts make no sense for a value-like type.
This results in a value-like type that is much more consistent in its
behaviour, and is potentially slightly more efficient in space and time. I
have pushed a working sample implementation to a fork of your repository
<https://github.com/hpesoj/indirect/blob/master/indirect.h>. Note that it
is more inspired by your original implementation than an evolution of it,
and the tests aren't complete by any means.
As for the name, I'm not a huge fan of std::indirect, because it very much
says "pointer" to me. Perhaps something like std::polymorphic would be
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b11f0d55-280a-4ff0-b6c2-9f197337364f%40isocpp.org.
------=_Part_168_2077745130.1477504481193
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Monday, 24 October 2016 17:34:08 UTC+8, Jonathan Coe w=
rote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8e=
x;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><br><div=
><br><div class=3D"gmail_quote">On 24 October 2016 at 10:10, <span dir=3D"=
ltr"><<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D=
"l_v-PsrKAAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:=
';return true;" onclick=3D"this.href=3D'javascript:';return tru=
e;">mihailn...@gmail.com</a>></span> wrote:<br><blockquote class=3D"gmai=
l_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left=
:1ex"><div dir=3D"ltr"><br><br>On Monday, October 24, 2016 at 9:40:59 AM UT=
C+3, Jonathan Coe 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=
"auto"><div></div><div><br></div><div>...<br></div><span><div>As promised, =
here is 'indirect' which gives const-propagation and deep-copy.</di=
v><div><br></div><div><a href=3D"http://open-std.org/JTC1/SC22/WG21/docs/pa=
pers/2016/p0201r1.pdf" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"th=
is.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fopen-std.org%2FJ=
TC1%2FSC22%2FWG21%2Fdocs%2Fpapers%2F2016%2Fp0201r1.pdf\x26sa\x3dD\x26sntz\x=
3d1\x26usg\x3dAFQjCNEw-dD03A2HwSOMFD1XO51yMA9D7w';return true;" onclick=
=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fopen-std.o=
rg%2FJTC1%2FSC22%2FWG21%2Fdocs%2Fpapers%2F2016%2Fp0201r1.pdf\x26sa\x3dD\x26=
sntz\x3d1\x26usg\x3dAFQjCNEw-dD03A2HwSOMFD1XO51yMA9D7w';return true;">h=
ttp://open-std.org/JTC1/SC22/<wbr>WG21/docs/papers/2016/p0201r1.<wbr>pdf</a=
></div><div><br></div></span><blockquote type=3D"cite"><div>..<br></div></b=
lockquote></div></blockquote><div><br></div><div>This is indeed a handy too=
l -=C2=A0we have=C2=A0all written at least one "poor man's" v=
ersion of it in our code. </div><div><br></div><div><i>However</i> I am wor=
ried people will use it even if cheaper alternatives are=C2=A0sufficient, j=
ust because it is <i>easier</i>. </div><div>The type-erasing control block =
is a price people will pay even if they don't have to, and without bein=
g aware of it.</div><div><br></div><div>Some other comments:</div><div>=C2=
=A0</div></div></blockquote></div></div></div></blockquote><blockquote clas=
s=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #c=
cc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quot=
e"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div></div><div>=C2=A0-=
=C2=A0I believe the move-ctor and move-assignment (line=C2=A0193 and 254)=
=C2=A0cannot be noexcept - they create a new control block. </div><div><br>=
</div></div></blockquote><div><br></div><div>Fixed in the impl.</div><div>=
=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div></div><div=
>And=C2=A0the fact that move-ops are not non-throwing is a considerable dra=
wback.</div><div><br></div></div></blockquote><div><br></div><div>move-cons=
truction and assignment of `indirect<T>` from another `indirect<T&=
gt;` can be noexcept. Only when the template type is different do we need t=
o allocate.=C2=A0</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div=
dir=3D"ltr"><div></div><div>=C2=A0-=C2=A0I am not a fan of the name indire=
ct<> - it is very vague. </div><div><br></div><div>May I suggest deep=
_ptr, or even deep_copy_ptr, because in the end it does model a pointer to =
object and it is about its lifetime.</div><div>It is an extension of pointe=
rs, not on basic vocabulary types. Where shared_ptr and unique_ptr handle n=
ew and delete only, this one adds copy as well. </div><div><br></div></div>=
</blockquote><div><br></div><div>LEWG requested a non-pointer-based name (i=
nitially it was cloned_ptr) as it's not a pointer. I'm sure we'=
ll discuss naming further in Issaquah.</div><div>=C2=A0</div><blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><div dir=3D"ltr"><div></div><div>Basic vocabulary types=C2=
=A0are created from values even if they alloc and manage mem internally, li=
ke vector. </div><div>This one is created from a pointer -=C2=A0thus it=C2=
=A0a pointer management class, not a basic type.</div><div><br></div><div>=
=C2=A0- Again, I think it is handily tool, but easily overused - it makes y=
ou <i>not</i> think about=C2=A0copies of big objects, which will lead to to=
o=C2=A0may of them. </div><div>Not unlike how std::vector and std::string a=
re used by unexperienced programmers or ones coming from a different langua=
ge like Java or C#.</div><div><br></div><div>Everything will be an indirect=
<> to solve all memory management=C2=A0<span>discomforts</span>. </di=
v><div>Value sematic are great, but low number of copies is also great. I a=
m afraid this will lead to explosion (hidden)=C2=A0copies of big objects=C2=
=A0in user code. =C2=A0</div><div><br></div><div><br></div></div></blockquo=
te><div><br></div><div>Agreed, this is a potentially useful tool, not a sil=
ver bullet. `propagate_const` is cheaper (free) when copying is not require=
d.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:=
0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><d=
iv></div></div><span>
<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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
l_v-PsrKAAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:&=
#39;;return true;" onclick=3D"this.href=3D'javascript:';return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"l_v-PsrKAAAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'=
;javascript:';return true;">std-pr...@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/f88b96df-e3b2-4845-98d9-05c216cf47c3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D'https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/f88b96df-e3b2-4845-98d9-05c216cf47c3%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter';return true;" on=
click=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/f88b96df-e3b2-4845-98d9-05c216cf47c3%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter';return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/f88b96df-e3b2-4845-<wbr>98d9-=
05c216cf47c3%40isocpp.org</a><wbr>.<br>
</blockquote></div></div></div></blockquote><div><br>I like the idea of a p=
olymorphic value-like type. However, I believe that the proposed design is =
stuck in limbo between a pointer-like and value-like type:<br><ul><li>An <s=
pan style=3D"font-family: courier new,monospace;">indirect</span> is constr=
ucted from a pointer that it takes ownership of. Ideally, a value-like type=
would hide all memory management under the hood. Sure, <span style=3D"font=
-family: courier new,monospace;">make_indirect</span> exists, but the smart=
pointer-esque, ownership-transferring constructor is still visible.</li><l=
i>An <span style=3D"font-family: courier new,monospace;">indirect</span> ca=
n be empty. Emptiness/nullness is a very pointer-like trait. Being able to =
convert a value-like type to <span style=3D"font-family: courier new,monosp=
ace;">bool</span> to test for emptiness is very odd<span style=3D"font-fami=
ly: courier new,monospace;"></span>. A value-like type should always have a=
value.</li><li>Moving an <span style=3D"font-family: courier new,monospace=
;">indirect</span> doesn't move the underlying object. Copying invokes =
the copy constructor, so why doesn't moving invoke the move constructor=
? I realize you gain <span style=3D"font-family: courier new,monospace;">no=
except</span> status if you just move the internal pointer, but this isn=
9;t very value-like behaviour.</li><li>Deleters and copiers smell of resour=
ce management.</li></ul><p>I suggest the following:</p><ul><li><span style=
=3D"font-family: courier new,monospace;">indirect</span> should not use del=
eters or other special resource management functors.<br></li><li>The defaul=
t constructor of <span style=3D"font-family: courier new,monospace;">indire=
ct<T></span> should default construct a <span style=3D"font-family: c=
ourier new,monospace;">T</span> (or not exist if <span style=3D"font-family=
: courier new,monospace;">T</span> is not default constructible)</li><li>Th=
e copy and move constructors and assignment operators of <span style=3D"fon=
t-family: courier new,monospace;">indirect</span> should copy and move the =
underlying objects (<span style=3D"font-family: courier new,monospace;">T</=
span> must be copyable and movable)</li><li>An <span style=3D"font-family: =
courier new,monospace;">indirect<T></span> should be copy and move co=
nstructible and assignable from <span style=3D"font-family: courier new,mon=
ospace;">T</span>.<br></li><li>The <span style=3D"font-family: courier new,=
monospace;">in_place</span> technique can be used to construct <span style=
=3D"font-family: courier new,monospace;">indirect</span> efficiently from o=
ther arguments (no additional copies; no adopted pointer).</li><li><span st=
yle=3D"font-family: courier new,monospace;">indirect</span> should not be c=
onvertible to <span style=3D"font-family: courier new,monospace;">bool</spa=
n>. In fact, with this design it can no longer be in an empty state, so the=
re is no reason for such a conversion to exist.<br></li><li>Since <span sty=
le=3D"font-family: courier new,monospace;">indirect</span> implicitly upcas=
ts, <span style=3D"font-family: courier new,monospace;">static_indirect_cas=
t</span> and <span style=3D"font-family: courier new,monospace;">dynamic_in=
direct_cast</span> should be available for downcasting. However, const and =
reinterpret casts make no sense for a value-like type.<br></li></ul><p>This=
results in a value-like type that is much more consistent in its behaviour=
, and is potentially slightly more efficient in space and time. I have push=
ed a working sample implementation to a <a href=3D"https://github.com/hpeso=
j/indirect/blob/master/indirect.h">fork of your repository</a>. Note that i=
t is more inspired by your original implementation than an evolution of it,=
and the tests aren't complete by any means.</p><p><br></p><p>As for th=
e name, I'm not a huge fan of <span style=3D"font-family: courier new,m=
onospace;">std::indirect</span>, because it very much says "pointer&qu=
ot; to me. Perhaps something like <span style=3D"font-family: courier new,m=
onospace;">std::polymorphic</span> would be better.<br></p></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/b11f0d55-280a-4ff0-b6c2-9f197337364f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b11f0d55-280a-4ff0-b6c2-9f197337364f=
%40isocpp.org</a>.<br />
------=_Part_168_2077745130.1477504481193--
------=_Part_167_2085292732.1477504481193--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 26 Oct 2016 21:12:08 +0300
Raw View
On 26 October 2016 at 20:54, <joseph.thomson@gmail.com> wrote:
> I like the idea of a polymorphic value-like type. However, I believe that
> the proposed design is stuck in limbo between a pointer-like and value-like
> type:
>
> An indirect is constructed from a pointer that it takes ownership of.
> Ideally, a value-like type would hide all memory management under the hood.
> Sure, make_indirect exists, but the smart pointer-esque,
> ownership-transferring constructor is still visible.
> An indirect can be empty. Emptiness/nullness is a very pointer-like trait.
> Being able to convert a value-like type to bool to test for emptiness is
> very odd. A value-like type should always have a value.
> Moving an indirect doesn't move the underlying object. Copying invokes the
> copy constructor, so why doesn't moving invoke the move constructor? I
> realize you gain noexcept status if you just move the internal pointer, but
> this isn't very value-like behaviour.
> Deleters and copiers smell of resource management.
>
> I suggest the following:
>
> indirect should not use deleters or other special resource management
> functors.
> The default constructor of indirect<T> should default construct a T (or not
> exist if T is not default constructible)
> The copy and move constructors and assignment operators of indirect should
> copy and move the underlying objects (T must be copyable and movable)
> An indirect<T> should be copy and move constructible and assignable from T.
> The in_place technique can be used to construct indirect efficiently from
> other arguments (no additional copies; no adopted pointer).
> indirect should not be convertible to bool. In fact, with this design it can
> no longer be in an empty state, so there is no reason for such a conversion
> to exist.
> Since indirect implicitly upcasts, static_indirect_cast and
> dynamic_indirect_cast should be available for downcasting. However, const
> and reinterpret casts make no sense for a value-like type.
>
> This results in a value-like type that is much more consistent in its
> behaviour, and is potentially slightly more efficient in space and time. I
> have pushed a working sample implementation to a fork of your repository.
> Note that it is more inspired by your original implementation than an
> evolution of it, and the tests aren't complete by any means.
You're describing a completely different type with completely
different use cases.
For some (many) of the use cases the proposed indirect is catering
for, your proposed
type is completely useless.
--
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/CAFk2RUaHWiVFia7_1WfOGVjNFX717xoZc_u%3DZA-cApWUFfD-sA%40mail.gmail.com.
.
Author: joseph.thomson@gmail.com
Date: Wed, 26 Oct 2016 11:36:37 -0700 (PDT)
Raw View
------=_Part_4473_2018950143.1477506997796
Content-Type: multipart/alternative;
boundary="----=_Part_4474_540841219.1477506997796"
------=_Part_4474_540841219.1477506997796
Content-Type: text/plain; charset=UTF-8
On Thursday, 27 October 2016 02:12:10 UTC+8, Ville Voutilainen wrote:
>
> On 26 October 2016 at 20:54, <joseph....@gmail.com <javascript:>> wrote:
> > I like the idea of a polymorphic value-like type. However, I believe
> that
> > the proposed design is stuck in limbo between a pointer-like and
> value-like
> > type:
> >
> > An indirect is constructed from a pointer that it takes ownership of.
> > Ideally, a value-like type would hide all memory management under the
> hood.
> > Sure, make_indirect exists, but the smart pointer-esque,
> > ownership-transferring constructor is still visible.
> > An indirect can be empty. Emptiness/nullness is a very pointer-like
> trait.
> > Being able to convert a value-like type to bool to test for emptiness is
> > very odd. A value-like type should always have a value.
> > Moving an indirect doesn't move the underlying object. Copying invokes
> the
> > copy constructor, so why doesn't moving invoke the move constructor? I
> > realize you gain noexcept status if you just move the internal pointer,
> but
> > this isn't very value-like behaviour.
> > Deleters and copiers smell of resource management.
> >
> > I suggest the following:
> >
> > indirect should not use deleters or other special resource management
> > functors.
> > The default constructor of indirect<T> should default construct a T (or
> not
> > exist if T is not default constructible)
> > The copy and move constructors and assignment operators of indirect
> should
> > copy and move the underlying objects (T must be copyable and movable)
> > An indirect<T> should be copy and move constructible and assignable from
> T.
> > The in_place technique can be used to construct indirect efficiently
> from
> > other arguments (no additional copies; no adopted pointer).
> > indirect should not be convertible to bool. In fact, with this design it
> can
> > no longer be in an empty state, so there is no reason for such a
> conversion
> > to exist.
> > Since indirect implicitly upcasts, static_indirect_cast and
> > dynamic_indirect_cast should be available for downcasting. However,
> const
> > and reinterpret casts make no sense for a value-like type.
> >
> > This results in a value-like type that is much more consistent in its
> > behaviour, and is potentially slightly more efficient in space and time.
> I
> > have pushed a working sample implementation to a fork of your
> repository.
> > Note that it is more inspired by your original implementation than an
> > evolution of it, and the tests aren't complete by any means.
>
> You're describing a completely different type with completely
> different use cases.
> For some (many) of the use cases the proposed indirect is catering
> for, your proposed
> type is completely useless.
>
Like what? My design seems perfectly in-line with the aims of the proposal,
namely to have a wrapper type which can hold free-store-allocated objects
polymorphically with value-like semantics.
--
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/0921ce76-4294-460d-9bd4-ad2816741b10%40isocpp.org.
------=_Part_4474_540841219.1477506997796
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, 27 October 2016 02:12:10 UTC+8, Ville Voutila=
inen wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 26 October 2016=
at 20:54, =C2=A0<<a href=3D"javascript:" target=3D"_blank" gdf-obfuscat=
ed-mailto=3D"fvl1UjiEAQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'=
;javascript:';return true;" onclick=3D"this.href=3D'javascript:'=
;;return true;">joseph....@gmail.com</a>> wrote:
<br>> I like the idea of a polymorphic value-like type. However, I belie=
ve that
<br>> the proposed design is stuck in limbo between a pointer-like and v=
alue-like
<br>> type:
<br>>
<br>> An indirect is constructed from a pointer that it takes ownership =
of.
<br>> Ideally, a value-like type would hide all memory management under =
the hood.
<br>> Sure, make_indirect exists, but the smart pointer-esque,
<br>> ownership-transferring constructor is still visible.
<br>> An indirect can be empty. Emptiness/nullness is a very pointer-lik=
e trait.
<br>> Being able to convert a value-like type to bool to test for emptin=
ess is
<br>> very odd. A value-like type should always have a value.
<br>> Moving an indirect doesn't move the underlying object. Copying=
invokes the
<br>> copy constructor, so why doesn't moving invoke the move constr=
uctor? I
<br>> realize you gain noexcept status if you just move the internal poi=
nter, but
<br>> this isn't very value-like behaviour.
<br>> Deleters and copiers smell of resource management.
<br>>
<br>> I suggest the following:
<br>>
<br>> indirect should not use deleters or other special resource managem=
ent
<br>> functors.
<br>> The default constructor of indirect<T> should default constr=
uct a T (or not
<br>> exist if T is not default constructible)
<br>> The copy and move constructors and assignment operators of indirec=
t should
<br>> copy and move the underlying objects (T must be copyable and movab=
le)
<br>> An indirect<T> should be copy and move constructible and ass=
ignable from T.
<br>> The in_place technique can be used to construct indirect efficient=
ly from
<br>> other arguments (no additional copies; no adopted pointer).
<br>> indirect should not be convertible to bool. In fact, with this des=
ign it can
<br>> no longer be in an empty state, so there is no reason for such a c=
onversion
<br>> to exist.
<br>> Since indirect implicitly upcasts, static_indirect_cast and
<br>> dynamic_indirect_cast should be available for downcasting. However=
, const
<br>> and reinterpret casts make no sense for a value-like type.
<br>>
<br>> This results in a value-like type that is much more consistent in =
its
<br>> behaviour, and is potentially slightly more efficient in space and=
time. I
<br>> have pushed a working sample implementation to a fork of your repo=
sitory.
<br>> Note that it is more inspired by your original implementation than=
an
<br>> evolution of it, and the tests aren't complete by any means.
<br>
<br>You're describing a completely different type with completely
<br>different use cases.
<br>For some (many) of the use cases the proposed indirect is catering
<br>for, your proposed
<br>type is completely useless.
<br></blockquote><div><br>Like what? My design seems perfectly in-line with=
the aims of the proposal, namely to have a wrapper type which can hold fre=
e-store-allocated objects polymorphically with value-like semantics.<br></d=
iv></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/0921ce76-4294-460d-9bd4-ad2816741b10%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0921ce76-4294-460d-9bd4-ad2816741b10=
%40isocpp.org</a>.<br />
------=_Part_4474_540841219.1477506997796--
------=_Part_4473_2018950143.1477506997796--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 26 Oct 2016 21:44:56 +0300
Raw View
On 26 October 2016 at 21:36, <joseph.thomson@gmail.com> wrote:
>> You're describing a completely different type with completely
>> different use cases.
>> For some (many) of the use cases the proposed indirect is catering
>> for, your proposed
>> type is completely useless.
>
>
> Like what? My design seems perfectly in-line with the aims of the proposal,
Being able to allow the user to adapt a non-copyable type to be cloned
by indirect,
and being able to use indirect instead of a hand-written solution that can clone
polymorphic types via pointers, with the ability to adopt a pointer
directly without
needing an extra clone. Basically, to do most of the things a pointer can do,
with the cloning ability.
--
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/CAFk2RUbamO38vehB54iTGvL9Nyu9DjniYi5bAw6muNLuODLBsg%40mail.gmail.com.
.
Author: joseph.thomson@gmail.com
Date: Wed, 26 Oct 2016 12:11:00 -0700 (PDT)
Raw View
------=_Part_715_956266350.1477509060932
Content-Type: multipart/alternative;
boundary="----=_Part_716_1546296515.1477509060932"
------=_Part_716_1546296515.1477509060932
Content-Type: text/plain; charset=UTF-8
On Thursday, 27 October 2016 02:44:59 UTC+8, Ville Voutilainen wrote:
>
> On 26 October 2016 at 21:36, <joseph....@gmail.com <javascript:>> wrote:
> >> You're describing a completely different type with completely
> >> different use cases.
> >> For some (many) of the use cases the proposed indirect is catering
> >> for, your proposed
> >> type is completely useless.
> >
> >
> > Like what? My design seems perfectly in-line with the aims of the
> proposal,
>
> Being able to allow the user to adapt a non-copyable type to be cloned
> by indirect,
> and being able to use indirect instead of a hand-written solution that can
> clone
> polymorphic types via pointers, with the ability to adopt a pointer
> directly without
> needing an extra clone. Basically, to do most of the things a pointer can
> do,
> with the cloning ability.
>
Neither of these use cases is stated in the proposal. And if the type is
meant to basically be a copyable unique_ptr, then it probably needs to go
back to being called cloned_ptr and embrace its status as a
resource-managing pointer-like type. The proposed behaviour of indirect
isn't really very value-like; it's a weird mix of value-like and
pointer-like.
--
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/e872629c-88cd-4355-a1fa-429196668936%40isocpp.org.
------=_Part_716_1546296515.1477509060932
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, 27 October 2016 02:44:59 UTC+8, Ville Voutila=
inen wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 26 October 2016=
at 21:36, =C2=A0<<a href=3D"javascript:" target=3D"_blank" gdf-obfuscat=
ed-mailto=3D"nlo-uAKGAQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'=
;javascript:';return true;" onclick=3D"this.href=3D'javascript:'=
;;return true;">joseph....@gmail.com</a>> wrote:
<br>>> You're describing a completely different type with complet=
ely
<br>>> different use cases.
<br>>> For some (many) of the use cases the proposed indirect is cate=
ring
<br>>> for, your proposed
<br>>> type is completely useless.
<br>>
<br>>
<br>> Like what? My design seems perfectly in-line with the aims of the =
proposal,
<br>
<br>Being able to allow the user to adapt a non-copyable type to be cloned
<br>by indirect,
<br>and being able to use indirect instead of a hand-written solution that =
can clone
<br>polymorphic types via pointers, with the ability to adopt a pointer
<br>directly without
<br>needing an extra clone. Basically, to do most of the things a pointer c=
an do,
<br>with the cloning ability.<br></blockquote><div><br>Neither of these use=
cases is stated in the proposal. And if the type is meant to basically be =
a copyable <span style=3D"font-family: courier new,monospace;">unique_ptr</=
span>, then it probably needs to go back to being called <span style=3D"fon=
t-family: courier new,monospace;">cloned_ptr</span> and embrace its status =
as a resource-managing pointer-like type. The proposed behaviour of <span s=
tyle=3D"font-family: courier new,monospace;">indirect</span> isn't real=
ly very value-like; it's a weird mix of value-like and pointer-like.<br=
></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/e872629c-88cd-4355-a1fa-429196668936%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/e872629c-88cd-4355-a1fa-429196668936=
%40isocpp.org</a>.<br />
------=_Part_716_1546296515.1477509060932--
------=_Part_715_956266350.1477509060932--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 26 Oct 2016 22:13:24 +0300
Raw View
On 26 October 2016 at 22:11, <joseph.thomson@gmail.com> wrote:
>> Being able to allow the user to adapt a non-copyable type to be cloned
>> by indirect,
>> and being able to use indirect instead of a hand-written solution that can
>> clone
>> polymorphic types via pointers, with the ability to adopt a pointer
>> directly without
>> needing an extra clone. Basically, to do most of the things a pointer can
>> do,
>> with the cloning ability.
>
>
> Neither of these use cases is stated in the proposal.
Yet indirect<T> supports those use cases fine, because their
motivation comes from
practical experience.
> And if the type is
> meant to basically be a copyable unique_ptr, then it probably needs to go
> back to being called cloned_ptr and embrace its status as a
> resource-managing pointer-like type. The proposed behaviour of indirect
> isn't really very value-like; it's a weird mix of value-like and
> pointer-like.
Well, it's apparently following LEWG's guidance.
--
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/CAFk2RUZRDT%2BD6W4%3DLkNAYSikXNP0opOtFcq9gPSymN8RzGMX-w%40mail.gmail.com.
.
Author: Jonathan Coe <jonathanbcoe@gmail.com>
Date: Wed, 26 Oct 2016 20:17:16 +0100
Raw View
> On 26 Oct 2016, at 20:13, Ville Voutilainen <ville.voutilainen@gmail.com> wrote:
>
> On 26 October 2016 at 22:11, <joseph.thomson@gmail.com> wrote:
>>> Being able to allow the user to adapt a non-copyable type to be cloned
>>> by indirect,
>>> and being able to use indirect instead of a hand-written solution that can
>>> clone
>>> polymorphic types via pointers, with the ability to adopt a pointer
>>> directly without
>>> needing an extra clone. Basically, to do most of the things a pointer can
>>> do,
>>> with the cloning ability.
>>
>>
>> Neither of these use cases is stated in the proposal.
>
> Yet indirect<T> supports those use cases fine, because their
> motivation comes from
> practical experience.
>
>> And if the type is
>> meant to basically be a copyable unique_ptr, then it probably needs to go
>> back to being called cloned_ptr and embrace its status as a
>> resource-managing pointer-like type. The proposed behaviour of indirect
>> isn't really very value-like; it's a weird mix of value-like and
>> pointer-like.
>
Which bits are 'pointer-like'?
It's more value-like than it was but may have further to go.
> Well, it's apparently following LEWG's guidance.
>
> --
> 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/CAFk2RUZRDT%2BD6W4%3DLkNAYSikXNP0opOtFcq9gPSymN8RzGMX-w%40mail.gmail.com.
--
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/80EB0663-B834-488C-85A7-2767F6196BCF%40gmail.com.
.
Author: joseph.thomson@gmail.com
Date: Wed, 26 Oct 2016 12:50:15 -0700 (PDT)
Raw View
------=_Part_2179_524317672.1477511415398
Content-Type: multipart/alternative;
boundary="----=_Part_2180_1211258991.1477511415399"
------=_Part_2180_1211258991.1477511415399
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Thursday, 27 October 2016 03:17:20 UTC+8, Jonathan Coe wrote:
>
>
>
> > On 26 Oct 2016, at 20:13, Ville Voutilainen <ville.vo...@gmail.com=20
> <javascript:>> wrote:=20
> >=20
> > On 26 October 2016 at 22:11, <joseph....@gmail.com <javascript:>>=20
> wrote:=20
> >>> Being able to allow the user to adapt a non-copyable type to be clone=
d=20
> >>> by indirect,=20
> >>> and being able to use indirect instead of a hand-written solution tha=
t=20
> can=20
> >>> clone=20
> >>> polymorphic types via pointers, with the ability to adopt a pointer=
=20
> >>> directly without=20
> >>> needing an extra clone. Basically, to do most of the things a pointer=
=20
> can=20
> >>> do,=20
> >>> with the cloning ability.=20
> >>=20
> >>=20
> >> Neither of these use cases is stated in the proposal.=20
> >=20
> > Yet indirect<T> supports those use cases fine, because their=20
> > motivation comes from=20
> > practical experience.=20
> >=20
> >> And if the type is=20
> >> meant to basically be a copyable unique_ptr, then it probably needs to=
=20
> go=20
> >> back to being called cloned_ptr and embrace its status as a=20
> >> resource-managing pointer-like type. The proposed behaviour of indirec=
t=20
> >> isn't really very value-like; it's a weird mix of value-like and=20
> >> pointer-like.=20
> >=20
>
> Which bits are 'pointer-like'?=20
> It's more value-like than it was but may have further to go.=20
>
I thought I outlined the parts that I consider pointer-like, but I can give=
=20
examples comparing the current implementation and my example=20
implementation. I'll use polymorphic as the name for my version, just to=20
disambiguate:
T t; // t default constructed (value-like)
polymorphic<T> p; // *p default constructed (value-like)
indirect<T> i; // i is empty (pointer-like)
T t =3D tt; // t copy constructed (value-like)
polymorphic<T> p =3D tt; // *p copy constructed (value-like)
indirect<T> i =3D tt; // error: cannot assign from T (pointer-like)
T t =3D std::move(tt); // t move constructed; tt moved from (value-like)
polymorphic<T> p =3D std::move(pp); // *p move constructed; *pp moved from=
=20
(value-like)
indirect<T> i =3D std::move(ii); // ownership transferred from ii to i; ii=
=20
now empty (pointer-like)
T t{1, 2, 3}; // t constructed in-place with arguments (value-like)
polymorphic<T> p{in_place, 1, 2, 3}; // *p constructed in-place with=20
arguments (value-like)
indirect<T> i{new T{1, 2, 3}}; // i constructed from pointer that it takes=
=20
ownership of (pointer-like)
// note: operator bool not defined for T
if (t) { =E2=80=A6 } // error: t cannot convert to bool (value-like)
if (p) { =E2=80=A6 } // error: p cannot convert to bool (value-like)
if (i) { =E2=80=A6 } // i checked for empty status (pointer-like)
> Well, it's apparently following LEWG's guidance.=20
> >=20
> > --=20
> > You received this message because you are subscribed to the Google=20
> Groups "ISO C++ Standard - Future Proposals" group.=20
> > To unsubscribe from this group and stop receiving emails from it, send=
=20
> an email to std-proposal...@isocpp.org <javascript:>.=20
> > To post to this group, send email to std-pr...@isocpp.org <javascript:>=
..=20
>
> > To view this discussion on the web visit=20
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUZRDT%=
2BD6W4%3DLkNAYSikXNP0opOtFcq9gPSymN8RzGMX-w%40mail.gmail.com.=20
>
>
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/754c5bb6-b821-4565-8dd0-76c1fb2b5a7a%40isocpp.or=
g.
------=_Part_2180_1211258991.1477511415399
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, 27 October 2016 03:17:20 UTC+8, Jonathan Coe =
wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.=
8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<br>
<br>> On 26 Oct 2016, at 20:13, Ville Voutilainen <<a href=3D"javascr=
ipt:" target=3D"_blank" gdf-obfuscated-mailto=3D"8kxip8aHAQAJ" rel=3D"nofol=
low" onmousedown=3D"this.href=3D'javascript:';return true;" onclick=
=3D"this.href=3D'javascript:';return true;">ville.vo...@gmail.com</=
a>> wrote:
<br>>=20
<br>> On 26 October 2016 at 22:11, =C2=A0<<a href=3D"javascript:" tar=
get=3D"_blank" gdf-obfuscated-mailto=3D"8kxip8aHAQAJ" rel=3D"nofollow" onmo=
usedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.=
href=3D'javascript:';return true;">joseph....@gmail.com</a>> wro=
te:
<br>>>> Being able to allow the user to adapt a non-copyable type =
to be cloned
<br>>>> by indirect,
<br>>>> and being able to use indirect instead of a hand-written s=
olution that can
<br>>>> clone
<br>>>> polymorphic types via pointers, with the ability to adopt =
a pointer
<br>>>> directly without
<br>>>> needing an extra clone. Basically, to do most of the thing=
s a pointer can
<br>>>> do,
<br>>>> with the cloning ability.
<br>>>=20
<br>>>=20
<br>>> Neither of these use cases is stated in the proposal.
<br>>=20
<br>> Yet indirect<T> supports those use cases fine, because their
<br>> motivation comes from
<br>> practical experience.
<br>>=20
<br>>> And if the type is
<br>>> meant to basically be a copyable unique_ptr, then it probably =
needs to go
<br>>> back to being called cloned_ptr and embrace its status as a
<br>>> resource-managing pointer-like type. The proposed behaviour of=
indirect
<br>>> isn't really very value-like; it's a weird mix of valu=
e-like and
<br>>> pointer-like.
<br>>=20
<br>
<br>Which bits are 'pointer-like'?
<br>It's more value-like than it was but may have further to go.
<br></blockquote><div><br>I thought I outlined the parts that I consider po=
inter-like, but I can give examples comparing the current implementation an=
d my example implementation. I'll use polymorphic as the name for my ve=
rsion, just to disambiguate:<br><br><div style=3D"background-color: rgb(250=
, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-=
width: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #000;"=
class=3D"styled-by-prettify">T 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 style=3D"color: #800;" class=3D"styled-by-pret=
tify">// t default constructed (value-like)</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>polymorphic</span><span style=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;" class=3D"st=
yled-by-prettify"> p</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">// *p de=
fault constructed (value-like)</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>indirect</span><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 style=3D"color: #000;" class=3D"styled-by-prettif=
y"> i</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #800;" class=3D"styled-by-prettify">// i is empty (pointer-=
like)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
br>T t </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> tt</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">// t copy constructed (value-like)<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>polymor=
phic</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">T</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">></span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> p </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> tt</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-p=
rettify">// *p copy constructed (value-like)</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>indirect</span><span style=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;" class=3D"style=
d-by-prettify"> i </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> tt</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #800;" class=3D"styled-by-prettify">// error: cannot assign =
from T (pointer-like)</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br><br>T t </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">move</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">tt</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;" cl=
ass=3D"styled-by-prettify">// t move constructed; tt moved from (value-like=
)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>polym=
orphic</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">></span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> p </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">move</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">pp</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">// *p move const=
ructed; *pp moved from (value-like)</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>indirect</span><span style=3D"color: #660;" cl=
ass=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-b=
y-prettify">></span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> i </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">move</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">ii</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">// ownership transferred from ii to i; ii now empty (pointer=
-like)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
<br>T t</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</=
span><span style=3D"color: #066;" class=3D"styled-by-prettify">1</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=
: #066;" class=3D"styled-by-prettify">2</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">3</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">// t constructe=
d in-place with arguments (value-like)</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br>polymorphic</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">T</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> p</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify">in_pl=
ace</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #066;" class=3D"styled-by-prettify">1</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: #066;" class=
=3D"styled-by-prettify">2</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">3</=
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">// *p constructed in-place w=
ith arguments (value-like)</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>indirect</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify"><</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">></span><span style=3D"color: #000;" class=3D"styled-by-prettify"> i<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">new</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #066;=
" class=3D"styled-by-prettify">1</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: #066;" class=3D"styled-by-pret=
tify">2</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">3</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">}};</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">// i constructed from pointer that it takes =
ownership of (pointer-like)</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br></span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">// note: operator bool not defined for T</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">if</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"style=
d-by-prettify">t</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">{</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=E2=80=A6</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: #800;" class=3D"=
styled-by-prettify">// error: t cannot convert to bool (value-like)</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">if</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">p</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">=E2=80=A6</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"> </span><span style=3D"color: #800;" =
class=3D"styled-by-prettify">// error: p cannot convert to bool (value-like=
)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">if</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: #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">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">=E2=80=A6</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">// i checked for empty status (pointe=
r-like)</span></div></code></div><br><br></div><blockquote class=3D"gmail_q=
uote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;pad=
ding-left: 1ex;">> Well, it's apparently following LEWG's guidan=
ce.
<br>>=20
<br>> --=20
<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=3D"javascript:" target=3D"_blank" gdf-obfuscated-m=
ailto=3D"8kxip8aHAQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'jav=
ascript:';return true;" onclick=3D"this.href=3D'javascript:';re=
turn true;">std-proposal...@<wbr>isocpp.org</a>.
<br>> To post to this group, send email to <a href=3D"javascript:" targe=
t=3D"_blank" gdf-obfuscated-mailto=3D"8kxip8aHAQAJ" rel=3D"nofollow" onmous=
edown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.hr=
ef=3D'javascript:';return true;">std-pr...@isocpp.org</a>.
<br>> To view this discussion on the web visit <a href=3D"https://groups=
..google.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUZRDT%2BD6W4%3DLkNAYSi=
kXNP0opOtFcq9gPSymN8RzGMX-w%40mail.gmail.com" target=3D"_blank" rel=3D"nofo=
llow" onmousedown=3D"this.href=3D'https://groups.google.com/a/isocpp.or=
g/d/msgid/std-proposals/CAFk2RUZRDT%2BD6W4%3DLkNAYSikXNP0opOtFcq9gPSymN8RzG=
MX-w%40mail.gmail.com';return true;" onclick=3D"this.href=3D'https:=
//groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUZRDT%2BD6W4%3=
DLkNAYSikXNP0opOtFcq9gPSymN8RzGMX-w%40mail.gmail.com';return true;">htt=
ps://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/CAFk2RU=
ZRDT%2BD6W4%<wbr>3DLkNAYSikXNP0opOtFcq9gPSymN8R<wbr>zGMX-w%40mail.gmail.com=
</a>.
<br></blockquote></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/754c5bb6-b821-4565-8dd0-76c1fb2b5a7a%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/754c5bb6-b821-4565-8dd0-76c1fb2b5a7a=
%40isocpp.org</a>.<br />
------=_Part_2180_1211258991.1477511415399--
------=_Part_2179_524317672.1477511415398--
.
Author: mihailnajdenov@gmail.com
Date: Wed, 26 Oct 2016 13:28:17 -0700 (PDT)
Raw View
------=_Part_1006_170734791.1477513697348
Content-Type: multipart/alternative;
boundary="----=_Part_1007_537633483.1477513697348"
------=_Part_1007_537633483.1477513697348
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
>
> ...
>
> T t; // t default constructed (value-like)
> polymorphic<T> p; // *p default constructed (value-like)
> indirect<T> i; // i is empty (pointer-like)
>
> T t =3D tt; // t copy constructed (value-like)
> polymorphic<T> p =3D tt; // *p copy constructed (value-like)
> indirect<T> i =3D tt; // error: cannot assign from T (pointer-like)
>
> T t =3D std::move(tt); // t move constructed; tt moved from (value-like)
> polymorphic<T> p =3D std::move(pp); // *p move constructed; *pp moved fro=
m=20
> (value-like)
> indirect<T> i =3D std::move(ii); // ownership transferred from ii to i; i=
i=20
> now empty (pointer-like)
>
> T t{1, 2, 3}; // t constructed in-place with arguments (value-like)
> polymorphic<T> p{in_place, 1, 2, 3}; // *p constructed in-place with=20
> arguments (value-like)
> indirect<T> i{new T{1, 2, 3}}; // i constructed from pointer that it=20
> takes ownership of (pointer-like)
>
> // note: operator bool not defined for T
> if (t) { =E2=80=A6 } // error: t cannot convert to bool (value-like)
> if (p) { =E2=80=A6 } // error: p cannot convert to bool (value-like)
> if (i) { =E2=80=A6 } // i checked for empty status (pointer-like)
>
I agree it is more close to pointer then to a value, but that's a good=20
thing. It should feel, you are managing a remote recourse. =20
Also, note that indirect<>, is intended to be constructed with=20
make_indirect NOT with the ctor with a pointer.=20
About polymorphic=20
The way it is right now, you do many allocations, just to pretend it is a=
=20
real variable on the stack - allocating default ctor, not empty after move,=
=20
etc.=20
All these I don't think are of benefit compared to the cost.
Assignment from raw value however might be useful, especially move=20
assignment.=20
Lastly, I find custom copier and deleter to be essential for the class to=
=20
be useful.=20
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/01eb6560-8902-40e3-af54-c395f3d3d33d%40isocpp.or=
g.
------=_Part_1007_537633483.1477513697348
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>...<br><=
br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187=
,187);border-style:solid;border-width:1px"><code><div><span style=3D"color:=
#000">T t</span><span style=3D"color:#660">;</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#800">// t default constructed (value-like)=
</span><span style=3D"color:#000"><br>polymorphic</span><span style=3D"colo=
r:#660"><</span><span style=3D"color:#000">T</span><span style=3D"color:=
#660">></span><span style=3D"color:#000"> p</span><span style=3D"color:#=
660">;</span><span style=3D"color:#000"> </span><span style=3D"color:#800">=
// *p default constructed (value-like)</span><span style=3D"color:#000"><br=
>indirect</span><span style=3D"color:#660"><</span><span style=3D"color:=
#000">T</span><span style=3D"color:#660">></span><span style=3D"color:#0=
00"> i</span><span style=3D"color:#660">;</span><span style=3D"color:#000">=
</span><span style=3D"color:#800">// i is empty (pointer-like)</span><span=
style=3D"color:#000"><br><br>T t </span><span style=3D"color:#660">=3D</sp=
an><span style=3D"color:#000"> tt</span><span style=3D"color:#660">;</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#800">// t copy con=
structed (value-like)</span><span style=3D"color:#000"><br>polymorphic</spa=
n><span style=3D"color:#660"><</span><span style=3D"color:#000">T</span>=
<span style=3D"color:#660">></span><span style=3D"color:#000"> p </span>=
<span style=3D"color:#660">=3D</span><span style=3D"color:#000"> tt</span><=
span style=3D"color:#660">;</span><span style=3D"color:#000"> </span><span =
style=3D"color:#800">// *p copy constructed (value-like)</span><span style=
=3D"color:#000"><br>indirect</span><span style=3D"color:#660"><</span><s=
pan style=3D"color:#000">T</span><span style=3D"color:#660">></span><spa=
n style=3D"color:#000"> i </span><span style=3D"color:#660">=3D</span><span=
style=3D"color:#000"> tt</span><span style=3D"color:#660">;</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#800">// error: cannot assi=
gn from T (pointer-like)</span><span style=3D"color:#000"><br><br>T t </spa=
n><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> std</spa=
n><span style=3D"color:#660">::</span><span style=3D"color:#000">move</span=
><span style=3D"color:#660">(</span><span style=3D"color:#000">tt</span><sp=
an style=3D"color:#660">);</span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#800">// t move constructed; tt moved from (value-like)</span=
><span style=3D"color:#000"><br>polymorphic</span><span style=3D"color:#660=
"><</span><span style=3D"color:#000">T</span><span style=3D"color:#660">=
></span><span style=3D"color:#000"> p </span><span style=3D"color:#660">=
=3D</span><span style=3D"color:#000"> std</span><span style=3D"color:#660">=
::</span><span style=3D"color:#000">move</span><span style=3D"color:#660">(=
</span><span style=3D"color:#000">pp</span><span style=3D"color:#660">);</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#800">// *p mov=
e constructed; *pp moved from (value-like)</span><span style=3D"color:#000"=
><br>indirect</span><span style=3D"color:#660"><</span><span style=3D"co=
lor:#000">T</span><span style=3D"color:#660">></span><span style=3D"colo=
r:#000"> i </span><span style=3D"color:#660">=3D</span><span style=3D"color=
:#000"> std</span><span style=3D"color:#660">::</span><span style=3D"color:=
#000">move</span><span style=3D"color:#660">(</span><span style=3D"color:#0=
00">ii</span><span style=3D"color:#660">);</span><span style=3D"color:#000"=
> </span><span style=3D"color:#800">// ownership transferred from ii to i; =
ii now empty (pointer-like)</span><span style=3D"color:#000"><br><br>T t</s=
pan><span style=3D"color:#660">{</span><span style=3D"color:#066">1</span><=
span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span =
style=3D"color:#066">2</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> </span><span style=3D"color:#066">3</span><span style=3D"c=
olor:#660">};</span><span style=3D"color:#000"> </span><span style=3D"color=
:#800">// t constructed in-place with arguments (value-like)</span><span st=
yle=3D"color:#000"><br>polymorphic</span><span style=3D"color:#660"><</s=
pan><span style=3D"color:#000">T</span><span style=3D"color:#660">></spa=
n><span style=3D"color:#000"> p</span><span style=3D"color:#660">{</span><s=
pan style=3D"color:#000">in_place</span><span style=3D"color:#660">,</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#066">1</span><span=
style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#066">2</span><span style=3D"color:#660">,</span><span style=3D"=
color:#000"> </span><span style=3D"color:#066">3</span><span style=3D"color=
:#660">};</span><span style=3D"color:#000"> </span><span style=3D"color:#80=
0">// *p constructed in-place with arguments (value-like)</span><span style=
=3D"color:#000"><br>indirect</span><span style=3D"color:#660"><</span><s=
pan style=3D"color:#000">T</span><span style=3D"color:#660">></span><spa=
n style=3D"color:#000"> i</span><span style=3D"color:#660">{</span><span st=
yle=3D"color:#008">new</span><span style=3D"color:#000"> T</span><span styl=
e=3D"color:#660">{</span><span style=3D"color:#066">1</span><span style=3D"=
color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color=
:#066">2</span><span style=3D"color:#660">,</span><span style=3D"color:#000=
"> </span><span style=3D"color:#066">3</span><span style=3D"color:#660">}};=
</span><span style=3D"color:#000"> </span><span style=3D"color:#800">// i c=
onstructed from pointer that it takes ownership of (pointer-like)</span><sp=
an style=3D"color:#000"><br><br></span><span style=3D"color:#800">// note: =
operator bool not defined for T</span><span style=3D"color:#000"><br></span=
><span style=3D"color:#008">if</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#660">(</span><span style=3D"color:#000">t</span><span st=
yle=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">{</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">=E2=80=A6</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">}</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#800">// error: t cannot convert to bool (value-like)</span><span styl=
e=3D"color:#000"><br></span><span style=3D"color:#008">if</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">(</span><span style=3D"c=
olor:#000">p</span><span style=3D"color:#660">)</span><span style=3D"color:=
#000"> </span><span style=3D"color:#660">{</span><span style=3D"color:#000"=
> </span><span style=3D"color:#660">=E2=80=A6</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#660">}</span><span style=3D"color:#000"> =
</span><span style=3D"color:#800">// error: p cannot convert to bool (value=
-like)</span><span style=3D"color:#000"><br></span><span style=3D"color:#00=
8">if</span><span style=3D"color:#000"> </span><span style=3D"color:#660">(=
</span><span style=3D"color:#000">i</span><span style=3D"color:#660">)</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#660">{</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#660">=E2=80=A6</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#660">}</span><span=
style=3D"color:#000"> </span><span style=3D"color:#800">// i checked for e=
mpty status (pointer-like)</span></div></code></div></div></div></blockquot=
e><div><br></div><div>I agree it is more close=C2=A0to pointer then to a va=
lue, but that's a good thing. It should feel, you are managing a remote=
recourse. =C2=A0=C2=A0</div><div><br></div><div>Also, note that indirect&l=
t;>, is intended to be constructed with make_indirect NOT with the ctor =
with a pointer. </div><div><br></div><div>About <font color=3D"#000000">pol=
ymorphic</font>=C2=A0</div><div>The way it is right now, you do many alloca=
tions, just to pretend it is a real variable on the stack - allocating defa=
ult ctor, not empty after move, etc. </div><div>All these I don't think=
are of benefit compared to the cost.</div><div><br></div><div>Assignment f=
rom raw value however=C2=A0might be useful, especially move assignment. </d=
iv><div><br></div><div><font color=3D"#000000">Lastly, I find custom copier=
and deleter to be essential for the class to be useful. </font></div><div>=
<font color=3D"#000000"><br></font></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/01eb6560-8902-40e3-af54-c395f3d3d33d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/01eb6560-8902-40e3-af54-c395f3d3d33d=
%40isocpp.org</a>.<br />
------=_Part_1007_537633483.1477513697348--
------=_Part_1006_170734791.1477513697348--
.
Author: Bengt Gustafsson <bengt.gustafsson@beamways.com>
Date: Wed, 26 Oct 2016 15:40:50 -0700 (PDT)
Raw View
------=_Part_16_1020449850.1477521650843
Content-Type: multipart/alternative;
boundary="----=_Part_17_1360629977.1477521650843"
------=_Part_17_1360629977.1477521650843
Content-Type: text/plain; charset=UTF-8
Yes, I think the need for being able to supply a copier and deleter defeats
any attempt to make an "emplace style" constructor. How can we know where
each parameter is to go?
For the original proposal it seems that make_indirect() would also need
these optional parameters so it would end up in the same bad place... the
only way I can think of to handle this would be to make four different
function names. What am I missing?
--
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/2c2c8ae1-4a6e-45c6-b53e-8fb5bd913518%40isocpp.org.
------=_Part_17_1360629977.1477521650843
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Yes, I think the need for being able to supply a copier an=
d deleter defeats any attempt to make an "emplace style" construc=
tor. How can we know where each parameter is to go?<div><br></div><div>For =
the original proposal it seems that make_indirect() would also need these o=
ptional parameters so it would end up in the same bad place... the only way=
I can think of to handle this would be to make four different function nam=
es. What am I missing?</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/2c2c8ae1-4a6e-45c6-b53e-8fb5bd913518%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/2c2c8ae1-4a6e-45c6-b53e-8fb5bd913518=
%40isocpp.org</a>.<br />
------=_Part_17_1360629977.1477521650843--
------=_Part_16_1020449850.1477521650843--
.
Author: joseph.thomson@gmail.com
Date: Wed, 26 Oct 2016 21:52:35 -0700 (PDT)
Raw View
------=_Part_278_933223176.1477543956105
Content-Type: multipart/alternative;
boundary="----=_Part_279_582691260.1477543956106"
------=_Part_279_582691260.1477543956106
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Thursday, 27 October 2016 04:28:17 UTC+8, mihailn...@gmail.com wrote:
>
> ...
>>
>> T t; // t default constructed (value-like)
>> polymorphic<T> p; // *p default constructed (value-like)
>> indirect<T> i; // i is empty (pointer-like)
>>
>> T t =3D tt; // t copy constructed (value-like)
>> polymorphic<T> p =3D tt; // *p copy constructed (value-like)
>> indirect<T> i =3D tt; // error: cannot assign from T (pointer-like)
>>
>> T t =3D std::move(tt); // t move constructed; tt moved from (value-like)
>> polymorphic<T> p =3D std::move(pp); // *p move constructed; *pp moved fr=
om=20
>> (value-like)
>> indirect<T> i =3D std::move(ii); // ownership transferred from ii to i; =
ii=20
>> now empty (pointer-like)
>>
>> T t{1, 2, 3}; // t constructed in-place with arguments (value-like)
>> polymorphic<T> p{in_place, 1, 2, 3}; // *p constructed in-place with=20
>> arguments (value-like)
>> indirect<T> i{new T{1, 2, 3}}; // i constructed from pointer that it=20
>> takes ownership of (pointer-like)
>>
>> // note: operator bool not defined for T
>> if (t) { =E2=80=A6 } // error: t cannot convert to bool (value-like)
>> if (p) { =E2=80=A6 } // error: p cannot convert to bool (value-like)
>> if (i) { =E2=80=A6 } // i checked for empty status (pointer-like)
>>
>
> I agree it is more close to pointer then to a value, but that's a good=20
> thing. It should feel, you are managing a remote recourse. =20
>
=20
I have no problem with a cloned_ptr proposal (essentially unique_ptr + deep=
=20
copy (+ const-propagation, maybe). I just think the aims of the current=20
proposal are confused. If it wants to be a polymorphic value-like type, I=
=20
suggest something similar to what I presented. If it wants to be a=20
deep-copying pointer-like type, then the chosen name should suggest that (I=
=20
like deep_copy_ptr), and it should probably support the appropriate=20
pointer-like operations (e.g. p =3D nullptr, p.get(), p.reset(x)).
Also, note that indirect<>, is intended to be constructed with=20
> make_indirect NOT with the ctor with a pointer.=20
>
=20
This doesn't fix the fact that the only way to directly construct indirect,=
=20
a supposedly value-like type, is by passing it ownership of a raw pointer.
About polymorphic=20
> The way it is right now, you do many allocations, just to pretend it is a=
=20
> real variable on the stack - allocating default ctor, not empty after mov=
e,=20
> etc.=20
> All these I don't think are of benefit compared to the cost.
>
=20
That's the idea. It behaves just like a stack-allocated object, but with=20
polymorphism. If you can't afford the copies, then maybe you need a=20
deep_copy_ptr instead.
Assignment from raw value however might be useful, especially move=20
> assignment.=20
>
=20
Assignment from T is only really possible when you ditch the deleter and=20
copier (it is only safe when using default_delete and default_copy).
Lastly, I find custom copier and deleter to be essential for the class to=
=20
> be useful.=20
>
Copier and deleter do not make sense for a value-like type. The only way=20
you *might* be able to crowbar them in is if you disallow assignment from=
=20
T, and also have a "creator" and "mover". However, I still think if you are=
=20
going to support generic resource-management, a pointer-like type is what=
=20
you need.
--=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/6d03522b-39f0-4d96-8384-ef9210122168%40isocpp.or=
g.
------=_Part_279_582691260.1477543956106
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, 27 October 2016 04:28:17 UTC+8, mihailn...@gm=
ail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-=
left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc=
solid;padding-left:1ex"><div dir=3D"ltr"><div>...<br><br><div style=3D"bac=
kground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:s=
olid;border-width:1px"><code><div><span style=3D"color:#000">T t</span><spa=
n style=3D"color:#660">;</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#800">// t default constructed (value-like)</span><span style=
=3D"color:#000"><br>polymorphic</span><span style=3D"color:#660"><</span=
><span style=3D"color:#000">T</span><span style=3D"color:#660">></span><=
span style=3D"color:#000"> p</span><span style=3D"color:#660">;</span><span=
style=3D"color:#000"> </span><span style=3D"color:#800">// *p default cons=
tructed (value-like)</span><span style=3D"color:#000"><br>indirect</span><s=
pan style=3D"color:#660"><</span><span style=3D"color:#000">T</span><spa=
n style=3D"color:#660">></span><span style=3D"color:#000"> i</span><span=
style=3D"color:#660">;</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#800">// i is empty (pointer-like)</span><span style=3D"color:#0=
00"><br><br>T t </span><span style=3D"color:#660">=3D</span><span style=3D"=
color:#000"> tt</span><span style=3D"color:#660">;</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#800">// t copy constructed (value-li=
ke)</span><span style=3D"color:#000"><br>polymorphic</span><span style=3D"c=
olor:#660"><</span><span style=3D"color:#000">T</span><span style=3D"col=
or:#660">></span><span style=3D"color:#000"> p </span><span style=3D"col=
or:#660">=3D</span><span style=3D"color:#000"> tt</span><span style=3D"colo=
r:#660">;</span><span style=3D"color:#000"> </span><span style=3D"color:#80=
0">// *p copy constructed (value-like)</span><span style=3D"color:#000"><br=
>indirect</span><span style=3D"color:#660"><</span><span style=3D"color:=
#000">T</span><span style=3D"color:#660">></span><span style=3D"color:#0=
00"> i </span><span style=3D"color:#660">=3D</span><span style=3D"color:#00=
0"> tt</span><span style=3D"color:#660">;</span><span style=3D"color:#000">=
</span><span style=3D"color:#800">// error: cannot assign from T (pointer-=
like)</span><span style=3D"color:#000"><br><br>T t </span><span style=3D"co=
lor:#660">=3D</span><span style=3D"color:#000"> std</span><span style=3D"co=
lor:#660">::</span><span style=3D"color:#000">move</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#000">tt</span><span style=3D"color:#=
660">);</span><span style=3D"color:#000"> </span><span style=3D"color:#800"=
>// t move constructed; tt moved from (value-like)</span><span style=3D"col=
or:#000"><br>polymorphic</span><span style=3D"color:#660"><</span><span =
style=3D"color:#000">T</span><span style=3D"color:#660">></span><span st=
yle=3D"color:#000"> p </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000"> std</span><span style=3D"color:#660">::</span><span styl=
e=3D"color:#000">move</span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">pp</span><span style=3D"color:#660">);</span><span style=3D=
"color:#000"> </span><span style=3D"color:#800">// *p move constructed; *pp=
moved from (value-like)</span><span style=3D"color:#000"><br>indirect</spa=
n><span style=3D"color:#660"><</span><span style=3D"color:#000">T</span>=
<span style=3D"color:#660">></span><span style=3D"color:#000"> i </span>=
<span style=3D"color:#660">=3D</span><span style=3D"color:#000"> std</span>=
<span style=3D"color:#660">::</span><span style=3D"color:#000">move</span><=
span style=3D"color:#660">(</span><span style=3D"color:#000">ii</span><span=
style=3D"color:#660">);</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#800">// ownership transferred from ii to i; ii now empty (poin=
ter-like)</span><span style=3D"color:#000"><br><br>T t</span><span style=3D=
"color:#660">{</span><span style=3D"color:#066">1</span><span style=3D"colo=
r:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#06=
6">2</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#066">3</span><span style=3D"color:#660">};</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#800">// t constr=
ucted in-place with arguments (value-like)</span><span style=3D"color:#000"=
><br>polymorphic</span><span style=3D"color:#660"><</span><span style=3D=
"color:#000">T</span><span style=3D"color:#660">></span><span style=3D"c=
olor:#000"> p</span><span style=3D"color:#660">{</span><span style=3D"color=
:#000">in_place</span><span style=3D"color:#660">,</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#066">1</span><span style=3D"color:#6=
60">,</span><span style=3D"color:#000"> </span><span style=3D"color:#066">2=
</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#066">3</span><span style=3D"color:#660">};</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#800">// *p construct=
ed in-place with arguments (value-like)</span><span style=3D"color:#000"><b=
r>indirect</span><span style=3D"color:#660"><</span><span style=3D"color=
:#000">T</span><span style=3D"color:#660">></span><span style=3D"color:#=
000"> i</span><span style=3D"color:#660">{</span><span style=3D"color:#008"=
>new</span><span style=3D"color:#000"> T</span><span style=3D"color:#660">{=
</span><span style=3D"color:#066">1</span><span style=3D"color:#660">,</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#066">2</span><sp=
an style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#066">3</span><span style=3D"color:#660">}};</span><span style=
=3D"color:#000"> </span><span style=3D"color:#800">// i constructed from po=
inter that it takes ownership of (pointer-like)</span><span style=3D"color:=
#000"><br><br></span><span style=3D"color:#800">// note: operator bool not =
defined for T</span><span style=3D"color:#000"><br></span><span style=3D"co=
lor:#008">if</span><span style=3D"color:#000"> </span><span style=3D"color:=
#660">(</span><span style=3D"color:#000">t</span><span style=3D"color:#660"=
>)</span><span style=3D"color:#000"> </span><span style=3D"color:#660">{</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#660">=E2=80=A6=
</span><span style=3D"color:#000"> </span><span style=3D"color:#660">}</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#800">// error: t=
cannot convert to bool (value-like)</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#008">if</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#660">(</span><span style=3D"color:#000">p</span><sp=
an style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#660">{</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">=E2=80=A6</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#660">}</span><span style=3D"color:#000"> </span><span style=
=3D"color:#800">// error: p cannot convert to bool (value-like)</span><span=
style=3D"color:#000"><br></span><span style=3D"color:#008">if</span><span =
style=3D"color:#000"> </span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">i</span><span style=3D"color:#660">)</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#660">{</span><span style=3D"color:=
#000"> </span><span style=3D"color:#660">=E2=80=A6</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#660">}</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#800">// i checked for empty status (point=
er-like)</span></div></code></div></div></div></blockquote><div><br></div><=
div>I agree it is more close=C2=A0to pointer then to a value, but that'=
s a good thing. It should feel, you are managing a remote recourse. =C2=A0 =
<br></div></blockquote><div>=C2=A0<br>I have no problem with a <span style=
=3D"font-family: courier new,monospace;">cloned_ptr</span> proposal (essent=
ially <span style=3D"font-family: courier new,monospace;">unique_ptr</span>=
+ deep copy (+ const-propagation, maybe). I just think the aims of the cur=
rent proposal are confused. If it wants to be a polymorphic value-like type=
, I suggest something similar to what I presented. If it wants to be a deep=
-copying pointer-like type, then the chosen name should suggest that (I lik=
e <span style=3D"font-family: courier new,monospace;">deep_copy_ptr</span>)=
, and it should probably support the appropriate pointer-like operations (e=
..g. <span style=3D"font-family: courier new,monospace;">p =3D nullptr</span=
>, <span style=3D"font-family: courier new,monospace;">p.get()</span>, <spa=
n style=3D"font-family: courier new,monospace;">p.reset(x)</span>).<br><br>=
</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8=
ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div></div><div>Also, no=
te that indirect<>, is intended to be constructed with make_indirect =
NOT with the ctor with a pointer. </div></blockquote><div>=C2=A0<br>This do=
esn't fix the fact that the only way to directly construct indirect, a =
supposedly value-like type, is by passing it ownership of a raw pointer.<br=
><br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left=
: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div></div><div>Abo=
ut <font color=3D"#000000">polymorphic</font>=C2=A0</div><div>The way it is=
right now, you do many allocations, just to pretend it is a real variable =
on the stack - allocating default ctor, not empty after move, etc. </div><d=
iv>All these I don't think are of benefit compared to the cost.</div></=
blockquote><div>=C2=A0<br>That's the idea. It behaves just like a stack=
-allocated object, but with polymorphism. If you can't afford the copie=
s, then maybe you need a <span style=3D"font-family: courier new,monospace;=
">deep_copy_ptr</span> instead.<br><br></div><blockquote class=3D"gmail_quo=
te" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;paddi=
ng-left: 1ex;"><div></div><div>Assignment from raw value however=C2=A0might=
be useful, especially move assignment. </div></blockquote><div>=C2=A0<br>A=
ssignment from <span style=3D"font-family: courier new,monospace;">T</span>=
is only really possible when you ditch the deleter and copier (it is only =
safe when using <span style=3D"font-family: courier new,monospace;">default=
_delete</span> and <span style=3D"font-family: courier new,monospace;">defa=
ult_copy</span>).<br><br></div><blockquote class=3D"gmail_quote" style=3D"m=
argin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"=
><div></div><div><font color=3D"#000000">Lastly, I find custom copier and d=
eleter to be essential for the class to be useful. </font></div></blockquot=
e><div><br>Copier and deleter do not make sense for a value-like type. The =
only way you <i>might</i> be able to crowbar them in is if you disallow ass=
ignment from T, and also have a "creator" and "mover". =
However, I still think if you are going to support generic resource-managem=
ent, a pointer-like type is what you need.<br></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/6d03522b-39f0-4d96-8384-ef9210122168%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/6d03522b-39f0-4d96-8384-ef9210122168=
%40isocpp.org</a>.<br />
------=_Part_279_582691260.1477543956106--
------=_Part_278_933223176.1477543956105--
.
Author: joseph.thomson@gmail.com
Date: Wed, 26 Oct 2016 21:59:38 -0700 (PDT)
Raw View
------=_Part_247_108825966.1477544378956
Content-Type: multipart/alternative;
boundary="----=_Part_248_1239999146.1477544378957"
------=_Part_248_1239999146.1477544378957
Content-Type: text/plain; charset=UTF-8
On Thursday, 27 October 2016 06:40:51 UTC+8, Bengt Gustafsson wrote:
>
> Yes, I think the need for being able to supply a copier and deleter
> defeats any attempt to make an "emplace style" constructor. How can we know
> where each parameter is to go?
>
You would need a creator and mover alongside the copier and deleter.
However, as I just mentioned in my other reply, I think this design is
ill-fitting for a value-like type, and would be better addressed with a
pointer-like type.
> For the original proposal it seems that make_indirect() would also need
> these optional parameters so it would end up in the same bad place... the
> only way I can think of to handle this would be to make four different
> function names. What am I missing?
>
I don't think make_indirect supports use of custom copiers and deleters,
much like make_unique doesn't support custom deleters, because it
implicitly uses default construction (operator new) so default_delete and
default_copy are appropriate. If you want to customize, use the constructor
directly.
--
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/0df7eaaa-dfdf-452d-86a4-716cbb463f8a%40isocpp.org.
------=_Part_248_1239999146.1477544378957
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, 27 October 2016 06:40:51 UTC+8, Bengt Gustafs=
son 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">Ye=
s, I think the need for being able to supply a copier and deleter defeats a=
ny attempt to make an "emplace style" constructor. How can we kno=
w where each parameter is to go?</div></blockquote><div><br>You would need =
a creator and mover alongside the copier and deleter. However, as I just me=
ntioned in my other reply, I think this design is ill-fitting for a value-l=
ike type, and would be better addressed with a pointer-like type.<br>=C2=A0=
</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8=
ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div></=
div><div>For the original proposal it seems that make_indirect() would also=
need these optional parameters so it would end up in the same bad place...=
the only way I can think of to handle this would be to make four different=
function names. What am I missing?</div></div></blockquote><div><br>I don&=
#39;t think <span style=3D"font-family: courier new,monospace;">make_indire=
ct</span> supports use of custom copiers and deleters, much like <span styl=
e=3D"font-family: courier new,monospace;">make_unique</span> doesn't su=
pport custom deleters, because it implicitly uses default construction (ope=
rator <span style=3D"font-family: courier new,monospace;">new</span>) so <s=
pan style=3D"font-family: courier new,monospace;">default_delete</span> and=
<span style=3D"font-family: courier new,monospace;">default_copy</span> ar=
e appropriate. If you want to customize, use the constructor directly.<br><=
/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/0df7eaaa-dfdf-452d-86a4-716cbb463f8a%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0df7eaaa-dfdf-452d-86a4-716cbb463f8a=
%40isocpp.org</a>.<br />
------=_Part_248_1239999146.1477544378957--
------=_Part_247_108825966.1477544378956--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Thu, 27 Oct 2016 00:09:35 -0500
Raw View
--001a113ab688d329ca053fd1c167
Content-Type: text/plain; charset=UTF-8
On Wed, Oct 26, 2016 at 11:52 PM, <joseph.thomson@gmail.com> wrote:
> Copier and deleter do not make sense for a value-like type.
So standard containers aren't value-like types? They contain allocators,
which direct copying (at least the allocation part, as it is still an open
question on whether or not copying should go through Allocator::construct)
and deletion.
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> +1-847-691-1404
--
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/CAGg_6%2BP7PBt06rwUgMB939HJ3K33ZczdVogaFGOttae1L%3D9Gsw%40mail.gmail.com.
--001a113ab688d329ca053fd1c167
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra">On Wed, Oct 26, 2016 at 11:52 P=
M, <span dir=3D"ltr"><<a href=3D"mailto:joseph.thomson@gmail.com" targe=
t=3D"_blank">joseph.thomson@gmail.com</a>></span> wrote:<br><div class=
=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex">Copier and deleter do not m=
ake sense for a value-like type.</blockquote></div><br>So standard containe=
rs aren't value-like types?=C2=A0 They contain allocators, which direct=
copying (at least the allocation part, as it is still an open question on =
whether or not copying should go through Allocator::construct) and deletion=
..<br>-- <br><div class=3D"gmail_signature" data-smartmail=3D"gmail_signatur=
e"><div dir=3D"ltr"><div><div dir=3D"ltr"><div>=C2=A0Nevin ":-)" =
Liber=C2=A0 <mailto:<a href=3D"mailto:nevin@eviloverlord.com" target=3D"=
_blank">nevin@eviloverlord.com</a>> =C2=A0+1-847-691-1404</div></div></d=
iv></div></div>
</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/CAGg_6%2BP7PBt06rwUgMB939HJ3K33ZczdVo=
gaFGOttae1L%3D9Gsw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2BP7PB=
t06rwUgMB939HJ3K33ZczdVogaFGOttae1L%3D9Gsw%40mail.gmail.com</a>.<br />
--001a113ab688d329ca053fd1c167--
.
Author: joseph.thomson@gmail.com
Date: Wed, 26 Oct 2016 23:04:13 -0700 (PDT)
Raw View
------=_Part_242_1455623526.1477548253946
Content-Type: multipart/alternative;
boundary="----=_Part_243_1781605615.1477548253946"
------=_Part_243_1781605615.1477548253946
Content-Type: text/plain; charset=UTF-8
On Thursday, 27 October 2016 13:10:27 UTC+8, Nevin ":-)" Liber wrote:
>
> On Wed, Oct 26, 2016 at 11:52 PM, <joseph....@gmail.com <javascript:>>
> wrote:
>
>> Copier and deleter do not make sense for a value-like type.
>
>
> So standard containers aren't value-like types? They contain allocators,
> which direct copying (at least the allocation part, as it is still an open
> question on whether or not copying should go through Allocator::construct)
> and deletion.
> --
> Nevin ":-)" Liber <mailto:ne...@eviloverlord.com <javascript:>>
> +1-847-691-1404
>
I believe the deleters of unique_ptr and shared_ptr are primarily designed
to handle custom generic resource management. Container allocators on the
other hand are, AFAIK, designed primarily for custom memory management.
However, if someone wanted to take an approach similar to STL allocators,
I'm sure it would be possible.
--
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/8c9ff3fd-38db-4bbd-9517-67d85565970a%40isocpp.org.
------=_Part_243_1781605615.1477548253946
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, 27 October 2016 13:10:27 UTC+8, Nevin ":=
-)" Liber 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"><div>On Wed, Oct 26, 2016 at 11:52 PM, <span dir=3D"ltr"><<a h=
ref=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"TQbqgCqoAQAJ=
" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';return =
true;" onclick=3D"this.href=3D'javascript:';return true;">joseph...=
..@gmail.com</a>></span> wrote:<br><div class=3D"gmail_quote"><blockquote=
class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc soli=
d;padding-left:1ex">Copier and deleter do not make sense for a value-like t=
ype.</blockquote></div><br>So standard containers aren't value-like typ=
es?=C2=A0 They contain allocators, which direct copying (at least the alloc=
ation part, as it is still an open question on whether or not copying shoul=
d go through Allocator::construct) and deletion.<br>-- <br><div><div dir=3D=
"ltr"><div><div dir=3D"ltr"><div>=C2=A0Nevin ":-)" Liber=C2=A0 &l=
t;mailto:<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D=
"TQbqgCqoAQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:=
';return true;" onclick=3D"this.href=3D'javascript:';return tru=
e;">ne...@eviloverlord.com</a><wbr>> =C2=A0+1-847-691-1404</div></div></=
div></div></div></div></div></blockquote><div><br>I believe the deleters of=
<span style=3D"font-family: courier new,monospace;">unique_ptr</span> and =
<span style=3D"font-family: courier new,monospace;">shared_ptr</span> are p=
rimarily designed to handle custom generic resource management. Container a=
llocators on the other hand are, AFAIK, designed primarily for custom memor=
y management. However, if someone wanted to take an approach similar to STL=
allocators, I'm sure it would be possible.<br></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/8c9ff3fd-38db-4bbd-9517-67d85565970a%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/8c9ff3fd-38db-4bbd-9517-67d85565970a=
%40isocpp.org</a>.<br />
------=_Part_243_1781605615.1477548253946--
------=_Part_242_1455623526.1477548253946--
.