220 34937 <CAEddoJZzSZ5RROJ6Uu=2+R90mXi+hnHPDCxobrHM2daM6AxPVw@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: =?UTF-8?Q?Jonathan_M=C3=BCller?= <jonathanmueller.dev@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Idea about "std::pmr::memory_resource"
Date: Sun, 15 Oct 2017 08:48:48 +0200
Lines: 102
Approved: news@gmane.org
Message-ID: <CAEddoJZzSZ5RROJ6Uu=2+R90mXi+hnHPDCxobrHM2daM6AxPVw@mail.gmail.com>
References: <0a8293b4-3246-47a5-9881-bc1ca4b91772@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="001a114699dc473a40055b9048b4"
X-Trace: blaine.gmane.org 1508050138 15016 195.159.176.226 (15 Oct 2017 06:48:58 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 15 Oct 2017 06:48:58 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCUMHC4Z6QGBBUUJRTHQKGQET2JYKKY@isocpp.org Sun Oct 15 08:48:52 2017
Return-path: <std-proposals+bncBCUMHC4Z6QGBBUUJRTHQKGQET2JYKKY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wr0-f198.google.com ([209.85.128.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCUMHC4Z6QGBBUUJRTHQKGQET2JYKKY@isocpp.org>)
	id 1e3cj5-00029K-Jz
	for gclcip-std-proposals@m.gmane.org; Sun, 15 Oct 2017 08:48:43 +0200
Original-Received: by mail-wr0-f198.google.com with SMTP id 22sf3183539wrb.9
        for <gclcip-std-proposals@m.gmane.org>; Sat, 14 Oct 2017 23:48:51 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1508050131; cv=pass;
        d=google.com; s=arc-20160816;
        b=LDG+k3KgfamGlk9B9IJILFdrM4I3xOr0ja4w7778zq1ZJJNxVkBgmEfYCNOY4dLl6f
         y2CRZOCT0WxpMb08+I4qxLeK+pdZ1W9IlN5j7yIfV57jLHS/5ThKeoiacCS1gUNZqqVT
         A02LjxmEjyq/5pLCRfWnMXmJ5qRgmRUGvUchtHwIcBVoKvWHhg22AeD7GJ7jMbsXDTV/
         UoABXKtmCaye0Pr7Dgia6dudPWSZelsR04MHLULlFv/Sq9vDCq9yjWRZRrMgqi2sf2h1
         Vt1G3PUJrmRlwPPsgtepMvtOHcD9I8iksNTObwmxMwpWSlPGYI17XrXuWR31Gu+geSc+
         iu5w==
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=QNkR5+YF9P607B91Lj1268zSmV0FC3FfZagx5nWStEQ=;
        b=CRjXm+YNe2ujPMqmouEXivgEbYsH1sVZAo4HdbQNOAPkNkokGYDiBqb7NbsDFt6TGN
         fj+f0I9C9GPRu5TIap5YsuOk6cWpNnhlOhjz15pSp5X743MhzgWOn3GU20RZYc2O36Q7
         OpTGhsxHFR2ocKR+DlE/+nqyiAnLydvx9bawkjAXo2so71m2rikqpEgPDI2MUdCdzViM
         9IxPLeUpKxJp4eHmENsge9L11JvaDKNjqY5aSK0Aubjd4JlSRa5CPurdhSp3jgSi0k3i
         X2nSLDfcFzgNXR8iszkJPt1l7lt0uIyaXmR0l3TsFBOZkeKYLw4da/LLdHFZMf6kUau2
         j1EQ==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=R5iWOSTz;
       spf=pass (google.com: domain of jonathanmueller.dev@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jonathanmueller.dev@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=QNkR5+YF9P607B91Lj1268zSmV0FC3FfZagx5nWStEQ=;
        b=QwBUdtLRe+GtYippwc4zpBa5R8LV6x+qhfVbv7BsKbL9+FPGKU4OKQT5atsrGGZiKw
         85X1Mxfjm3XjIV820ARjByprArJKe3+HrUW6tKgBzDT13a8jUgD7sxBqewYZ+uDtPjMv
         TZzAzVCcPrDGmSX7LS0G86GuUrwYrHbH/7/TwdnEigPu4atz6AlozBOcLodMRZEJYVRF
         92ddOaTOWISCLgm4Zj5ZU2rkRJdIdeyxZ3XySxCg/P7zMNRqi3bmXc1Uk1iDkUG1zFGv
         czWYVkG4OYlp2wpJHt+qOZe5kjLqnl8q2/Pjz5xW8kogRItRty09yTyfbLnaOUpcwrGS
         0Sgg==
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=QNkR5+YF9P607B91Lj1268zSmV0FC3FfZagx5nWStEQ=;
        b=MZ42mP4tnq+waKeXDtoeN/ZhmMko++Z0gkt/2U/34+LM9AcxHMqFyQZswcYp1X1EZf
         9n27tcp47+hjWDRbHt5rSqckYTsaK+0DavOMj+SXDKvMpdhTdfRHUvjbuCk0ZWE5iftW
         LWr2Rbby1KfIm7TDi/H9kTH3P/svr0QJTjoh674Er3X9QxxxR/9Oy9GmeAXNSA5rY06a
         ylBkezR1+3ceBCQfYXqUd3Ir9Iq4QYNV9tXcydXU/U5zPZq0FUtOjcRvXDH5KvUeK397
         w2YLkeyZfKNCwryFCztiTRMpoVeY1vHl4CWUanUiHz3+trPT93uh9suLvMqHj0K+vPu0
         N+8A==
X-Gm-Message-State: AMCzsaWSVl5Q+pLcImf11OpOSYFzsuSmIbAi/lGQvHdw+TZZ1ZJ3owDH
	IqNnlvGjuHvv4uDvdA8LwNVuvQ==
X-Google-Smtp-Source: ABhQp+RwiooreyPtVM90P0V8SowcOtSDjDFlgZ8LX+CwVpA3a1xsA3T5n+jIJN6O3yb4dPvQAcl48g==
X-Received: by 10.28.143.13 with SMTP id r13mr656732wmd.30.1508050131135;
        Sat, 14 Oct 2017 23:48:51 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.197.15 with SMTP id v15ls893928wmf.2.canary-gmail; Sat, 14
 Oct 2017 23:48:50 -0700 (PDT)
X-Received: by 10.223.136.90 with SMTP id e26mr5200607wre.143.1508050130055;
        Sat, 14 Oct 2017 23:48:50 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1508050130; cv=none;
        d=google.com; s=arc-20160816;
        b=UK7rE8U4AtVJ4KC0JVc+qpqK/cWAAtCcdARUqsfticM4OcroLAKS0r0X5JxHWMvtQz
         glaZXEqEQlff/Vv2+Odo6VjQSmRnn1Zq6xx/gjaHJxRHByOKUdEYNbUcYOfP46EV1pQ4
         4C53s4/LLTiJGZLDQmWg7d4DjIsLdDWahzKlA1Qkt0GBziIusC5wDyVKcDrwZjdGBqjP
         EcbO9yAt3o9UrmZ9Gm9wHFStuVO3ueGEFtzYImcs1aIZe6TOu/AQlu0RO9mj1oArB3Fu
         o0N+fALf40N82zk5jaUBryqzKd8x0vpWTF6Yx8+DkHRrRfGCmyZch6I8UKaMGSh1S6Gc
         Z5ZQ==
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=/ftm+VISvHXVgvC8QORaUy+1UIfJE6BmtvbARp+PTiw=;
        b=AFbAiB3GSlQgmkCLgiM7bjEj3aC9K2zXDpR8X/zjJs239+Ghpdq+++D/7iuhul6JgF
         9Ku5IYzsjeB+xfa/5tOSG3o89c63HWpHeN8NYppe1ts+qed/DnpNKfqv5R6PlkV4uFix
         UKBVnrMdyoSA8RqAUHEZ6iySGz357eDzs5W4b3bt5lEbpRuS22yMWSR1qeyc6tESz+Fl
         7t8Lp4O6XvcGo0GHlQx0ZU+ah92Zyj0MVDQXMnjB0zdaDdRWTUsqVTyBvjiZRoze/Jkh
         T0JrEhhHHHOW4ghnZJf6MrmRu4Kf33VwwQ2t6JigSpoDLhzeD4LvjxW5dzsVNLX0N9xB
         bs6g==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=R5iWOSTz;
       spf=pass (google.com: domain of jonathanmueller.dev@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jonathanmueller.dev@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 y85sor1229146wmd.52.2017.10.14.23.48.50
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Sat, 14 Oct 2017 23:48:50 -0700 (PDT)
Received-SPF: pass (google.com: domain of jonathanmueller.dev@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 10.28.109.23 with SMTP id i23mr4591097wmc.32.1508050129597;
 Sat, 14 Oct 2017 23:48:49 -0700 (PDT)
Original-Received: by 10.223.173.203 with HTTP; Sat, 14 Oct 2017 23:48:48 -0700 (PDT)
Original-Received: by 10.223.173.203 with HTTP; Sat, 14 Oct 2017 23:48:48 -0700 (PDT)
In-Reply-To: <0a8293b4-3246-47a5-9881-bc1ca4b91772@isocpp.org>
X-Original-Sender: jonathanmueller.dev@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=R5iWOSTz;       spf=pass
 (google.com: domain of jonathanmueller.dev@gmail.com designates 209.85.220.41
 as permitted sender) smtp.mailfrom=jonathanmueller.dev@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-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:34937
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/34937>

--001a114699dc473a40055b9048b4
Content-Type: text/plain; charset="UTF-8"

On Oct 14, 2017 10:14, "Mingxin Wang" <wmx16835vv@163.com> wrote:

Specifically, in order to define a "concrete memory resource", I suggest to
add the following concept:

A type MR meets the MemoryResource requirements if the following
expressions are well-formed and have the specified semantics (mr denotes a
value of type MR).

mr.allocate(bytes, alignment)
  Requires: The types of `bytes` and `alignment` are both `std::size_t`.
  Returns: A pointer to allocated storage with a size of at least `bytes`.
The returned storage is aligned to the specified `alignment`, if such
alignment is supported; otherwise it is aligned to `max_align`.
  Throws: Appropriate exception if it is unable to allocate memory with the
requested size and alignment.

mr.deallocate(p, bytes, alignment)
  Requires: The type of `p` is `void*`, the type of `bytes` and `alignment`
are both `std::size_t`; `p` shall have been returned from a prior call to
`allocate(bytes, alignment)` on a memory resource equal to `*this`, and the
storage at `p` shall not yet have been deallocated.
  Effects: Dispose of allocated storage.
  Throws: Nothing.


<plug>
It is non-standard but my memory library provides an allocator concept
similar to those you've described. You can find it here:
github.com/foonathan/memory.
</plug>

I agree that making the PMRs polymorphic by default wasn't an ideal choice.
They should have been template based and provide a type erasure wrapper.

However, I've heard that the virtual overhead doesn't really matter much.

-- 
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/CAEddoJZzSZ5RROJ6Uu%3D2%2BR90mXi%2BhnHPDCxobrHM2daM6AxPVw%40mail.gmail.com.

--001a114699dc473a40055b9048b4
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div data-smartmail=3D"gmail_signature" dir=3D"auto">On O=
ct 14, 2017 10:14, &quot;Mingxin Wang&quot; &lt;<a href=3D"mailto:wmx16835v=
v@163.com">wmx16835vv@163.com</a>&gt; wrote:</div><div class=3D"gmail_extra=
" dir=3D"auto"><div class=3D"gmail_quote"><blockquote class=3D"quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"ltr"><div>Specifically, in order to define a &quot;concrete memory reso=
urce&quot;, I suggest to add the following concept:</div><div><br></div><di=
v>A type MR meets the MemoryResource requirements if the following expressi=
ons are well-formed and have the specified semantics (mr denotes a value of=
 type MR).</div><div><br></div><div>mr.allocate(bytes, alignment)</div><div=
>=C2=A0 Requires: The types of `bytes` and `alignment` are both `std::size_=
t`.</div><div>=C2=A0 Returns: A pointer to allocated storage with a size of=
 at least `bytes`. The returned storage is aligned to the specified `alignm=
ent`, if such alignment is supported; otherwise it is aligned to `max_align=
`.</div><div>=C2=A0 Throws: Appropriate exception if it is unable to alloca=
te memory with the requested size and alignment.</div><div><br></div><div>m=
r.deallocate(p, bytes, alignment)</div><div>=C2=A0 Requires: The type of `p=
` is `void*`, the type of `bytes` and `alignment` are both `std::size_t`; `=
p` shall have been returned from a prior call to `allocate(bytes, alignment=
)` on a memory resource equal to `*this`, and the storage at `p` shall not =
yet have been deallocated.</div><div>=C2=A0 Effects: Dispose of allocated s=
torage.</div><div>=C2=A0 Throws: Nothing.</div></div></blockquote></div></d=
iv><div dir=3D"auto"><br></div><div dir=3D"auto">&lt;plug&gt;</div><div cla=
ss=3D"gmail_extra" dir=3D"auto"></div><div dir=3D"auto">It is non-standard =
but my memory library provides an allocator concept similar to those you&#3=
9;ve described. You can find it here: <a href=3D"http://github.com/foonatha=
n/memory">github.com/foonathan/memory</a>.</div><div dir=3D"auto">&lt;/plug=
&gt;</div><div dir=3D"auto"><br></div><div dir=3D"auto">I agree that making=
 the PMRs polymorphic by default wasn&#39;t an ideal choice. They should ha=
ve been template based and provide a type erasure wrapper.</div><div dir=3D=
"auto"><br></div><div dir=3D"auto">However, I&#39;ve heard that the virtual=
 overhead doesn&#39;t really matter much.</div><div class=3D"gmail_extra" d=
ir=3D"auto"></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/CAEddoJZzSZ5RROJ6Uu%3D2%2BR90mXi%2Bhn=
HPDCxobrHM2daM6AxPVw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAEddoJZzSZ=
5RROJ6Uu%3D2%2BR90mXi%2BhnHPDCxobrHM2daM6AxPVw%40mail.gmail.com</a>.<br />

--001a114699dc473a40055b9048b4--

.
