220 34935 <ac2e1965-b697-4be3-bd33-c9431dd2619d@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Mingxin Wang <wmx16835vv@163.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Idea about "std::pmr::memory_resource"
Date: Sat, 14 Oct 2017 20:40:29 -0700 (PDT)
Lines: 95
Approved: news@gmane.org
Message-ID: <ac2e1965-b697-4be3-bd33-c9431dd2619d@isocpp.org>
References: <0a8293b4-3246-47a5-9881-bc1ca4b91772@isocpp.org>
 <62cd9e1e-03b8-4125-a032-72624a9f5254@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_14848_403107053.1508038829323"
X-Trace: blaine.gmane.org 1508038828 32189 195.159.176.226 (15 Oct 2017 03:40:28 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 15 Oct 2017 03:40:28 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDNMBNHJWIGBBLNRRPHQKGQEQNYA3YY@isocpp.org Sun Oct 15 05:40:24 2017
Return-path: <std-proposals+bncBDNMBNHJWIGBBLNRRPHQKGQEQNYA3YY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua0-f198.google.com ([209.85.217.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDNMBNHJWIGBBLNRRPHQKGQEQNYA3YY@isocpp.org>)
	id 1e3Zmp-0007rz-Og
	for gclcip-std-proposals@m.gmane.org; Sun, 15 Oct 2017 05:40:23 +0200
Original-Received: by mail-ua0-f198.google.com with SMTP id c28sf5780181uaa.17
        for <gclcip-std-proposals@m.gmane.org>; Sat, 14 Oct 2017 20:40:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=te2bVdhfOah1S+6CmIGH3u3ZfuxvQ7CjXyp65XDPVBA=;
        b=lJ9RxDMTh3k6y3I6Rdw1GPSvuo9F56iD7CL9JxicIYZEX2jCUWPkWGNBQHbPhFNCaT
         d5ZuefgTMo8ODMw7eFVrsOAk70oJAP2oRGePiUa3pYQeT65uDLbyWu3YQ6YXVhmzakYK
         IIZQXc+92ee7wOctEwSvwSC5OmkM2gEb/VUNToSqUuWM2Mzgzo45/ZkQucmcl/ujpCx8
         466+Feiw/+HmG5ELhamh1P5GDnrKA1heWnRZhQIA1sIEex2cuCedv80wYKqmrGGRdrUl
         RwOaS28v+aiguCxINby/z/58T7iMb5XBSJa7SWZcHiKF58DkvNbmexp9WsGIRaEqVH7C
         cy3w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to: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=te2bVdhfOah1S+6CmIGH3u3ZfuxvQ7CjXyp65XDPVBA=;
        b=m7VkumNLsZYmmwyCCMdZ6ZwU2vTA8u8Bo2vkTfG0/RjgpqGVTpyAX3q5/V4Fh6tTOP
         0TGrTfv29J/EWqqdbh5PpqRr9D9wQfv0KQUJArAXdUgtRc7Db7GcFci3Un8Fogvr7fFg
         BihLiDjDlHyifIrQyWmGupBbE/yooamadQuByxwHa/xhxFDsHQBRKJBGzBVe/uBDCAc1
         tlDr/s8PWpUxMBn903577j/xXeR1leX/nPDxaFEzJQMXnOGBUM8jdGMAFt/kL4SWwC3A
         e7TVUd/gYBNC/CHDg/psSgjGvuRLJRyDa5DuBrRRgfB/Z+uhI97QmEqo4JV1tC55wqME
         JXvQ==
X-Gm-Message-State: AMCzsaWug9xf0QvH4VC43TOKIjP49NEqSvcDoPl3WNFa4BttpNaRnkXp
	RjSQJ0OXkZNxRqHxUD2C3EA2NQ==
X-Google-Smtp-Source: AOwi7QBGk62cgM1DxTlW3PscC6DouVliORjtakDdhn8THR+8FxodVfTiPi+fYkfUUlAwgcBrPBjZkw==
X-Received: by 10.31.98.66 with SMTP id w63mr3177459vkb.0.1508038831181;
        Sat, 14 Oct 2017 20:40:31 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.159.45.140 with SMTP id v12ls1305656uaj.20.gmail; Sat, 14 Oct
 2017 20:40:29 -0700 (PDT)
X-Received: by 10.31.96.146 with SMTP id u140mr395072vkb.2.1508038829786;
        Sat, 14 Oct 2017 20:40:29 -0700 (PDT)
In-Reply-To: <62cd9e1e-03b8-4125-a032-72624a9f5254@isocpp.org>
X-Original-Sender: wmx16835vv@163.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:34935
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/34935>

------=_Part_14848_403107053.1508038829323
Content-Type: multipart/alternative; 
	boundary="----=_Part_14849_1016021062.1508038829323"

------=_Part_14849_1016021062.1508038829323
Content-Type: text/plain; charset="UTF-8"

Thanks for your comments!

On Sunday, October 15, 2017 at 3:54:41 AM UTC+8, T. C. wrote:
>
> For simple memory resources, including the three in the standard, is_equal 
> implementations can simply do an address comparison. There's no need for 
> dynamic_cast or RTTI. 
>

However, this conclusion only holds in "simple designs", and it is apparent 
that `std::pmr::memory_resource` is desined to have good extendability for 
more complex implementations in the future, as what is illustrated in the 
latest draft: "The most-derived type of other might not match the type of 
this. For a derived class D, a typical implementation of this function will 
immediately return false if dynamic_cast<const D*>(&other) == nullptr".

Meanwhile, the `operator==` defined in `std::pmr::memory_resource` seems 
not so well-designed:

bool operator==(const memory_resource& a, const memory_resource& b) 
> noexcept;
>
Returns: &a == &b || a.is_equal(b).
>

For "simple designs", as you said, `&a == &b` and `a.is_equal(b)` seems to 
be equivalent, so that redundant operations are introduced.

>
Mingxin Wang 

-- 
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/ac2e1965-b697-4be3-bd33-c9431dd2619d%40isocpp.org.

------=_Part_14849_1016021062.1508038829323
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thanks for your comments!<br><br>On Sunday, October 15, 20=
17 at 3:54:41 AM UTC+8, T. C. 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">For simple memory resources, including the three in =
the standard, is_equal implementations can simply do an address comparison.=
 There&#39;s no need for dynamic_cast or RTTI.=C2=A0</div></blockquote><div=
><br></div><div>However, this conclusion only holds in &quot;simple designs=
&quot;, and it is apparent that `std::pmr::memory_resource` is desined to h=
ave good extendability for more complex implementations in the future, as w=
hat is illustrated in the latest draft: &quot;The most-derived type of othe=
r might not match the type of this. For a derived class D, a typical implem=
entation of this function will immediately return false if dynamic_cast&lt;=
const D*&gt;(&amp;other) =3D=3D nullptr&quot;.</div><div><br></div><div>Mea=
nwhile, the `operator=3D=3D` defined in `std::pmr::memory_resource` seems n=
ot so well-designed:</div><div><br></div><blockquote class=3D"gmail_quote" =
style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 20=
4); padding-left: 1ex;">bool operator=3D=3D(const memory_resource&amp; a, c=
onst memory_resource&amp; b) noexcept;<br></blockquote><blockquote class=3D=
"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rg=
b(204, 204, 204); padding-left: 1ex;">Returns: &amp;a =3D=3D &amp;b || a.is=
_equal(b).<br></blockquote><div><br></div><div>For &quot;simple designs&quo=
t;, as you said, `&amp;a =3D=3D &amp;b` and `a.is_equal(b)` seems to be=C2=
=A0equivalent, so that redundant operations are introduced.</div><blockquot=
e 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></blockquote><div=
><br></div><div>Mingxin Wang=C2=A0</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/ac2e1965-b697-4be3-bd33-c9431dd2619d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/ac2e1965-b697-4be3-bd33-c9431dd2619d=
%40isocpp.org</a>.<br />

------=_Part_14849_1016021062.1508038829323--

------=_Part_14848_403107053.1508038829323--

.
