220 25352 <C2CA1C21-42FC-448F-BCEE-F6B4F3EA8E55@gmail.com> article
Path: news.gmane.org!not-for-mail
From: David Krauss <potswa@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Allowing uncopyable allocators
Date: Sun, 27 Mar 2016 00:59:06 +0800
Lines: 179
Approved: news@gmane.org
Message-ID: <C2CA1C21-42FC-448F-BCEE-F6B4F3EA8E55@gmail.com>
References: <657cb0a7-4854-41c6-963f-5a11cc677157@isocpp.org> <CAGsORuBC6atKs+yAOZCUCCiPHdaQdL9eOon390G2j2W208+pew@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0 (Mac OS X Mail 9.1 \(3096.5\))
Content-Type: multipart/alternative; boundary="Apple-Mail=_BA5DEE2C-01DA-445B-B5C1-7F78B7413E42"
X-Trace: ger.gmane.org 1459011570 7457 80.91.229.3 (26 Mar 2016 16:59:30 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 26 Mar 2016 16:59:30 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCW25A7E3QCRBZX73K3QKGQEDM5IFYY@isocpp.org Sat Mar 26 17:59:22 2016
Return-path: <std-proposals+bncBCW25A7E3QCRBZX73K3QKGQEDM5IFYY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qg0-f72.google.com ([209.85.192.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCW25A7E3QCRBZX73K3QKGQEDM5IFYY@isocpp.org>)
	id 1ajrYX-0005Wu-DT
	for gclcip-std-proposals@m.gmane.org; Sat, 26 Mar 2016 17:59:21 +0100
Original-Received: by mail-qg0-f72.google.com with SMTP id c67sf118895870qgc.0
        for <gclcip-std-proposals@m.gmane.org>; Sat, 26 Mar 2016 09:59:20 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=from:message-id:mime-version:subject:date:references:to:in-reply-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=NtXOM1pUPohPIGx74Uu6+PQs3WyAPbloNj5P9UMIhT8=;
        b=OWfbT+bDbn8gI5/uLjjs9SWMRF9F+iWWFhLKBiMzaY7wfDHAwipxhFGMCyt6HHTEFq
         dwnkfzmBBYCIUpUk4d9X/XX1W10taGvIyYrLXQ3+NdF/u1uIARZEw4IX06ADqZIdB33E
         SM4V8qckFWsal5a5wm9zLK9P/iwjOr96HRY1+tOtfsHLF+XbzqxN+9eAOrY7GcQq2Z5d
         86PvFKUPmUWeHmt1DJysXGXj6N87Og9fx5X5US/l3Pw60amYk6CgCsWVryiYKgvIG/Xg
         0XtHFrmQ5RxtXomRoMnHU7ZRR+eEzoA+0uj5apiarCY6Zu/9oKGtzFWvqWWWw6q4ovDp
         KteQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:mime-version:subject:date
         :references:to:in-reply-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=NtXOM1pUPohPIGx74Uu6+PQs3WyAPbloNj5P9UMIhT8=;
        b=D8w3gHl7XcTktnONOWb5rjKUHLXwhWaNMFo4TGibzUNLjVPe4i3ow7TFPXUsUWYBzI
         NQvhZu6wKHiG9TTHb2VjLo97ScZ5TnzFAjrQI85VfTzjSXX+9ontehejPko+9mfnK0GS
         kqv/+We+SguATkjE91PeH0gw2PMsnEWdmvA7xUwJ4e7FTQUzSNm0yqWQl1VH9jg1/HNw
         Ff+ZzHj/RATL8XpqvtFFl/uftwy5nPWpGUt6D4XYfAeuO5gQUBBcrfb2wS7uUysbL/2+
         1T45eyMJUbVhCbblzcDs30GHpqoOF65tN0PZzrBhkOoBlecQO/n7TVUUeUD8WYGgjZ+L
         SuJw==
X-Gm-Message-State: AD7BkJJO0zOtnu1m0u2l/MrhsHHkIKa1LluMgqKnmVTrxzgl5mHoiBurFXg8QuoggZyl3Q==
X-Received: by 10.140.97.244 with SMTP id m107mr12375088qge.20.1459011559704;
        Sat, 26 Mar 2016 09:59:19 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.33.85 with SMTP id h82ls993818ioh.63.gmail; Sat, 26 Mar
 2016 09:59:18 -0700 (PDT)
X-Received: by 10.98.74.17 with SMTP id x17mr30049380pfa.14.1459011558522;
        Sat, 26 Mar 2016 09:59:18 -0700 (PDT)
Original-Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com. [2607:f8b0:400e:c00::243])
        by mx.google.com with ESMTPS id q75si2221571pfq.207.2016.03.26.09.59.18
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Sat, 26 Mar 2016 09:59:18 -0700 (PDT)
Received-SPF: pass (google.com: domain of potswa@gmail.com designates 2607:f8b0:400e:c00::243 as permitted sender) client-ip=2607:f8b0:400e:c00::243;
Original-Received: by mail-pf0-x243.google.com with SMTP id x3so15189347pfb.0
        for <std-proposals@isocpp.org>; Sat, 26 Mar 2016 09:59:18 -0700 (PDT)
X-Received: by 10.98.15.142 with SMTP id 14mr29927044pfp.6.1459011558201;
        Sat, 26 Mar 2016 09:59:18 -0700 (PDT)
Original-Received: from [172.20.10.2] ([121.54.54.140])
        by smtp.gmail.com with ESMTPSA id f8sm24253765pfj.49.2016.03.26.09.59.14
        for <std-proposals@isocpp.org>
        (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
        Sat, 26 Mar 2016 09:59:17 -0700 (PDT)
In-Reply-To: <CAGsORuBC6atKs+yAOZCUCCiPHdaQdL9eOon390G2j2W208+pew@mail.gmail.com>
X-Mailer: Apple Mail (2.3096.5)
X-Original-Sender: potswa@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of potswa@gmail.com
 designates 2607:f8b0:400e:c00::243 as permitted sender) smtp.mailfrom=potswa@gmail.com;
       dmarc=pass (p=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:25352
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/25352>

--Apple-Mail=_BA5DEE2C-01DA-445B-B5C1-7F78B7413E42
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2016=E2=80=9301=E2=80=9317, at 7:38 AM, quicknir@gmail.com wrote:
>=20
> But what if your allocators want to own their own resources? Such allocat=
ors can never really allocate or deallocate each other's pointers, so they =
can never compare equal. This sounds like a big deal, but if your allocator=
 is uncopyable, then it's not an issue; there's no real situation where you=
 would ever necessarily expect them to compare equal.

It would be nice to see this avenue pursued. It would allow =E2=80=9Csmall=
=E2=80=9D or =E2=80=9Clocal=E2=80=9D vectors to be specializations of std::=
vector. Locally-optimized versions of all the standard containers would app=
ear for minimal effort.


> On 2016=E2=80=9301=E2=80=9317, at 12:12 PM, Zhihao Yuan <zy@miator.net> w=
rote:
>=20
> There won't be any issue after
>=20
>  http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2015/p0135r0.html
>=20
> being accepted.

The interface for initializing and retrieving the internal allocator would =
need to be revised, at least for the new local allocators. It would be nice=
 to even remove it, but querying the remaining capacity is too useful.

(Regarding =E2=80=9Cnever equal,=E2=80=9D pedantically, if you can obtain a=
 reference to a local allocator, then it should compare equal to itself.)


> On 2016=E2=80=9301=E2=80=9317, at 3:50 PM, quicknir@gmail.com wrote:
>=20
> Not sure what polymorphic means in this context (polymorphic allocator?),

Polymorphic allocators exist on the opposite end of the overall problem dom=
ain of allocators. Every allocator object gets reduced to a polymorphic poi=
nter, and every allocation and deallocation is dispatched as a virtual func=
tion. This helps interoperability at the expense of performance. It=E2=80=
=99s part of the Fundamentals TS; it may or may not be adopted by C++17.

> I've literally seen examples of people rewriting std::function from scrat=
ch so that they could change the size of the small function optimization be=
cause heap allocation is a major issue for them.

This seems to be fairly common. Unfortunately, the small function optimizat=
ion takes place outside the allocator. You could perhaps hack a local alloc=
ator into my function_container <https://github.com/potswa/cxx_function> te=
mplate. But you=E2=80=99d want to forbid converting that back to an ordinar=
y function, or else do something clever like heap-allocate the local alloca=
tor. The library doesn=E2=80=99t provide for that. Also, the ordinary small=
-function optimization would be made redundant=E2=80=A6 it=E2=80=99s possib=
le that this is an entirely different problem.


> On 2016=E2=80=9303=E2=80=9326, at 11:44 PM, Yun Chen <yun.go.chen@gmail.c=
om> wrote:
>=20
> We should extend it to move construction through select_on_container_move=
_construction, as we need the ability of default constructing the allocator=
 too. This would be required to move construct an container in an arena fro=
m stack. =20

=E2=80=A6 and lest it be overlooked, if these allocators aren=E2=80=99t cop=
yable, they=E2=80=99re not movable either.

--=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/C2CA1C21-42FC-448F-BCEE-F6B4F3EA8E55%40gmail.com=
..

--Apple-Mail=_BA5DEE2C-01DA-445B-B5C1-7F78B7413E42
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><div class=3D""><b=
r class=3D""></div><blockquote type=3D"cite" class=3D""><div class=3D"">On =
2016=E2=80=9301=E2=80=9317, at 7:38 AM, <a href=3D"mailto:quicknir@gmail.co=
m" class=3D"">quicknir@gmail.com</a> wrote:</div><br class=3D"Apple-interch=
ange-newline"><div class=3D""><span class=3D"" style=3D"float: none; displa=
y: inline !important;">But what if your allocators want to own their own re=
sources? Such allocators can never really allocate or deallocate each other=
's pointers, so they can never compare equal. This sounds like a big deal, =
but if your allocator is uncopyable, then it's not an issue; there's no rea=
l situation where you would ever necessarily expect them to compare equal.<=
/span></div></blockquote><div class=3D""><div class=3D""><span class=3D"" s=
tyle=3D"float: none; display: inline !important;"><br class=3D""></span></d=
iv></div><div class=3D""><span class=3D"" style=3D"float: none; display: in=
line !important;">It would be nice to see this avenue pursued. It would all=
ow =E2=80=9Csmall=E2=80=9D or =E2=80=9Clocal=E2=80=9D vectors to be special=
izations of <font face=3D"Courier" class=3D"">std::vector</font>. Locally-o=
ptimized versions of all the standard containers would appear for minimal e=
ffort.</span></div><div class=3D""><br class=3D""></div><div class=3D""><sp=
an class=3D"" style=3D"font-size: small; float: none; display: inline !impo=
rtant;"><br class=3D""></span></div><div><blockquote type=3D"cite" class=3D=
""><div class=3D"">On 2016=E2=80=9301=E2=80=9317, at 12:12 PM, Zhihao Yuan =
&lt;<a href=3D"mailto:zy@miator.net" class=3D"">zy@miator.net</a>&gt; wrote=
:</div><br class=3D"Apple-interchange-newline"><div class=3D""><div class=
=3D"">There won't be any issue after<br class=3D""><br class=3D""> &nbsp;<a=
 href=3D"http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2015/p0135r0.ht=
ml" class=3D"">http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2015/p013=
5r0.html</a><br class=3D""><br class=3D"">being accepted.<br class=3D""></d=
iv></div></blockquote></div><br class=3D""><div class=3D"">The interface fo=
r initializing and retrieving the internal allocator would need to be revis=
ed, at least for the new local allocators. It would be nice to even remove =
it, but querying the remaining capacity is too useful.</div><div class=3D""=
><br class=3D""></div><div class=3D"">(Regarding =E2=80=9Cnever equal,=E2=
=80=9D pedantically, if you can obtain a reference to a local allocator, th=
en it should compare equal to itself.)</div><div class=3D""><br class=3D"">=
</div><div class=3D""><br class=3D""></div><div class=3D""><blockquote type=
=3D"cite" class=3D"">On 2016=E2=80=9301=E2=80=9317, at 3:50 PM, <a href=3D"=
mailto:quicknir@gmail.com" class=3D"">quicknir@gmail.com</a> wrote:</blockq=
uote><blockquote type=3D"cite"><br class=3D"Apple-interchange-newline"><div=
 class=3D""></div></blockquote><blockquote type=3D"cite" class=3D""><div cl=
ass=3D""><span class=3D"" style=3D"float: none; display: inline !important;=
">Not sure what polymorphic means in this context (polymorphic allocator?),=
</span></div></blockquote><div class=3D""><br class=3D""></div><div class=
=3D"">Polymorphic allocators exist on the opposite end of the overall probl=
em domain of allocators. Every allocator object gets reduced to a polymorph=
ic pointer, and every allocation and deallocation is dispatched as a virtua=
l function. This helps interoperability at the expense of performance. It=
=E2=80=99s part of the Fundamentals TS; it may or may not be adopted by C++=
17.</div><br class=3D""><blockquote type=3D"cite" class=3D""><div class=3D"=
"><span class=3D"" style=3D"float: none; display: inline !important;"> I've=
 literally seen examples of people rewriting std::function from scratch so =
that they could change the size of the small function optimization because =
heap allocation is a major issue for them.</span></div></blockquote><br cla=
ss=3D""></div><div class=3D"">This seems to be fairly common. Unfortunately=
, the small function optimization takes place outside the allocator. You co=
uld perhaps hack a local allocator into my&nbsp;<a href=3D"https://github.c=
om/potswa/cxx_function" class=3D""><font face=3D"Courier" class=3D"">functi=
on_container</font></a>&nbsp;template. But you=E2=80=99d want to forbid con=
verting that back to an ordinary <font face=3D"Courier" class=3D"">function=
</font>, or else do something clever like heap-allocate the local allocator=
.. The library doesn=E2=80=99t provide for that. Also, the ordinary small-fu=
nction optimization would be made redundant=E2=80=A6 it=E2=80=99s possible =
that this is an entirely different problem.</div><div class=3D""><br class=
=3D""></div><div class=3D""><br class=3D""></div><div class=3D""><blockquot=
e type=3D"cite" class=3D""><div class=3D"">On 2016=E2=80=9303=E2=80=9326, a=
t 11:44 PM, Yun Chen &lt;<a href=3D"mailto:yun.go.chen@gmail.com" class=3D"=
">yun.go.chen@gmail.com</a>&gt; wrote:</div><br class=3D"Apple-interchange-=
newline"><div class=3D""><div class=3D"">We should extend it to move constr=
uction through select_on_container_move_construction, as we need the abilit=
y of default constructing the allocator too. This would be required to move=
 construct an container in an arena from stack. &nbsp;</div></div></blockqu=
ote><br class=3D""></div><div class=3D"">=E2=80=A6 and lest it be overlooke=
d, if these allocators aren=E2=80=99t copyable, they=E2=80=99re not movable=
 either.</div><div class=3D""><br class=3D""></div></body></html>

<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/C2CA1C21-42FC-448F-BCEE-F6B4F3EA8E55%=
40gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/C2CA1C21-42FC-448F-BCEE-F6B4F3EA8E55%=
40gmail.com</a>.<br />

--Apple-Mail=_BA5DEE2C-01DA-445B-B5C1-7F78B7413E42--

.
