220 36548 <CALvx3hY-kSJAN5jbpp0gSK0GWBtEPpK=Jx5XR3DsUxJLqAg+bA@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Richard Hodges <hodges.r@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: What happened to N4282
Date: Sun, 7 Jan 2018 23:38:54 +0100
Lines: 193
Approved: news@gmane.org
Message-ID: <CALvx3hY-kSJAN5jbpp0gSK0GWBtEPpK=Jx5XR3DsUxJLqAg+bA@mail.gmail.com>
References: <CANVf7NXAJ4fgPDsVPAFacHJaiHgGS0wVuUF3XcSQRNLBjkTCVA@mail.gmail.com>
 <fd278536-7104-4aa8-a0fd-bb9788e7c0aa@isocpp.org> <c82b2d47-e144-4809-b87a-f70d00d8a7e7@isocpp.org>
 <p2u66r$5uh$1@blaine.gmane.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="001a113f3446bb60a5056237586f"
X-Trace: blaine.gmane.org 1515364618 16151 195.159.176.226 (7 Jan 2018 22:36:58 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 7 Jan 2018 22:36:58 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD4PBM7UWAHRB76CZLJAKGQEFVDQ37A@isocpp.org Sun Jan 07 23:36:53 2018
Return-path: <std-proposals+bncBD4PBM7UWAHRB76CZLJAKGQEFVDQ37A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-io0-f197.google.com ([209.85.223.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBD4PBM7UWAHRB76CZLJAKGQEFVDQ37A@isocpp.org>)
	id 1eYJYj-0003sJ-AB
	for gclcip-std-proposals@m.gmane.org; Sun, 07 Jan 2018 23:36:53 +0100
Original-Received: by mail-io0-f197.google.com with SMTP id q16sf3674970ioh.4
        for <gclcip-std-proposals@m.gmane.org>; Sun, 07 Jan 2018 14:38:57 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1515364736; cv=pass;
        d=google.com; s=arc-20160816;
        b=kWXXFnPFMGT8YO/AKNglmtL53qDDRGMnB9uASLzOAs2VY3yh9hf1dpYB3Dyfw7ziGl
         SgGdMHAJLaUaI9g9KVymKVdkAVrHh9iHotDgD6vl5BtzDMjncCB1adANoA1JXtoDZaqj
         Jry9iKSnjN/uz4p9Agkn0lSHMSCHXZy8+LWkpJipr3l+QgikVLPk8zfJEe/pFY4H9JHI
         EIdA7L6jFfqwfKtthauYhTt0k50LDPbwfpIVWVqp3if7dOEXmIhbkDC1hSc9iqm6i7ma
         gD1kc/4W+cMvKSW1VQqzTi5p0G3Ha98zcXN2iyPgG9sdV3SSla4aH3Li3C7zQ9ZmqZEw
         sKKg==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:references:in-reply-to:mime-version:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=ZdcomyBbPj4JB4+jNW+Cyg25TBCTEeNeVVdRJui9vQI=;
        b=lORDdCd9P08QZuUvtWo9utBaDxk8o/fi5Tg3UK5YgRb+xFuDKXAwERc/an7dYFbCKy
         3CRWn7wuUfuSR2/cVyO19Z0EQcIv/X6rshfGP68Hi8sCopcp+UHdTJcVpT54fjJB8ZXr
         bkTHicUB5lzgMKQe7EMCGR+4zogKp+0NxHt6MLQroaNJGUSOxcYNEICnDC1NFMUj+429
         DjVj7m0pf5Y1WuL0351UUy9x1EmsdR++5EnXilHnFGfOI/i7zjhLJ8dfyWq1GqQ6/LD0
         k/sDnWNI4/HjWW/qMoBUW1rtpTCUHwDFvYEo5N0aCU2OAXYDj25nrecsvaz8j5mu4DZf
         A95A==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZvdDrtmb;
       spf=pass (google.com: domain of hodges.r@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=hodges.r@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=ZdcomyBbPj4JB4+jNW+Cyg25TBCTEeNeVVdRJui9vQI=;
        b=QZacoQBjLJcPkZ7BipOKfby/TaY1bkLrywQKXSnlNwBJ0m52NRKOFMDCuZdQVC01uQ
         GJJ7NHp/+2gz6Ea+BlfjvyLxr8hLghKLtNLFqgkFrO7kQDOcs1N1/AhID72ooj8Bfnqa
         VBPjja+EYQNXuweyzn5/rd5kih8WCV5dxmytG2sx4VDsw0zYoZp1wC+nbLIBc4tTCh0O
         aA8iFdLUHPYw8PoAnpkaO/+vYjLa1jXbak2AgO3+eFwN7l9YOu6ZRewVf7/Ct5qgf2sK
         2juYYVgAJdMdU1xZ1/TAaqEVxoyUQRz3Cuuco5UZRtJ1fkKg+CVghHrF7nrk8ssS3xg5
         fziw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=ZdcomyBbPj4JB4+jNW+Cyg25TBCTEeNeVVdRJui9vQI=;
        b=ElXI1EYTDUjjjqMx0/HrbobSiDIkbNzUao8zdrvSU3tmoO8u1RyV5VWz/wJZQQe4f1
         tLHakDWkM3eMgh7wM7rtbJ5YqZw/xzE+jodUmaMQOsPBhLC61NyRDmw7bTblKrmo2d2c
         wIHv3DZvwd3KkZ5zg/2OchokgWng+V6tAXJ7wyvxVVAAN/okV/UAjYOZT+OftKZn9SIg
         ZtzhhL3oFDOeLyxFApuyTO/PJIWHDTEQcMTaA3vuW/dNCXmFRIzEXu0cLJuxYuDzN/TV
         SOuOtwTm0bshngXFj38SkG5omtt9typ/fxG+JGKW1Ni8DDmwhyBDf86WJpktL4TPQ0Dd
         Ddhg==
X-Gm-Message-State: AKwxytfhjIGIXaYhFhkSDQJuIOqIrquXSt9OiEui3Lf/f/J8dxI65mrr
	FzpCznS48oXRe+PiKX88d/Wqtw==
X-Google-Smtp-Source: ACJfBosQwzyQfCow4/0J4QNXfcwAGrFnwBavRTlanme4JtuYjQsXkA09LWuuQsLTRGiemBg1GtxIOw==
X-Received: by 10.107.43.17 with SMTP id r17mr6979068ior.116.1515364736580;
        Sun, 07 Jan 2018 14:38:56 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.129.98 with SMTP id c95ls1351918iod.15.gmail; Sun, 07 Jan
 2018 14:38:55 -0800 (PST)
X-Received: by 10.107.157.17 with SMTP id g17mr9880483ioe.5.1515364735415;
        Sun, 07 Jan 2018 14:38:55 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1515364735; cv=none;
        d=google.com; s=arc-20160816;
        b=NCJG2W6V44+nE4NyKgcLSCux7j8yoV7+b4VUn5e/k/wHGSWQizhqgJICVrTXkur2ew
         NIgr0ocz2l40UWvuxpcF9eA7S47IfsHEvLSnWWHkbEZ9geIYgad6fAVh142c8BfHZflV
         wt3Htg7SbAWG+6QAmqMcyLbJnwI/uQgcyzCjp4P6dyxi25EkOB4QmYGE+AuKYF9CaEC9
         csG9SZRtfT+YFsrObXKjeRAQnJ7npAp9UQounNxzT5VHC1+Wgxmoze/sGMenH8gTg+Le
         /KBuP5ChiU2VbygBLWribyrUIDP0eeY9g6lWCFYIEj0o95xyQ7qMLYPTaf7tSKUnUold
         uzsQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:references:in-reply-to:mime-version
         :dkim-signature:arc-authentication-results;
        bh=/AIeckv1Mp+5BqImO6m2+uk+F1WYG8UNGNSuvG80oTQ=;
        b=jC1DqWJvDR0GrJV861owqcyKfkI+Yy2xa0MnV6fmfYMb11HvrBGBBjIkJcC9mTz4M2
         faUhnQu/2vFzQJtyvKkOuwwQsklKklaF/WZdwA4xGiLNB8MWvMIUdh0TYzkVHE/HIAGR
         JrEKfofHpA48SXub5KLQ/hQ8vE/ML9/mNgmbY/8oVQfnt0YBR/qv5JDx52UodFvmTvkB
         0wHX0iyzgVYpjSXpSkAjxO+pSS1xBQ8r0Qlo/jn+QWrxH+1bbEuiV7C3mfWoMYSNzcf9
         sJi0zKVDP8XELjds28KXraCfh/WJZpziQrFNi8J0JMUPIp/7XxQ0/vwX3Fu84r7ErteL
         epbw==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZvdDrtmb;
       spf=pass (google.com: domain of hodges.r@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=hodges.r@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id d133sor5646910iof.177.2018.01.07.14.38.55
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Sun, 07 Jan 2018 14:38:55 -0800 (PST)
Received-SPF: pass (google.com: domain of hodges.r@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 10.107.7.227 with SMTP id g96mr9559254ioi.201.1515364734949;
 Sun, 07 Jan 2018 14:38:54 -0800 (PST)
Original-Received: by 10.2.181.55 with HTTP; Sun, 7 Jan 2018 14:38:54 -0800 (PST)
In-Reply-To: <p2u66r$5uh$1@blaine.gmane.org>
X-Original-Sender: hodges.r@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=ZvdDrtmb;       spf=pass
 (google.com: domain of hodges.r@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=hodges.r@gmail.com;       dmarc=pass (p=NONE
 sp=NONE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: 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:36548
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/36548>

--001a113f3446bb60a5056237586f
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I wrote my own observer_ptr too, feeling that it states intent explicitly.

However, it's probably true that std::reference_wrapper<> does the same
job. It's just a little less convenient when talking to c apis.

I don't like seeing naked pointers in c++ code. I'd be inclined to reject
code that used them at code review time unless it could be proven they were
necessary.



On 7 January 2018 at 23:17, Bo Persson <bop@gmb.dk> wrote:

> On 2018-01-07 18:07, Masse Nicolas wrote:
>
>> Hi all,
>>
>> Le dimanche 10 d=C3=A9cembre 2017 23:07:54 UTC+1, Nicol Bolas a =C3=A9cr=
it :
>>
>>
>>     Basically, naked pointers are treated like a hypothetical
>>     `optional<T&>`. If you want an owning pointer, you use a smart
>>     pointer or, if you cannot properly encapsulate the ownership,
>>     `gsl::owner<T>`. If you want a non-owning array, you use
>> `gsl::span<T>`.
>>
>>     People are going to use `T*` for non-owning pointers; there's no
>>     getting around that. We already have one way to spell that; we don't
>>     need a second one.
>>
>>
>> I should say I just don't agree with you.
>> When people use naked pointer, we can't know wether it is:
>> - for storing a non-owned pointer
>> - due to compatibility with C code
>> - poorly written code
>> - whathever
>>
>> Also it goes against a rule I've set with myself who said that naked
>> pointer should always be avoided :D.
>>
>> On the other side, when using std::observer_ptr<T>, you know:
>> - that the given pointer isn't owned and that you should not try to take
>> any ownership on it.
>> - the code is not that poorly written :)
>>
>>
> The trend for the C++ Core Guidelines seems to be that a raw pointer is
> non-owning (and non-array).
>
> http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rr-ptr
>
> And then use the compilers' static analysis to warn about doing "owning
> things" to the pointers.
>
> I think the observer_ptr, while a good idea in isolation, has lost to the
> more comprehensive guidelines.
>
>
>     Bo Persson
>
>
> --
> 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/is
> ocpp.org/d/msgid/std-proposals/p2u66r%245uh%241%40blaine.gmane.org.
>

--=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/CALvx3hY-kSJAN5jbpp0gSK0GWBtEPpK%3DJx5XR3DsUxJLq=
Ag%2BbA%40mail.gmail.com.

--001a113f3446bb60a5056237586f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I wrote my own observer_ptr too, feeling that it states in=
tent explicitly.<div><br></div><div>However, it&#39;s probably true that st=
d::reference_wrapper&lt;&gt; does the same job. It&#39;s just a little less=
 convenient when talking to c apis.</div><div><br></div><div>I don&#39;t li=
ke seeing naked pointers in c++ code. I&#39;d be inclined to reject code th=
at used them at code review time unless it could be proven they were necess=
ary.</div><div><br></div><div><br></div></div><div class=3D"gmail_extra"><b=
r><div class=3D"gmail_quote">On 7 January 2018 at 23:17, Bo Persson <span d=
ir=3D"ltr">&lt;<a href=3D"mailto:bop@gmb.dk" target=3D"_blank">bop@gmb.dk</=
a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0=
 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D"">On =
2018-01-07 18:07, Masse Nicolas wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
Le dimanche 10 d=C3=A9cembre 2017 23:07:54 UTC+1, Nicol Bolas a =C3=A9crit=
=C2=A0:<br>
<br>
<br>
=C2=A0 =C2=A0 Basically, naked pointers are treated like a hypothetical<br>
=C2=A0 =C2=A0 `optional&lt;T&amp;&gt;`. If you want an owning pointer, you =
use a smart<br>
=C2=A0 =C2=A0 pointer or, if you cannot properly encapsulate the ownership,=
<br>
=C2=A0 =C2=A0 `gsl::owner&lt;T&gt;`. If you want a non-owning array, you us=
e `gsl::span&lt;T&gt;`.<br>
<br>
=C2=A0 =C2=A0 People are going to use `T*` for non-owning pointers; there&#=
39;s no<br>
=C2=A0 =C2=A0 getting around that. We already have one way to spell that; w=
e don&#39;t<br>
=C2=A0 =C2=A0 need a second one.<br>
<br>
<br>
I should say I just don&#39;t agree with you.<br>
When people use naked pointer, we can&#39;t know wether it is:<br>
- for storing a non-owned pointer<br>
- due to compatibility with C code<br>
- poorly written code<br>
- whathever<br>
<br>
Also it goes against a rule I&#39;ve set with myself who said that naked po=
inter should always be avoided :D.<br>
<br>
On the other side, when using std::observer_ptr&lt;T&gt;, you know:<br>
- that the given pointer isn&#39;t owned and that you should not try to tak=
e any ownership on it.<br>
- the code is not that poorly written :)<br>
<br>
</blockquote>
<br></span>
The trend for the C++ Core Guidelines seems to be that a raw pointer is non=
-owning (and non-array).<br>
<br>
<a href=3D"http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rr-p=
tr" rel=3D"noreferrer" target=3D"_blank">http://isocpp.github.io/CppCor<wbr=
>eGuidelines/CppCoreGuidelines#<wbr>Rr-ptr</a><br>
<br>
And then use the compilers&#39; static analysis to warn about doing &quot;o=
wning things&quot; to the pointers.<br>
<br>
I think the observer_ptr, while a good idea in isolation, has lost to the m=
ore comprehensive guidelines.<br>
<br>
<br>
=C2=A0 =C2=A0 Bo Persson<span class=3D""><br>
<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%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@isoc<wbr>pp.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/p2u66r%245uh%241%40blaine.gmane.org" =
rel=3D"noreferrer" target=3D"_blank">https://groups.google.com/a/is<wbr>ocp=
p.org/d/msgid/std-proposals<wbr>/p2u66r%245uh%241%40blaine.<wbr>gmane.org</=
a>.<br>
</blockquote></div><br></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/CALvx3hY-kSJAN5jbpp0gSK0GWBtEPpK%3DJx=
5XR3DsUxJLqAg%2BbA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hY-kSJA=
N5jbpp0gSK0GWBtEPpK%3DJx5XR3DsUxJLqAg%2BbA%40mail.gmail.com</a>.<br />

--001a113f3446bb60a5056237586f--

.
