220 17566 <5c67669c-7812-43a5-a8fd-21dcc6f8894a@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: lie4pan1 <lie4pan1@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Thoughts/idea about N4401 vs N4475 (regarding raw
 ptrs and mutables)
Date: Wed, 29 Apr 2015 02:09:56 -0700 (PDT)
Lines: 260
Approved: news@gmane.org
Message-ID: <5c67669c-7812-43a5-a8fd-21dcc6f8894a@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_6987_3080161.1430298596744"
X-Trace: ger.gmane.org 1430298616 21725 80.91.229.3 (29 Apr 2015 09:10:16 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 29 Apr 2015 09:10:16 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCEP3ZH7SICRBZN7QKVAKGQEDTL6YOY@isocpp.org Wed Apr 29 11:10:02 2015
Return-path: <std-proposals+bncBCEP3ZH7SICRBZN7QKVAKGQEDTL6YOY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pa0-f69.google.com ([209.85.220.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCEP3ZH7SICRBZN7QKVAKGQEDTL6YOY@isocpp.org>)
	id 1YnO0F-00032E-Mq
	for gclcip-std-proposals@m.gmane.org; Wed, 29 Apr 2015 11:10:00 +0200
Original-Received: by pabvw2 with SMTP id vw2sf36887316pab.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 29 Apr 2015 02:09:58 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:subject:mime-version:content-type
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=xflQ0oGp7FUSy4WoBNx6QhZrR3lwRKD8bdvqJz77S2c=;
        b=L3oWp7rH4MkiTRPiUNB2zb9MMoKAnLkcshPuPGVmYNVCDwtZ75N1POvqNgJC5X07MY
         i2+S4ET9qiiSNpfh4zbLhA6rQZQPY3kCQzc8GAsJiHzFBKalyJAufa4JrkHCikSZrCnM
         1PrHsVoGqUfXZ+a3or1wbWCVZwtyZgNL+3FF//hKGaq9vaCKnThk7E+n5uejwM5QYRKH
         LKNY2/kLSox4BrRImAaqlkY14p4WVpTnTv3KvNdOo8I9XAnlM35LVWsMZYdXog3c9ifp
         n5LagUMUe89gBmeeHIf5oiG6LCziU7JZvC6/YlV3vIdaf44vkx9b65o5dHiwrAGbrD3R
         6I5w==
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:message-id:subject:mime-version
         :content-type:x-original-sender:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=xflQ0oGp7FUSy4WoBNx6QhZrR3lwRKD8bdvqJz77S2c=;
        b=HWRvT4Nu4OUG/H2Xfhx6c3Il1JzcDRPs4ovQrwGO0VWjuUl2dUFsHneSBRkgkzUyGP
         SmKERx2Oi/8MxmpGLfsg7lRMadOV2zL6k8dd/dy8hk34Klsz/2mu5qHQjej7nxrauPzy
         gE4VOtvMIwMTX7pKg7aoYbbECo3d1HojYbxGhVFm9DblWj+OduDaU467hMA4+LnWkzvg
         cy1ExHB+u+hYpQ532clOb32xUxEjSPNy2l+k6yTZVU2ou43PfgWwrzK95jN8vbg1ZnGn
         /4B0+ViX6Y8LrbTYS82yxEO//LJdZp3tQQTShAJRj6RjB7aj6W+64uCfxDEO4CYSbkRC
         dsiQ==
X-Gm-Message-State: ALoCoQmWLziGFY5CtfKgY874aL4LOSp/N5XEaBOEkJkoYAC7r9nFxCVhJh99WyRWNRllnuLzDv3V
X-Received: by 10.66.101.6 with SMTP id fc6mr34250396pab.36.1430298598520;
        Wed, 29 Apr 2015 02:09:58 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.99.49 with SMTP id p46ls657356qge.51.gmail; Wed, 29 Apr
 2015 02:09:57 -0700 (PDT)
X-Received: by 10.140.100.136 with SMTP id s8mr249376qge.2.1430298597612;
        Wed, 29 Apr 2015 02:09:57 -0700 (PDT)
X-Original-Sender: lie4pan1@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: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://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>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:17566
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/17566>

------=_Part_6987_3080161.1430298596744
Content-Type: multipart/alternative; 
	boundary="----=_Part_6988_228658399.1430298596744"

------=_Part_6988_228658399.1430298596744
Content-Type: text/plain; charset=UTF-8

Hi!

I've read about some proposals papers on defaulted comparison operators. I 
like the idea that some comparisons (see below) be default-generated, but I 
don't think *inconsistent* 'default-generated operators' rules that could 
only resolve part of the problem regarding raw pointers and mutables are 
good for a language like C++ that is already so complicated.

Difference should look different. How about:

class MyClass
{
// Existence of '__cookie__' non-mutable raw pointers prevent the compiler 
from generating defaulted copy-ctor, operator== etc.
// However, if there were no such pointers (in this example, __cookie__ 
Datum *newed_),
// the default-generated copy-ctor should only (shallow-)copy 
non-'__cookie__' members ignoring '__cookie__' ones,
// the default-generated operator== shall only (shallow-)compare 
non-'__cookie__' members ignoring '__cookie__' ones,
// and so on.
private:
    const Object *one_;                // non-owning observer pointer, can 
be treated trivially
private:
    __cookie__ Datum *newed_;          // non-mutable owning pointer, 
shouldn't be shallow-copied/compared, thus suppressing defaulted
    __cookie__ mutable Cache_ last_;   // some cache data, should be 
ignored in comparisons, in common sense
    __cookie__ mutable bool dirty_;    // some cache invalidation flag, 
same treatment as above
private /*friend class IntrsiveList*/: // <- please ignore this block 
comment :-p
    __cookie__ mutable MyClass *next_; // I would argue that this is 
mutable because it is not part of the object's internal state,
                                       // thus it should be ignored for 
object copying and comparisons
};

// Pros:
// * New syntax/keyword.
// * Clearer expression/documentation of intention on data members of the 
class author(s).
// * Provides a simple way to somehow fix the old-ish defaulted 
copy-ctor/assignment issues with raw pointer / mutable members.
// * Things that should work without extra work eg. raw observer pointers 
work.
// Cons:
// * New syntax/keyword.
// * Buggy code that fails to add '__cookie__' where necessary might be 
misused (with the newly defaulted comparison operators).


That is basically N4401 + new '__cookie__' rules. The new rules are 
consistent with all defaulted operators.
(Yes I am only talking about defaulted operator== and operator!= here 
because I am unsure about other comparisons related to ordering.)

-- 

--- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_6988_228658399.1430298596744
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><span style=3D"font-family: courier new,monospace;"><span =
style=3D"font-family: arial,sans-serif;">Hi!<br><br>I've read about some pr=
oposals papers on defaulted comparison operators</span></span><span style=
=3D"font-family: courier new,monospace;"><span style=3D"font-family: arial,=
sans-serif;">. I like the idea that some comparisons</span></span><span sty=
le=3D"font-family: courier new,monospace;"><span style=3D"font-family: aria=
l,sans-serif;"><span style=3D"font-family: courier new,monospace;"><span st=
yle=3D"font-family: arial,sans-serif;"> (see below)</span></span> be defaul=
t-generated, but I don't think </span></span><span style=3D"font-family: co=
urier new,monospace;"><span style=3D"font-family: arial,sans-serif;"><span =
style=3D"font-family: courier new,monospace;"><span style=3D"font-family: a=
rial,sans-serif;"><b>inconsistent</b> </span></span>'default-generated oper=
ators'</span></span><span style=3D"font-family: courier new,monospace;"><sp=
an style=3D"font-family: arial,sans-serif;"><span style=3D"font-family: cou=
rier new,monospace;"><span style=3D"font-family: arial,sans-serif;"> rules =
that could only resolve part of the problem</span></span></span></span><spa=
n style=3D"font-family: courier new,monospace;"><span style=3D"font-family:=
 arial,sans-serif;"><span style=3D"font-family: courier new,monospace;"><sp=
an style=3D"font-family: arial,sans-serif;"><span style=3D"font-family: cou=
rier new,monospace;"><span style=3D"font-family: arial,sans-serif;"><span s=
tyle=3D"font-family: courier new,monospace;"><span style=3D"font-family: ar=
ial,sans-serif;"> regarding raw pointers and mutables</span></span></span><=
/span> are good</span></span> for a language</span></span><span style=3D"fo=
nt-family: courier new,monospace;"><span style=3D"font-family: arial,sans-s=
erif;"><span style=3D"font-family: courier new,monospace;"><span style=3D"f=
ont-family: arial,sans-serif;"> like C++</span></span> that is already so c=
omplicated.<br><br></span></span><span style=3D"font-family: courier new,mo=
nospace;"><span style=3D"font-family: arial,sans-serif;"><span style=3D"fon=
t-family: courier new,monospace;"><span style=3D"font-family: arial,sans-se=
rif;"> Difference should look different.</span></span> How about:<br><br></=
span><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 25=
0); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1p=
x; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpre=
ttyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">class</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">MyClass</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><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #800=
;" class=3D"styled-by-prettify">// Existence of '__cookie__' non-mutable ra=
w pointers prevent the compiler from generating defaulted copy-ctor, operat=
or=3D=3D etc.</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br></span><span style=3D"color: #800;" class=3D"styled-by-prettify">// =
However, if there were no such pointers (in this example, __cookie__ Datum =
*newed_),</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: #800;" class=3D"styled-by-prettify">// the =
default-generated copy-ctor should only (shallow-)copy non-'__cookie__' mem=
bers ignoring '__cookie__' ones,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">// the default</span><span style=3D"color: #800;" class=
=3D"styled-by-prettify"><span style=3D"font-family: courier new,monospace;"=
><code class=3D"prettyprint"><span style=3D"color: #800;" class=3D"styled-b=
y-prettify">-generat</span><span style=3D"color: #800;" class=3D"styled-by-=
prettify"></span></code></span>ed operator=3D=3D shall only (shallow-)compa=
re non-'__cookie__' members ignoring '__cookie__' ones,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #800;" class=3D"styled-by-prettify">// and so on.</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><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><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>&nbsp; &nbsp; </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: #606;" class=3D"=
styled-by-prettify">Object</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">on=
e_</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style=3D"color: #800;" =
class=3D"styled-by-prettify">// non-owning observer pointer, can be treated=
 trivially</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">privat=
e</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; =
__cookie__ </span><span style=3D"color: #606;" class=3D"styled-by-prettify"=
>Datum</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">newed_</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
</span><span style=3D"color: #800;" class=3D"styled-by-prettify">// non-mut=
able owning pointer, shouldn't be shallow-copied/compared, thus suppressing=
 defaulted</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>&nbsp; &nbsp; __cookie__ </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">mutable</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pre=
ttify">Cache_</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> last_</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; </=
span><span style=3D"color: #800;" class=3D"styled-by-prettify">// some cach=
e data, should be ignored in comparisons, in common sense</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; __cookie__=
 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">mutable</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> dirty_</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> &nbsp; &nbsp;</span><span style=3D"c=
olor: #800;" class=3D"styled-by-prettify">// some cache invalidation flag, =
same treatment as above</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">private</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/*fri=
end class IntrsiveList*/</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// &=
lt;- please ignore this block comment :-p</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; __cookie__ </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">mutable</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">MyClass</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">next_</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// I w=
ould argue that this is mutable because it is not part of the object's inte=
rnal state,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span=
><span style=3D"color: #800;" class=3D"styled-by-prettify">// thus it shoul=
d be ignored for object copying and comparisons</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br></span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">// Pros:</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">// * New syntax/keyword.</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #800;" cla=
ss=3D"styled-by-prettify">// * Clearer expression/documentation of intentio=
n on data members of the class author(s).</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span><span style=3D"color: #800;" clas=
s=3D"styled-by-prettify">// * Provides a simple way to somehow fix the old-=
ish defaulted copy-ctor/assignment issues with raw pointer / mutable member=
s.</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #800;" class=3D"styled-by-prettify">// * Things th=
at should work without extra work eg. raw observer pointers work.</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span sty=
le=3D"color: #800;" class=3D"styled-by-prettify">// Cons:</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #800;" class=3D"styled-by-prettify">// * New syntax/keyword.</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span sty=
le=3D"color: #800;" class=3D"styled-by-prettify">// * Buggy code that fails=
 to add '__cookie__' where necessary might be misused (with the newly defau=
lted comparison operators).</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br></span></div></code></div><span style=3D"font-fami=
ly: arial,sans-serif;"><br>That is basically N4401 + new '__cookie__' rules=
.. The new rules are consistent with all defaulted operators.<br></span></sp=
an><span style=3D"font-family: courier new,monospace;"><span style=3D"font-=
family: arial,sans-serif;"><span style=3D"font-family: courier new,monospac=
e;"><span style=3D"font-family: arial,sans-serif;">(Yes I am only talking a=
bout </span></span><span style=3D"font-family: courier new,monospace;"><spa=
n style=3D"font-family: arial,sans-serif;"><span style=3D"font-family: cour=
ier new,monospace;"><span style=3D"font-family: arial,sans-serif;">defaulte=
d operator=3D=3D and operator!=3D</span></span> here because I am unsure ab=
out other comparisons</span></span></span></span><span style=3D"font-family=
: courier new,monospace;"><span style=3D"font-family: arial,sans-serif;"><s=
pan style=3D"font-family: courier new,monospace;"><span style=3D"font-famil=
y: arial,sans-serif;"><span style=3D"font-family: courier new,monospace;"><=
span style=3D"font-family: arial,sans-serif;"><span style=3D"font-family: c=
ourier new,monospace;"><span style=3D"font-family: arial,sans-serif;"> rela=
ted to ordering</span></span></span></span>.)<br></span></span></span></spa=
n><span style=3D"font-family: courier new,monospace;"><br></span></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_6988_228658399.1430298596744--
------=_Part_6987_3080161.1430298596744--

.
