220 29047 <bebb500d-5b71-48e5-8878-0e5fae129c41@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: mihailnajdenov@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: [propagate_const] Implicit conversion to T
Date: Sun, 23 Oct 2016 03:12:00 -0700 (PDT)
Lines: 140
Approved: news@gmane.org
Message-ID: <bebb500d-5b71-48e5-8878-0e5fae129c41@isocpp.org>
References: <1f43ffe8-b267-4c8c-8834-f3e60035f18d@isocpp.org>
 <7f61be69-4f4c-40a5-9199-805edc90b428@isocpp.org> <13a71b20-8fd3-4a29-9279-716a2c9082a6@isocpp.org>
 <7abb6203-6ca7-4e04-ab6a-dc6a60e223ca@isocpp.org> <CAFk2RUZSZ4_mUv8S=O5khg9ErDSxJ8vT5R9Z3ULwKLnQqELAVw@mail.gmail.com>
 <60ae1a96-7a31-491d-bcf8-c81590544006@isocpp.org>
 <CAAbBDD-Txt57g_XEpKhRaJhW7WXLen+emuXKgn2g19DzK5m9Bg@mail.gmail.com>
 <d348adb2-19b5-48f9-8836-adf9c3fa3300@isocpp.org>
 <aeae0bb0-aa8e-4c84-90ea-45cea4aa1b25@isocpp.org>
 <bcba393d-6c88-42ca-88ca-fbda08d49758@isocpp.org>
 <b53d5d2e-35cb-4f55-8ce6-6f7fe926c428@isocpp.org>
 <a51760a2-b976-4ef6-9214-bba82af80b79@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_900_55946508.1477217520702"
X-Trace: blaine.gmane.org 1477217538 4407 195.159.176.226 (23 Oct 2016 10:12:18 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 23 Oct 2016 10:12:18 +0000 (UTC)
Cc: jbcoe@me.com, joseph.thomson@gmail.com, mihailnajdenov@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCUJ3A7GRAPRB4UZWLAAKGQEHEAG2JQ@isocpp.org Sun Oct 23 12:12:14 2016
Return-path: <std-proposals+bncBCUJ3A7GRAPRB4UZWLAAKGQEHEAG2JQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw0-f199.google.com ([209.85.161.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCUJ3A7GRAPRB4UZWLAAKGQEHEAG2JQ@isocpp.org>)
	id 1byFl3-0007Xw-Fk
	for gclcip-std-proposals@m.gmane.org; Sun, 23 Oct 2016 12:12:01 +0200
Original-Received: by mail-yw0-f199.google.com with SMTP id j134sf31341260ywb.6
        for <gclcip-std-proposals@m.gmane.org>; Sun, 23 Oct 2016 03:12:04 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=bShqxP81ch6fcIyY4Euv9TP7ozyRVief3cxZNA5TxY0=;
        b=HhCwxx2yc4z0RmnSXTo6+gmt/ibtZHlMVkNVeQeN6IzTuFkvIMD9gDXoow5zE5ezAK
         vkwsypqSlSjBzRCWGDdOz+85C7fmqaD2An8TL+WM78cB4swy9VUA4t4gn904kjLkLP7W
         Hs0PxHeKZHghJ0u3XlAUOSg5t4NxEEprTmtNR+Rm+kiul05pMgbQ6nhrg1V18xFwifb8
         eg58qTXcGXQHc4V8k3+LQAQWbj5SPAlwFLH2dOpmXOLUb0XQavNg7h9rZncPA16WOd6E
         Xg/sOurLlZfIzbym7Lke4KZRHxlTY/rNTsETQMzz+t/Qe/zPc+H/73uB6HMXTgZSOjNA
         ovIg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=bShqxP81ch6fcIyY4Euv9TP7ozyRVief3cxZNA5TxY0=;
        b=J/xYMCv7GGR4HxNDbJ2qv5AgOTd3FMBCeA+VaJ8YXLi2EefvwediWmnqFcTULqzPYa
         TQqkdW+myVY1jp4EyaOTovdQSrgNn5d3gq3NN7zFhoYjr+2n/cBrMSwHUUqvYcWBNz0E
         xWp1ozGsrWesrk0d9Ui4GPLDb4nILB2OAmHVe7C3p3/7pqOkqgvXJa9RfmUdm2GE2VwT
         I/THcNx8bVWrx1BCrhBqVbdB42mM7VUTVjm8X1IrZc9Ygv6aar4V7huEkZthm4LyH4sM
         1VCIEHV1kzklCnrROEVQU/UHVmGyhCFeJ9tDhuQpgFh7PwEPgLp7elsNfwWE59LZwFAU
         c91w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to
         :references:subject:mime-version:x-original-sender:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=bShqxP81ch6fcIyY4Euv9TP7ozyRVief3cxZNA5TxY0=;
        b=Vv8byG65c+BaQl39pyvF3/GcwtTliRQxxTmlSoTiJKxKsjJgz4l8Kiczkfm+6c8tki
         9XhnqGuVU1TKzWU0yYbh7aUKZZ/MVsoOSjgGNFN60YrVLLYyHBL9AH3fZHrg4KuLmXcF
         z/aTAa+U7b4e407UPZVNHQ/rRVvxp4KcVP1/vKylJ9ES8cFicxjSo74z7IySjnIZqXIa
         W/R/7xJR3QgDbEbHhFJJQ94v7VbyOdEZvyrJPMpTKKWl8DzsoxdfUw2ertE/GYZgmMdR
         eHZ2+7riw3mzSEy6nEbKeDt3EHfwODAp6hkXv+uXfoBXAde5f1dgZ/8QCzQ0S6KBSSwU
         NQ4Q==
X-Gm-Message-State: AA6/9RlNpBbv2naNAF3QeYgv4g/g0+goJSN0nRdkM37T/NoPXflkmAE6IuF7bjTp6DvZ1A==
X-Received: by 10.129.116.66 with SMTP id p63mr8321517ywc.83.1477217523754;
        Sun, 23 Oct 2016 03:12:03 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.32.129 with SMTP id g123ls3552062iog.31.gmail; Sun, 23 Oct
 2016 03:12:02 -0700 (PDT)
X-Received: by 10.36.225.205 with SMTP id n196mr1719376ith.0.1477217522202;
        Sun, 23 Oct 2016 03:12:02 -0700 (PDT)
In-Reply-To: <a51760a2-b976-4ef6-9214-bba82af80b79@isocpp.org>
X-Original-Sender: MihailNajdenov@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:29047
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/29047>

------=_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&quot;natural copying syntax&quot; - 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;">&lt;</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;">&lt;</span><wbr><span class=3D"styled-by-prettify" style=3D"color: #=
080;">int&gt;</span></span><span style=3D"color:#660"><span class=3D"styled=
-by-prettify" style=3D"color: #660;">&gt;</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&amp;&amp;) =3D default;<br>=C2=A0S&amp; operato=
r=3D(S&amp;&amp;) =3D default;<br>=C2=A0S(const S&amp; o) : _p(get_underlyi=
ng(o._p)) {}<br>=C2=A0S&amp; operator=3D(const S&amp; o) { if(&amp;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&lt;shared_ptr&lt;int&gt;&gt; _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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/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--

.
